diff frontends/wix/card_game.py @ 99:63c9067a1499

Tarot game: invalid cards management - tarot plugin: card validity check, new signal tarotGameInvalidCards - wix: when an invalid cards signal is received, the cards are back in the hand, and the state change so the player as to play again.
author Goffi <goffi@goffi.org>
date Fri, 18 Jun 2010 15:19:32 +0800
parents 01d7bd6f0e86
children 94011f553cd0
line wrap: on
line diff
--- a/frontends/wix/card_game.py	Thu Jun 03 17:43:49 2010 +0930
+++ b/frontends/wix/card_game.py	Fri Jun 18 15:19:32 2010 +0800
@@ -193,6 +193,29 @@
         self.played[player] = pl_cards[0]
         self.Refresh()
 
+    def invalidCards(self, phase, played_cards, invalid_cards):
+        """Invalid cards have been played
+        @param phase: phase of the game
+        @param played_cards: all the cards played
+        @param invalid_cards: cards which are invalid"""
+
+        if phase == "play":
+            self.state = "play"
+        elif phase == "ecart":
+            self.state = "ecart"
+        else:
+            error ('INTERNAL ERROR: unmanaged game phase')
+        
+        for suit, value in played_cards:
+            self.hand.append(self.cards[suit, value])
+        
+        self._recalc_ori()
+        self.Refresh()
+        self.hand.sort()
+        wx.MessageDialog(self, _("Cards played are invalid !"), _("Error"), wx.OK | wx.ICON_ERROR).ShowModal()
+
+
+
 
     def _is_on_hand(self, pos_x, pos_y):
         """Return True if the coordinate are on the hand cards"""