diff frontends/src/primitivus/card_game.py @ 323:7bc1b3401ecb

primitivus: fixed state state change in tarot game
author Goffi <goffi@goffi.org>
date Tue, 10 May 2011 15:46:01 +0200
parents b1794cbb88e5
children 809733b8d9be
line wrap: on
line diff
--- a/frontends/src/primitivus/card_game.py	Tue May 10 15:42:12 2011 +0200
+++ b/frontends/src/primitivus/card_game.py	Tue May 10 15:46:01 2011 +0200
@@ -292,15 +292,10 @@
         """A card has been played by player"""
         QuickCardGame.cardsPlayed(self, player, cards)
         self.table.putCard(self.getPlayerLocation(player),self.played[player])
+        self._checkState()
         self.parent.host.redraw()
-    
-    ##EVENTS##
-    def onClick(self, hand, card_wid):
-        """Called when user do an action on the hand"""
-        if not self.state in ['play','ecart','wait_for_ecart']:
-            #it's not our turn, we ignore the click
-            card_wid.select(False)
-            return
+   
+    def _checkState(self):
         if isinstance(self.center.widget_list[1].original_widget, Hand): #if we have a hand displayed
             self.center.widget_list[1] = urwid.Filler(self.table) #we show again the table
             if self.state == "chien":
@@ -312,6 +307,16 @@
                 self.hand.sort()
                 self.to_show = []
                 self.hand_wid.update(self.hand)
+        
+
+    ##EVENTS##
+    def onClick(self, hand, card_wid):
+        """Called when user do an action on the hand"""
+        if not self.state in ['play','ecart','wait_for_ecart']:
+            #it's not our turn, we ignore the click
+            card_wid.select(False)
+            return
+        self._checkState()
         if self.state ==  "ecart":
             if len(self.hand_wid.getSelected()) == 6:
                 pop_up_widget = sat_widgets.ConfirmDialog(_("Do you put these cards in chien ?"), yes_cb=self.onEcartDone, no_cb=self.parent.host.removePopUp)