summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorMark Kretschmann <markey@web.de>2006-08-26 18:57:29 +0000
committerMark Kretschmann <markey@web.de>2006-08-26 18:57:29 +0000
commit4278e1faa85d60746004c47687b5834c135a54bb (patch)
treea41ed93e12f81d0755da8316474cbaeef7457869 /data
parentec6916f0d4c6b4b6e63b39e44daa136fe6614d1d (diff)
Separate out the winning messages in an extra file, as advised by tango_.
Diffstat (limited to 'data')
-rw-r--r--data/rbot/plugins/quiz.rb34
-rw-r--r--data/rbot/templates/quiz/win_messages11
2 files changed, 27 insertions, 18 deletions
diff --git a/data/rbot/plugins/quiz.rb b/data/rbot/plugins/quiz.rb
index 231a9c99..9e7aa454 100644
--- a/data/rbot/plugins/quiz.rb
+++ b/data/rbot/plugins/quiz.rb
@@ -92,6 +92,14 @@ class QuizPlugin < Plugin
#
def fetch_data( m )
# TODO: Make this configurable, and add support for more than one file (there's a size limit in linux too ;) )
+ # Read the winning messages file
+ @win_messages = Array.new
+ if File.exists? "#{@bot.botclass}/quiz/win_messages"
+ IO.foreach("#{@bot.botclass}/quiz/win_messages") { |line| @win_messages << line.chomp }
+ else
+ warning( "win_messages file not found!" )
+ end
+
path = "#{@bot.botclass}/quiz/quiz.rbot"
debug "Fetching from #{path}"
@@ -245,33 +253,23 @@ class QuizPlugin < Plugin
message = m.message.downcase.strip
if message == q.answer.downcase or message == q.answer_core.downcase
- replies = []
-
points = 1
if q.first_try
points += 1
- replies << "WHOPEEE! #{m.sourcenick.to_s} got it on the first try! That's worth an extra point. Answer was: #{q.answer}"
+ reply = "WHOPEEE! #{m.sourcenick.to_s} got it on the first try! That's worth an extra point. Answer was: #{q.answer}"
elsif q.rank_table.length >= 1 and m.sourcenick.to_s == q.rank_table[0][0]
- replies << "THE QUIZ CHAMPION defends his throne! Seems like #{m.sourcenick.to_s} is invicible! Answer was: #{q.answer}"
+ reply = "THE QUIZ CHAMPION defends his throne! Seems like #{m.sourcenick.to_s} is invicible! Answer was: #{q.answer}"
elsif q.rank_table.length >= 2 and m.sourcenick.to_s == q.rank_table[1][0]
- replies << "THE SECOND CHAMPION is on the way up! Hurry up #{m.sourcenick.to_s}, you only need #{q.rank_table[0][1].score - q.rank_table[1][1].score - 1} points to beat the king! Answer was: #{q.answer}"
+ reply = "THE SECOND CHAMPION is on the way up! Hurry up #{m.sourcenick.to_s}, you only need #{q.rank_table[0][1].score - q.rank_table[1][1].score - 1} points to beat the king! Answer was: #{q.answer}"
elsif q.rank_table.length >= 3 and m.sourcenick.to_s == q.rank_table[2][0]
- replies << "THE THIRD CHAMPION strikes again! Give it all #{m.sourcenick.to_s}, with #{q.rank_table[1][1].score - q.rank_table[2][1].score - 1} more points you'll reach the 2nd place! Answer was: #{q.answer}"
+ reply = "THE THIRD CHAMPION strikes again! Give it all #{m.sourcenick.to_s}, with #{q.rank_table[1][1].score - q.rank_table[2][1].score - 1} more points you'll reach the 2nd place! Answer was: #{q.answer}"
else
- replies << "BINGO!! #{m.sourcenick.to_s} got it right. The answer was: #{q.answer}"
- replies << "OMG!! PONIES!! #{m.sourcenick.to_s} is the cutest. The answer was: #{q.answer}"
- replies << "HUZZAAAH! #{m.sourcenick.to_s} did it again. The answer was: #{q.answer}"
- replies << "YEEEHA! Cowboy #{m.sourcenick.to_s} scored again. The answer was: #{q.answer}"
- replies << "STRIKE! #{m.sourcenick.to_s} pwned you all. The answer was: #{q.answer}"
- replies << "YAY :)) #{m.sourcenick.to_s} is totally invited to my next sleepover. The answer was: #{q.answer}"
- replies << "And the crowd GOES WILD for #{m.sourcenick.to_s}. The answer was: #{q.answer}"
- replies << "GOOOAAALLLL! That was one fine strike by #{m.sourcenick.to_s}. The answer was: #{q.answer}"
- replies << "HOO-RAY, #{m.sourcenick.to_s} deserves a medal! Only #{m.sourcenick.to_s} could have known the answer: #{q.answer}"
- replies << "OKAY, #{m.sourcenick.to_s} is officially a spermatologist! Answer was: #{q.answer}"
- replies << "WOOO, I bet that #{m.sourcenick.to_s} knows where the word 'trivia' comes from too! Answer was: #{q.answer}"
+ reply = @win_messages[rand( @win_messages.length )]
+ reply.gsub!( "<who>", m.sourcenick )
+ reply.gsub!( "<answer>", q.answer )
end
- m.reply replies[rand( replies.length )]
+ m.reply reply
player = nil
if q.registry.has_key?( m.sourcenick.to_s )
diff --git a/data/rbot/templates/quiz/win_messages b/data/rbot/templates/quiz/win_messages
new file mode 100644
index 00000000..e513b6d6
--- /dev/null
+++ b/data/rbot/templates/quiz/win_messages
@@ -0,0 +1,11 @@
+BINGO!! <who> got it right. The answer was: <answer>
+OMG!! PONIES!! <who> is the cutest. The answer was: <answer>
+HUZZAAAH! <who> did it again. The answer was: <answer>
+YEEEHA! Cowboy <who> scored again. The answer was: <answer>
+STRIKE! <who> pwned you all. The answer was: <answer>
+YAY :)) <who> is totally invited to my next sleepover. The answer was: <answer>
+And the crowd GOES WILD for <who>. The answer was: <answer>
+GOOOAAALLLL! That was one fine strike by <who>. The answer was: <answer>
+HOO-RAY, <who> deserves a medal! Only <who> could have known the answer: <answer>
+OKAY, <who> is officially a spermatologist! Answer was: <answer>
+WOOO, I bet that <who> knows where the word 'trivia' comes from too! Answer was: <answer>