diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-10-14 12:52:47 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-10-14 14:49:46 +0200 |
commit | c3a762a2dbe70ffdd33455f0f82c7321548fc732 (patch) | |
tree | 89fa3e7b4b4e6e0ed2e3662f6e7c56050724ccee /data | |
parent | 68bcb2b77929549d171af3fd86774d325644d45c (diff) |
UNO plugin: fix playable cards during picks
A bug in the logic allowed a +2 to be playable on a Reverse of the wrong
color (e.g. g+2, gr, r+2).
Diffstat (limited to 'data')
-rw-r--r-- | data/rbot/plugins/games/uno.rb | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/data/rbot/plugins/games/uno.rb b/data/rbot/plugins/games/uno.rb index 47fac28d..ea7ed18b 100644 --- a/data/rbot/plugins/games/uno.rb +++ b/data/rbot/plugins/games/uno.rb @@ -336,14 +336,28 @@ class UnoGame # if play is forced, check against the only allowed cards return false if @must_play and not @must_play.include?(card) - # When a +something is online, you can only play a +something of same or - # higher something, or a Reverse of the correct color, or a Reverse on - # a Reverse - # TODO make optional if @picker > 0 - return true if card.picker >= @last_picker - return true if card.value == 'Reverse' and (card.color == @color or @discard.value == card.value) - return false + # During a picker run (i.e. after a +something was played and before a + # player is forced to pick) you can only play pickers (+2, +4) and + # Reverse. Reverse can be played if the previous card matches by color or + # value (as usual), a +4 can always be played, a +2 can be played on a +2 + # of any color or on a Reverse of the correct color unless a +4 was + # played on it + # TODO make optional + case card.value + when 'Reverse' + # Reverse can be played if it matches color or value + return (card.color == @color) || (@discard.value == card.value) + when '+2' + return false if @last_picker > 2 + return true if @discard.value == card.value + return true if @discard.value == 'Reverse' and @color == card.color + return false + when '+4' + return true + else + return false + end else # You can always play a Wild return true if Wild === card |