#-- vim:sw=2:et
#++
#
-# Plugin for the Ruby IRC bot (http://linuxbrit.co.uk/rbot/)
-#
-# A trivia quiz game. Fast paced, featureful and fun.
+# :title: Quiz plugin for rbot
#
# Author:: Mark Kretschmann <markey@web.de>
# Author:: Jocke Andersson <ajocke@gmail.com>
# Author:: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
# Author:: Yaohan Chen <yaohan.chen@gmail.com>
#
-# (c) 2006 Mark Kretschmann, Jocke Andersson, Giuseppe Bilotta
-# (c) 2007 Giuseppe Bilotta, Yaohan Chen
+# Copyright:: (C) 2006 Mark Kretschmann, Jocke Andersson, Giuseppe Bilotta
+# Copyright:: (C) 2007 Giuseppe Bilotta, Yaohan Chen
+#
+# License:: GPL v2
#
-# Licensed under GPL V2.
+# A trivia quiz game. Fast paced, featureful and fun.
-# FIXME interesting fact: in the Quiz class, @registry.has_key? seems to be
-# case insensitive. Although this is all right for us, this leads to rank vs
-# registry mismatches. So we have to make the @rank_table comparisons case
-# insensitive as well. For the moment, redefine everything to downcase before
-# matching the nick.
+# FIXME:: interesting fact: in the Quiz class, @registry.has_key? seems to be
+# case insensitive. Although this is all right for us, this leads to
+# rank vs registry mismatches. So we have to make the @rank_table
+# comparisons case insensitive as well. For the moment, redefine
+# everything to downcase before matching the nick.
#
-# TODO define a class for the rank table. We might also need it for scoring in
-# other games.
+# TODO:: define a class for the rank table. We might also need it for scoring
+# in other games.
#
-# TODO when Ruby 2.0 gets out, fix the FIXME 2.0 UTF-8 workarounds
+# TODO:: when Ruby 2.0 gets out, fix the FIXME 2.0 UTF-8 workarounds
# Class for storing question/answer pairs
QuizBundle = Struct.new( "QuizBundle", :question, :answer )
"Quiz game aministration commands (requires authentication): 'quiz autoask <on/off>' => enable/disable autoask mode. 'quiz autoask delay <secs>' => delay next quiz by <secs> seconds when in autoask mode. 'quiz transfer <source> <dest> [score] [jokers]' => transfer [score] points and [jokers] jokers from <source> to <dest> (default is entire score and all jokers). 'quiz setscore <player> <score>' => set <player>'s score to <score>. 'quiz setjokers <player> <jokers>' => set <player>'s number of jokers to <jokers>. 'quiz deleteplayer <player>' => delete one player from the rank table (only works when score and jokers are set to 0)."
else
urls = @bot.config['quiz.sources'].select { |p| p =~ /^https?:\/\// }
- "A multiplayer trivia quiz. 'quiz' => ask a question. 'quiz hint' => get a hint. 'quiz solve' => solve this question. 'quiz skip' => skip to next question. 'quiz joker' => draw a joker to win this round. 'quiz score [player]' => show score for [player] (default is yourself). 'quiz top5' => show top 5 players. 'quiz top <number>' => show top <number> players (max 50). 'quiz stats' => show some statistics. 'quiz fetch' => refetch questions from databases." + (urls.empty? ? "" : "\nYou can add new questions at #{urls.join(', ')}")
+ "A multiplayer trivia quiz. 'quiz' => ask a question. 'quiz hint' => get a hint. 'quiz solve' => solve this question. 'quiz skip' => skip to next question. 'quiz joker' => draw a joker to win this round. 'quiz score [player]' => show score for [player] (default is yourself). 'quiz top5' => show top 5 players. 'quiz top <number>' => show top <number> players (max 50). 'quiz stats' => show some statistics. 'quiz fetch' => refetch questions from databases. 'quiz refresh' => refresh the question pool for this channel." + (urls.empty? ? "" : "\nYou can add new questions at #{urls.join(', ')}")
end
end
else
q.canonical_answer = q.answers.first
end
-
+
q.first_try = true
# FIXME 2.0 UTF-8
q.hinted = true
# FIXME 2.0 UTF-8
- if q.hintrange.length == 0
+ if q.hint == q.answer_array
m.reply "#{Bold}#{Color}04BUST!#{Color}#{Bold} This round is over. #{Color}04Minus one point for #{nick}#{Color}."
stats = nil
end
+ def cmd_refresh( m, params )
+ q = create_quiz ( m.channel )
+ q.questions.clear
+ fetch_data ( m )
+ cmd_quiz( m, params )
+ end
+
+
def cmd_top5( m, params )
chan = m.channel
q = create_quiz( chan )
plugin.map 'quiz score', :action => 'cmd_score'
plugin.map 'quiz score :player', :action => 'cmd_score_player'
plugin.map 'quiz fetch', :action => 'cmd_fetch'
+plugin.map 'quiz refresh', :action => 'cmd_refresh'
plugin.map 'quiz top5', :action => 'cmd_top5'
plugin.map 'quiz top :number', :action => 'cmd_top_number'
plugin.map 'quiz stats', :action => 'cmd_stats'