]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/games/uno.rb
seen: show what user said or did before leaving
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / games / uno.rb
index bb6401257753695c39c5327eb9d2ae70140ded63..a86c33dba8d03216fa37cc9814baa885a470a318 100644 (file)
@@ -108,7 +108,7 @@ class UnoGame
       @color = 'Wild'
       raise if value and not value == '+4'
       if value
-        @value = value.dup 
+        @value = value.dup
         @shortform = 'w'+value
       else
         @value = nil
@@ -411,7 +411,7 @@ class UnoGame
         # only be possible if the first W+4 was illegal, so it wouldn't
         # apply for a W+4 played on a +2 anyway.
         #
-        if @picker == 0 and Wild === cards.first and cards.first.value 
+        if @picker == 0 and Wild === cards.first and cards.first.value
           # save the previous discard in case of challenge
           @last_discard = @discard.dup
           # save the color too, in case it was a Wild
@@ -845,8 +845,14 @@ class UnoPlugin < Plugin
       _("The points won with a game of %{uno} are totalled from the cards remaining in the hands of the other players."),
       _("Each normal (not special) card is worth its face value (from 0 to 9 points)."),
       _("Each colored special card (+2, Reverse, Skip) is worth 20 points."),
-      _("Each Wild and Wild +4 is worth 50 points.")
+      _("Each Wild and Wild +4 is worth 50 points."),
+      help(plugin, 'top'),
+      help(plugin, 'topwin'),
       ].join(" ") % { :uno => UnoGame::UNO }
+    when 'top'
+      _("You can see the scoring table with 'uno top N' where N is the number of top scores to show.")
+    when 'topwin'
+      _("You can see the winners table with 'uno topwin N' where N is the number of top winners to show.")
     when /cards?/
       [
       _("There are 108 cards in a standard %{uno} deck."),
@@ -863,7 +869,7 @@ class UnoPlugin < Plugin
       _("'uno end' to end the game before its natural completion")
       ].join("; ")
     else
-      _("%{uno} game. !uno to start a game. see 'help uno rules' for the rules, 'help uno admin' for admin commands. In-game commands: %{cmds}.") % {
+      _("%{uno} game. !uno to start a game. see 'help uno rules' for the rules, 'help uno admin' for admin commands, 'help uno score' for scoring rules. In-game commands: %{cmds}.") % {
         :uno => UnoGame::UNO,
         :cmds => help(plugin, 'commands')
       }
@@ -874,6 +880,7 @@ class UnoPlugin < Plugin
     return unless @games.key?(m.channel)
     return unless m.plugin # skip messages such as: <someuser> botname,
     g = @games[m.channel]
+    replied = true
     case m.plugin.intern
     when :jo # join game
       return if m.params
@@ -935,11 +942,14 @@ class UnoPlugin < Plugin
     when :tu # show whose turn is it
       return if m.params
       if g.has_turn?(m.source)
-        m.nickreply _("it's your turn, sleepyhead")
+        m.reply _("it's your turn, sleepyhead"), :nick => true
       else
         g.show_turn(:cards => false)
       end
+    else
+      replied=false
     end
+    m.replied=true if replied
   end
 
   def create_game(m, p)
@@ -1151,6 +1161,14 @@ class UnoPlugin < Plugin
       scores << [v.won.inject(0) { |s, w| s+=w.score }, k]
     end
 
+    if wins.empty?
+      m.reply(_("no %{uno} games were completed here") % {
+        :uno => UnoGame::UNO
+      })
+      return
+    end
+
+
     if n = p[:scorenum]
       msg = _("%{uno} %{num} highest scores: ") % {
         :uno => UnoGame::UNO, :num => p[:scorenum]