summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-07-26 13:49:58 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-07-29 22:20:37 +0200
commit9f6b528de0d7902d1f22cf8cdd7d656cc82e2c32 (patch)
treef0011fd1ed0908543015341c94ecdcb5165066a2
parent3e3ae3b4ce4d35d2796d2e73206da31f8bde1655 (diff)
wheeloffortune plugin: fix a bug where the wrong timing would get the QA stuck at always being the same
-rw-r--r--data/rbot/plugins/games/wheelfortune.rb21
1 files changed, 18 insertions, 3 deletions
diff --git a/data/rbot/plugins/games/wheelfortune.rb b/data/rbot/plugins/games/wheelfortune.rb
index e0b0930d..569ad129 100644
--- a/data/rbot/plugins/games/wheelfortune.rb
+++ b/data/rbot/plugins/games/wheelfortune.rb
@@ -11,10 +11,16 @@
class WoFQA
attr_accessor :cat, :clue, :hint
attr_reader :answer
+ attr_accessor :guessed
def initialize(cat, clue, ans=nil)
@cat = cat # category
@clue = clue # clue phrase
self.answer = ans
+ @guessed = false
+ end
+
+ def guessed?
+ @guessed
end
def catclue
@@ -149,6 +155,10 @@ class WoFGame
end
end
+ def mark_guessed(qa)
+ qa.guessed = true
+ end
+
def mark_winner(user)
@running = false
k = user.botuser
@@ -331,7 +341,7 @@ class WheelOfFortune < Plugin
:name => game.name,
:count => game.length
}
- announce(m, p.merge({ :next => true }) ) unless game.running?
+ announce(m, p) unless game.running?
else
m.reply _("something went wrong, I can't seem to understand what you're trying to set up") if clue.empty?
end
@@ -416,7 +426,10 @@ class WheelOfFortune < Plugin
return
end
game = @games[ch]
- qa = p[:next] ? game.next : game.current
+ qa = game.current
+ if !qa or qa.guessed?
+ qa = game.next
+ end
if !qa
m.reply _("there are no %{name} questions for %{chan}, I'm waiting for %{who} to add them") % {
:name => game.name,
@@ -472,6 +485,7 @@ class WheelOfFortune < Plugin
# TODO what happens when the last hint reveals the whole answer?
announce(m)
when :gotit
+ game.mark_guessed(game.current)
want_more = game.mark_winner(m.source)
m.reply _("%{who} got it! The answer was: %{ans}") % {
:who => m.sourcenick,
@@ -498,7 +512,7 @@ class WheelOfFortune < Plugin
:nocolor => Irc.color()
}
score_table(m.channel, game)
- announce(m, :next => true)
+ announce(m)
end
else
# can this happen?
@@ -511,6 +525,7 @@ class WheelOfFortune < Plugin
ch = m.channel.irc_downcase(m.server.casemap).intern
return unless game = @games[ch]
return unless game.running?
+ return unless game.current and not game.current.guessed?
check = game.check(m.message, :buy => false)
react_on_check(m, ch, game, check)
end