]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/games/uno.rb
plugin(script): remove deprecated $SAFE
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / games / uno.rb
index 751543623313faeca00c1d8a47246fac228b32f6..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
@@ -772,9 +775,9 @@ class UnoGame
       }
       return false
     end
-    if p = get_player(user)
+    if pl = get_player(user)
       announce _("%{p} is already playing %{uno} here") % {
-        :p => p, :uno => UNO
+        :p => pl, :uno => UNO
       }
       return false
     end
@@ -831,12 +834,12 @@ class UnoGame
       deal(p, @picker)
       @picker = 0
     end
-    score = @players.inject(0) do |sum, p|
-      if p.cards.length > 0
+    score = @players.inject(0) do |sum, pl|
+      if pl.cards.length > 0
         announce _("%{p} still had %{cards}") % {
-          :p => p, :cards => p.cards.join(' ')
+          :p => pl, :cards => pl.cards.join(' ')
         }
-        sum += p.cards.inject(0) do |cs, c|
+        sum += pl.cards.inject(0) do |cs, c|
           cs += c.score
         end
       end