X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fgames%2Funo.rb;h=df6a1eee1bf040b6f6f7c921ae298c05a56d07c1;hb=c4e7896a87d97988926d3b57f62599384c5c7189;hp=6b50d03e3b85799a9cc0314cdf40ebf4f6d5dcc2;hpb=539685183e46a9fe7f0d334688b8760a99e3d169;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/games/uno.rb b/data/rbot/plugins/games/uno.rb index 6b50d03e..df6a1eee 100644 --- a/data/rbot/plugins/games/uno.rb +++ b/data/rbot/plugins/games/uno.rb @@ -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 @@ -605,6 +608,12 @@ class UnoGame end def show_turn(opts={}) + if @players.empty? + announce _("nobody is playing %{uno} yet!") % { + :uno => UNO + } + return false + end cards = true cards = opts[:cards] if opts.key?(:cards) player = @players.first @@ -689,6 +698,13 @@ class UnoGame return end end + if @last_discard + announce _("you can't join now, %{p}, a %{card} was just played, wait until next turn") % { + :card => @discard, + :p => user + } + return + end cards = 7 if @start_time cards = (@players.inject(0) do |s, pl| @@ -759,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 @@ -818,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