]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/games/hangman.rb
Suppress warnings about unitialized variables
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / games / hangman.rb
index d571fd782d4fc204a10feceb0aff7a32b74c8625..2a4bf33851419867f103ad36dcd47a1f83ee1165 100644 (file)
@@ -63,7 +63,7 @@ class Hangman
 end
 
 class Hangman
-  attr_reader :misses, :guesses, :word, :letters, :scores
+  attr_reader :misses, :guesses, :word, :scores
 
   STAGES = [' (x_x) ', ' (;_;) ', ' (>_<) ', ' (-_-) ', ' (o_~) ', ' (^_^) ', '\(^o^)/']
   HEALTH = STAGES.size-1
@@ -242,15 +242,15 @@ class HangmanPlugin < Plugin
   def help(plugin, topic="")
     case topic
     when ""
-      return "hangman game plugin - topics: play, stop"
+      return _("hangman game plugin - topics: play, stop")
     when "play"
-      return "hangman play on <channel> with word <word> => use in private chat with the bot to start a game with custom word\n"+
-             "hangman play random [with [max|min] length [<|>|== <length>]] => hangman with a random word from #{RandomWord::SITE}\n"+
-             "hangman play with wordlist <wordlist> => hangman with random word from <wordlist>"
+      return [_("hangman play on <channel> with word <word> => use in private chat with the bot to start a game with custom word\n"),
+              _("hangman play random [with [max|min] length [<|>|== <length>]] => hangman with a random word from %{site}\n"),
+              _("hangman play with wordlist <wordlist> => hangman with random word from <wordlist>")].join
     when "stop"
-      return "hangman stop => quits the current game"
+      return _("hangman stop => quits the current game")
     when "define"
-      return "define => seeks a definition for the previous answer using google"
+      return _("define => seeks a definition for the previous answer using google")
     end
   end
 
@@ -261,7 +261,7 @@ class HangmanPlugin < Plugin
       begin
         wordlist = Wordlist.get(params[:wordlist].join("/"), :spaces => true)
       rescue
-        raise "no such wordlist"
+        raise _("no such wordlist")
       end
 
       wordlist[rand(wordlist.size)]
@@ -282,7 +282,7 @@ class HangmanPlugin < Plugin
         unless words.empty?
           words.first
         else
-          m.reply "suitable word not found in the set"
+          m.reply _("suitable word not found in the set")
           nil
         end
       else
@@ -365,16 +365,17 @@ class HangmanPlugin < Plugin
       end
 
       if game.over?
-        str = if game.won?
+        sentence = if game.won?
           _("you nailed it!")
         elsif game.lost?
           _("you've killed the poor guy :(")
         end
 
-        str << _(" go #{Bold}again#{Bold}?")
+        again = _("go %{b}again%{b}?") % { :b => Bold }
 
+        scores = []
         game.scores.each do |user, score|
-          str << " #{user.nick}: "
+          str = "#{user.nick}: "
           str << if score > 0
             Irc.color(:green)+'+'
           elsif score < 0
@@ -383,9 +384,13 @@ class HangmanPlugin < Plugin
 
           str << score.round.to_s
           str << Irc.color
+
+          scores << str
         end
 
-        m.reply str, :nick => true
+        m.reply _("%{sentence} %{again} %{scores}") % {
+          :sentence => sentence, :again => again, :scores => scores.join(' ')
+        }, :nick => true
 
         if rand(5).zero?
           m.reply _("wondering what that means? try ´%{prefix}define´") % {