# (C) 2006 Giuseppe Bilotta\r
#\r
# TODO allow manual addition of words\r
+# TODO scoring: base score is t = ceil(100*exp(-(n-1)^2/50^))+p for n attempts\r
+# done by p players; players that didn't win but contributed\r
+# with a attempts will get t*a/n points\r
\r
AZ_RULES = {\r
:italian => {\r
def listen(m)\r
return unless m.kind_of?(PrivMessage)\r
return if m.channel.nil? or m.address?\r
- k = m.channel.to_s # to_sym?\r
+ k = m.channel.downcase.to_s # to_sym?\r
return unless @games.key?(k)\r
return if m.params\r
word = m.plugin.downcase\r
end\r
\r
def manual_word_check(m, params)\r
- k = m.channel.to_s\r
+ k = m.channel.downcase.to_s\r
word = params[:word].downcase\r
if not @games.key?(k)\r
m.reply "no A-Z game running here, can't check for #{word}, can I?"\r
\r
def stop_game(m, params)\r
return if m.channel.nil? # Shouldn't happen, but you never know\r
- k = m.channel.to_s # to_sym?\r
+ k = m.channel.downcase.to_s # to_sym?\r
if @games.key?(k)\r
m.reply "the word in #{Bold}#{@games[k].range}#{Bold} was: #{Bold}#{@games[k].word}"\r
@games.delete(k)\r
\r
def start_game(m, params)\r
return if m.channel.nil? # Shouldn't happen, but you never know\r
- k = m.channel.to_s # to_sym?\r
+ k = m.channel.downcase.to_s # to_sym?\r
unless @games.key?(k)\r
lang = (params[:lang] || @bot.config['core.language']).to_sym\r
method = 'random_pick_'+lang.to_s\r
return false\r
end\r
debug p\r
- if p =~ /<span class="hwd">#{word}<\/span>([^\n]+?)<span class="psa">#{rules[:good]}<\/span>/i\r
+ if p =~ /<span class="(?:hwd|srch)">#{word}<\/span>([^\n]+?)<span class="psa">#{rules[:good]}<\/span>/i\r
debug "new word #{word}"\r
wc[word.to_sym] = {:who => :dict}\r
return true\r
lemmi = Array.new\r
good = rules[:good]\r
# We look for a lemma composed by a single word and of length at least two\r
- p.scan(/<span class="hwd">(.*?)<\/span>([^\n]+?)<span class="psa">#{rules[:good]}<\/span>/i) { |prelemma, discard|\r
+ p.scan(/<span class="(?:hwd|srch)">(.*?)<\/span>([^\n]+?)<span class="psa">#{rules[:good]}<\/span>/i) { |prelemma, discard|\r
lemma = prelemma.downcase\r
debug "checking lemma #{lemma} (#{prelemma}) and discarding #{discard}"\r
next if wc.key?(lemma.to_sym)\r