diff options
author | Okasu <oka.sux@gmail.com> | 2012-01-21 02:33:15 -0500 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2012-01-23 15:18:28 +0100 |
commit | 435e7d0a7f47626d59b71867712dd82fde67c097 (patch) | |
tree | 6ae0d0a12be48e3718333a63a3583d8a1a87e756 /data/rbot | |
parent | b73f06958c304dc5bc82523765f893211785f2d0 (diff) |
greed: prevent players from going twice in a row
Diffstat (limited to 'data/rbot')
-rw-r--r-- | data/rbot/plugins/games/greed.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/data/rbot/plugins/games/greed.rb b/data/rbot/plugins/games/greed.rb index 93a88158..c81fda5e 100644 --- a/data/rbot/plugins/games/greed.rb +++ b/data/rbot/plugins/games/greed.rb @@ -14,6 +14,7 @@ class Greed < Plugin def initialize super @scoreboard = {} + @players = [] end def help(plugin, topic="") @@ -79,6 +80,11 @@ class Greed < Plugin def greed(m, params) player = scores mhash = {m.sourcenick => player[1]} + @players.push mhash.to_a[0][0] + if @players[-1] == @players[-2] + m.reply _("Oh you, %{who}! You can't go twice in a row!") % {:who => @players[-1]} + return + end @scoreboard.merge! mhash m.reply _("you rolled (%{roll}) for %{pts} points (%{groups})") % { :roll => player[0].join(' '), @@ -97,6 +103,8 @@ class Greed < Plugin else m.reply _("You win!") end + @players.clear + return end if @scoreboard.values.size == 2 m.reply _("%{who} wins!") % { @@ -104,6 +112,7 @@ class Greed < Plugin @scoreboard.keys.first : @scoreboard.keys.last } @scoreboard.clear + @players.clear end end end |