]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
uno plugin: when players join mid-game, give them an average number of gards
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 10 Apr 2008 11:23:49 +0000 (13:23 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 10 Apr 2008 11:23:49 +0000 (13:23 +0200)
data/rbot/plugins/games/uno.rb

index 4ea0ec35b6a3bf3c0ea639c8dda7e26a4e7ac20e..92bf2b48fe1ea73972f1923f865b0d603305b6df 100644 (file)
@@ -509,12 +509,19 @@ class UnoGame
       }
       return
     end
+    cards = 7
+    if @start_time
+      cards = @players.inject(0) do |s, pl|
+        s +=pl.cards.length
+      end/@players.length
+    end
     p = Player.new(user)
     @players << p
     announce _("%{p} joins this game of %{uno}") % {
       :p => p, :uno => UNO
     }
-    deal(p, 7)
+    deal(p, cards)
+    return if @start_time
     if @join_timer
       @bot.timer.reschedule(@join_timer, 10)
     elsif @players.length > 1