From fb33606c5a7e2aa75c11bb5282987138920c8bde Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Wed, 9 Apr 2008 21:25:40 +0200 Subject: uno plugin: sort players' cards --- data/rbot/plugins/games/uno.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'data/rbot') 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) -- cgit v1.2.3