class AzGame\r
\r
attr_reader :range, :word\r
- attr_accessor :tries, :total_tries, :winner\r
+ attr_accessor :tries, :total_tries, :total_failed, :failed, :winner\r
def initialize(plugin, lang, word)\r
@plugin = plugin\r
@lang = lang.to_sym\r
@word = word.downcase\r
@range = [AZ_RULES[lang][:first].dup, AZ_RULES[lang][:last].dup]\r
@total_tries = 0\r
+ @total_failed = 0 # not used, reported, updated\r
@tries = Hash.new(0)\r
+ @failed = Hash.new(0) # not used, not reported, updated\r
@winner = nil\r
def @range.to_s\r
return "%s -- %s" % self\r
m.reply "#{word} is not in the range #{Bold}#{isit.last}#{Bold}" if m.address?\r
when :noexist\r
m.reply "#{word} doesn't exist or is not acceptable for the game"\r
+ @games[k].total_failed += 1\r
+ @games[k].failed[m.source] += 1\r
when :in\r
m.reply "close, but no cigar. New range: #{Bold}#{isit.last}#{Bold}"\r
@games[k].total_tries += 1\r
@games[k] = AzGame.new(self, lang, word)\r
end\r
tr = @games[k].total_tries\r
- m.reply "A-Z: #{Bold}#{@games[k].range}#{Bold}" + (tr > 0 ? " (after #{tr} tries)" : "")\r
+ case tr\r
+ when 0\r
+ tr_msg = ""\r
+ when 1\r
+ tr_msg = " (after 1 try"\r
+ else\r
+ tr_msg = " (after #{tr} tries"\r
+ end\r
+\r
+ unless tr_msg.empty?\r
+ f_tr = @games[k].total_failed\r
+ case f_tr\r
+ when 0\r
+ tr_msg << ")"\r
+ when 1\r
+ tr_msg << " and 1 invalid try)"\r
+ else\r
+ tr_msg << " and #{f_tr} invalid tries)"\r
+ end\r
+ end\r
+\r
+ m.reply "A-Z: #{Bold}#{@games[k].range}#{Bold}" + tr_msg\r
return\r
end\r
\r