summaryrefslogtreecommitdiff
path: root/data/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-01-26 00:52:38 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-01-26 00:52:38 +0000
commit6ddef356ef83b534caf170d1f90028a4ec860589 (patch)
tree57ba5d0952d0054a70f390fd2cf1b8eaa96d8898 /data/rbot
parente8d0c5f2656ebca203aa6336233500e0967b0e30 (diff)
Keep track of invalid tries in azgame, but report them without considering them for scoring
Diffstat (limited to 'data/rbot')
-rw-r--r--data/rbot/plugins/azgame.rb29
1 files changed, 27 insertions, 2 deletions
diff --git a/data/rbot/plugins/azgame.rb b/data/rbot/plugins/azgame.rb
index ae410e87..c1ad3ea5 100644
--- a/data/rbot/plugins/azgame.rb
+++ b/data/rbot/plugins/azgame.rb
@@ -27,14 +27,16 @@ AZ_RULES = {
class AzGame
attr_reader :range, :word
- attr_accessor :tries, :total_tries, :winner
+ attr_accessor :tries, :total_tries, :total_failed, :failed, :winner
def initialize(plugin, lang, word)
@plugin = plugin
@lang = lang.to_sym
@word = word.downcase
@range = [AZ_RULES[lang][:first].dup, AZ_RULES[lang][:last].dup]
@total_tries = 0
+ @total_failed = 0 # not used, reported, updated
@tries = Hash.new(0)
+ @failed = Hash.new(0) # not used, not reported, updated
@winner = nil
def @range.to_s
return "%s -- %s" % self
@@ -132,6 +134,8 @@ class AzGamePlugin < Plugin
m.reply "#{word} is not in the range #{Bold}#{isit.last}#{Bold}" if m.address?
when :noexist
m.reply "#{word} doesn't exist or is not acceptable for the game"
+ @games[k].total_failed += 1
+ @games[k].failed[m.source] += 1
when :in
m.reply "close, but no cigar. New range: #{Bold}#{isit.last}#{Bold}"
@games[k].total_tries += 1
@@ -193,7 +197,28 @@ class AzGamePlugin < Plugin
@games[k] = AzGame.new(self, lang, word)
end
tr = @games[k].total_tries
- m.reply "A-Z: #{Bold}#{@games[k].range}#{Bold}" + (tr > 0 ? " (after #{tr} tries)" : "")
+ case tr
+ when 0
+ tr_msg = ""
+ when 1
+ tr_msg = " (after 1 try"
+ else
+ tr_msg = " (after #{tr} tries"
+ end
+
+ unless tr_msg.empty?
+ f_tr = @games[k].total_failed
+ case f_tr
+ when 0
+ tr_msg << ")"
+ when 1
+ tr_msg << " and 1 invalid try)"
+ else
+ tr_msg << " and #{f_tr} invalid tries)"
+ end
+ end
+
+ m.reply "A-Z: #{Bold}#{@games[k].range}#{Bold}" + tr_msg
return
end