From b248fcaf86256bb92ae3d42090da7ae76dd07ce6 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sat, 16 Dec 2006 23:00:30 +0000 Subject: karma check for self++ now case insensitive --- data/rbot/plugins/azgame.rb | 15 +++++++++------ data/rbot/plugins/karma.rb | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/data/rbot/plugins/azgame.rb b/data/rbot/plugins/azgame.rb index ec804789..ae059f7c 100644 --- a/data/rbot/plugins/azgame.rb +++ b/data/rbot/plugins/azgame.rb @@ -6,6 +6,9 @@ # (C) 2006 Giuseppe Bilotta # # TODO allow manual addition of words +# TODO scoring: base score is t = ceil(100*exp(-(n-1)^2/50^))+p for n attempts +# done by p players; players that didn't win but contributed +# with a attempts will get t*a/n points AZ_RULES = { :italian => { @@ -80,7 +83,7 @@ class AzGamePlugin < Plugin def listen(m) return unless m.kind_of?(PrivMessage) return if m.channel.nil? or m.address? - k = m.channel.to_s # to_sym? + k = m.channel.downcase.to_s # to_sym? return unless @games.key?(k) return if m.params word = m.plugin.downcase @@ -108,7 +111,7 @@ class AzGamePlugin < Plugin end def manual_word_check(m, params) - k = m.channel.to_s + k = m.channel.downcase.to_s word = params[:word].downcase if not @games.key?(k) m.reply "no A-Z game running here, can't check for #{word}, can I?" @@ -123,7 +126,7 @@ class AzGamePlugin < Plugin def stop_game(m, params) return if m.channel.nil? # Shouldn't happen, but you never know - k = m.channel.to_s # to_sym? + k = m.channel.downcase.to_s # to_sym? if @games.key?(k) m.reply "the word in #{Bold}#{@games[k].range}#{Bold} was: #{Bold}#{@games[k].word}" @games.delete(k) @@ -134,7 +137,7 @@ class AzGamePlugin < Plugin def start_game(m, params) return if m.channel.nil? # Shouldn't happen, but you never know - k = m.channel.to_s # to_sym? + k = m.channel.downcase.to_s # to_sym? unless @games.key?(k) lang = (params[:lang] || @bot.config['core.language']).to_sym method = 'random_pick_'+lang.to_s @@ -333,7 +336,7 @@ class AzGamePlugin < Plugin return false end debug p - if p =~ /#{word}<\/span>([^\n]+?)#{rules[:good]}<\/span>/i + if p =~ /#{word}<\/span>([^\n]+?)#{rules[:good]}<\/span>/i debug "new word #{word}" wc[word.to_sym] = {:who => :dict} return true @@ -383,7 +386,7 @@ class AzGamePlugin < Plugin lemmi = Array.new good = rules[:good] # We look for a lemma composed by a single word and of length at least two - p.scan(/(.*?)<\/span>([^\n]+?)#{rules[:good]}<\/span>/i) { |prelemma, discard| + p.scan(/(.*?)<\/span>([^\n]+?)#{rules[:good]}<\/span>/i) { |prelemma, discard| lemma = prelemma.downcase debug "checking lemma #{lemma} (#{prelemma}) and discarding #{discard}" next if wc.key?(lemma.to_sym) diff --git a/data/rbot/plugins/karma.rb b/data/rbot/plugins/karma.rb index 166a9df4..f4716e2b 100644 --- a/data/rbot/plugins/karma.rb +++ b/data/rbot/plugins/karma.rb @@ -69,7 +69,7 @@ class KarmaPlugin < Plugin key.sub!(/^\((.*)\)$/, "\1") key.gsub!(/\s+/, " ") next unless(key.length > 0) - next if(key == m.sourcenick) + next if(key.downcase == m.sourcenick.downcase) if(change == "++") @registry[key] += 1 if key =~ /^#{@bot.nick}$/i -- cgit v1.2.3