def check(word)\r
w = word.downcase\r
debug "checking #{w} for #{@word} in #{@range}"\r
+ # Since we're called threaded, bail out early if a winner\r
+ # was assigned already\r
+ return [:ignore, nil] if @winner\r
return [:bingo, nil] if w == @word\r
return [:out, @range] if w < @range.first or w > @range.last\r
return [:ignore, @range] if w == @range.first or w == @range.last\r
+ # This is potentially slow (for languages that check online)\r
return [:noexist, @range] unless @plugin.send("is_#{@lang}?", w)\r
debug "we like it"\r
+ # Check again if there was a winner in the mean time,\r
+ # and bail out if there was\r
+ return [:ignore, nil] if @winner\r
if w < @word and w > @range.first\r
@range.first.replace(w)\r
return [:in, @range]\r
:listener => /^[a-z]+$/\r
},\r
}\r
- \r
+\r
japanese_wordlist = "#{@bot.botclass}/azgame/wordlist-japanese"\r
if File.exist?(japanese_wordlist)\r
words = File.readlines(japanese_wordlist) \\r
when :out\r
m.reply _("%{word} is not in the range %{bold}%{range}%{bold}") % {:word => word, :bold => Bold, :range => isit.last} if m.address?\r
when :noexist\r
+ # bail out early if the game was won in the mean time\r
+ return if !@games[k] or @games[k].winner\r
m.reply _("%{word} doesn't exist or is not acceptable for the game") % {:word => word}\r
@games[k].total_failed += 1\r
@games[k].failed[m.source] += 1\r
when :in\r
+ # bail out early if the game was won in the mean time\r
+ return if !@games[k] or @games[k].winner\r
m.reply _("close, but no cigar. New range: %{bold}%{range}%{bold}") % {:bold => Bold, :range => isit.last}\r
@games[k].total_tries += 1\r
@games[k].tries[m.source] += 1\r
:invalid_tries => n_("%{count} invalid try", "%{count} invalid tries", tr) %\r
{:count => f_tr} }\r
else\r
- tr_msg = _(" (after %{total_tries}") %\r
+ tr_msg = _(" (after %{total_tries})") %\r
{ :total_tries => n_("%{count} try", "%{count} tries", tr) %\r
{:count => tr}}\r
end\r
def is_japanese?(word)\r
@rules[:japanese][:list].include?(word)\r
end\r
- \r
+\r
# return integer between min and max, inclusive\r
def rand_between(min, max)\r
rand(max - min + 1) + min\r
end\r
- \r
+\r
def random_pick_japanese(min=nil, max=nil)\r
rules = @rules[:japanese]\r
min = rules[:first] if min.nil_or_empty?\r