+ def message(m)
+ return if m.address?
+ 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
+
+ def buy(m, p)
+ ch = m.channel.irc_downcase(m.server.casemap).intern
+ game = @games[ch]
+ if not game
+ m.reply _("there's no %{name} game running on %{chan}") % {
+ :name => @bot.config['wheelfortune.game_name'],
+ :chan => m.channel
+ }
+ return
+ elsif !game.running?
+ m.reply _("there are no %{name} questions for %{chan}, I'm waiting for %{who} to add them") % {
+ :name => game.name,
+ :chan => chan,
+ :who => game.manager
+ }
+ return
+ else
+ vowel = p[:vowel]
+ bought = game.buy(m.source)
+ if bought
+ m.reply _("%{who} buys a %{vowel} for %{price} points") % {
+ :who => m.source,
+ :vowel => vowel,
+ :price => game.price
+ }
+ check = game.check(vowel, :buy => true)
+ react_on_check(m, ch, game, check)
+ else
+ m.reply _("you can't buy a %{vowel}, %{who}: it costs %{price} points and you only have %{score}") % {
+ :who => m.source,
+ :vowel => vowel,
+ :price => game.price,
+ :score => game.score(m.source)
+ }
+ end
+ end
+ end
+