summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-04-11 19:07:29 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-04-11 19:07:29 +0200
commit78e4b978141ee46a54b4a62d724985f5ab1b18d7 (patch)
treebdfd775fa39e5047316767090500a26981bf3c0b /data
parentf4c06c198fd6235e5932b73e91012e6fce22b6ad (diff)
uno plugin: don't fail to drop players that left the channel
Diffstat (limited to 'data')
-rw-r--r--data/rbot/plugins/games/uno.rb22
1 files changed, 17 insertions, 5 deletions
diff --git a/data/rbot/plugins/games/uno.rb b/data/rbot/plugins/games/uno.rb
index 1df903d3..5f1c2679 100644
--- a/data/rbot/plugins/games/uno.rb
+++ b/data/rbot/plugins/games/uno.rb
@@ -183,7 +183,18 @@ class UnoGame
end
def get_player(user)
- @players.each { |p| return p if p.user == user }
+ case user
+ when User
+ @players.each do |p|
+ return p if p.user == user
+ end
+ when String
+ @players.each do |p|
+ return p if p.user.irc_downcase == user.irc_downcase(channel.casemap)
+ end
+ else
+ get_player(user.to_s)
+ end
return nil
end
@@ -630,8 +641,10 @@ class UnoGame
end
end
- def drop_player(user)
- unless p = get_player(user)
+ def drop_player(nick)
+ # A nick is passed because the original player might have left
+ # the channel or IRC
+ unless p = get_player(nick)
announce _("%{p} isn't playing %{uno}") % {
:p => p, :uno => UNO
}
@@ -882,8 +895,7 @@ class UnoPlugin < Plugin
m.reply _("There is no %{uno} game running here") % { :uno => UnoGame::UNO }
return
end
- who = p[:nick] ? m.channel.get_user(p[:nick]) : m.source
- @games[m.channel].drop_player(who)
+ @games[m.channel].drop_player(p[:nick] || m.source.nick)
end
def print_stock(m, p)