]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
UNO: prevent player from replaying a misplayed card
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 22 Sep 2011 20:42:02 +0000 (22:42 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 22 Sep 2011 20:42:02 +0000 (22:42 +0200)
data/rbot/plugins/games/uno.rb

index ab0ea161e44cd7885a7cbf800e3aa40874804524..df6a1eee1bf040b6f6f7c921ae298c05a56d07c1 100644 (file)
@@ -515,7 +515,7 @@ class UnoGame
       announce _("%{lp}'s move was %{b}not%{b} legal, %{lp} must pick %{b}%{n}%{b} cards and play again!") % {
         :cp => cp, :lp => lp, :b => Bold, :n => @picker
       }
-      lp.cards << @discard # put the W+4 back in place
+      played = @discard # store the misplayed W+4
 
       # reset the discard
       @color = @last_color.dup
@@ -527,7 +527,10 @@ class UnoGame
 
       # force the player to play the current cards
       @must_play = lp.cards.dup
+      # but not the same (type of) card he misplayed, though
+      @must_play.delete(played)
 
+      lp.cards << played # reinstate the W+4 in the list of player cards
       # give him the penalty cards
       deal(lp, @picker)
       @picker = 0