diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-04-09 21:25:40 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-04-09 21:25:40 +0200 |
commit | fb33606c5a7e2aa75c11bb5282987138920c8bde (patch) | |
tree | 8771341a162e87ec4bfa81cc19b700448a13fb0c /data/rbot | |
parent | 7ee14d61698e23c61a51cc6e15e836246eadb21e (diff) |
uno plugin: sort players' cards
Diffstat (limited to 'data/rbot')
-rw-r--r-- | data/rbot/plugins/games/uno.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/data/rbot/plugins/games/uno.rb b/data/rbot/plugins/games/uno.rb index 59cf0ba9..1d49642c 100644 --- a/data/rbot/plugins/games/uno.rb +++ b/data/rbot/plugins/games/uno.rb @@ -86,6 +86,16 @@ class UnoGame def special? SPECIALS.include?(@value) end + + def <=>(other) + cc = self.color <=> other.color + if cc == 0 + return self.value.to_s <=> other.value.to_s + else + return cc + end + end + include Comparable end # Wild, Wild +4 cards @@ -467,6 +477,7 @@ class UnoGame end notify player, _("You picked %{picked}") % { :picked => picked.join(' ') } player.cards += picked + player.cards.sort! end def add_player(user) |