diff frontends/src/primitivus/card_game.py @ 878:36c6495d86b0

plugin card_game: update to use the new XMLUI mechanism: TODO: the new round is not starting after the scores have been displayed
author souliane <souliane@mailoo.org>
date Wed, 26 Feb 2014 02:17:43 +0100
parents 1fe00f0c9a91
children b12706d164d7
line wrap: on
line diff
--- a/frontends/src/primitivus/card_game.py	Wed Feb 26 02:13:29 2014 +0100
+++ b/frontends/src/primitivus/card_game.py	Wed Feb 26 02:17:43 2014 +0100
@@ -249,6 +249,13 @@
 
     def newGame(self, hand):
         """Start a new game, with given hand"""
+        if hand is []:  # reset the display after the scores have been showed
+            self.resetRound()
+            for location in ['top', 'left', 'bottom', 'right']:
+                self.table.putCard(location, None)
+            self.parent.host.redraw()
+            self.parent.host.bridge.tarotGameReady(self.player_nick, self.referee, self.parent.host.profile)
+            return
         QuickCardGame.newGame(self, hand)
         self.hand_wid.update(self.hand)
         self.parent.host.redraw()
@@ -260,10 +267,9 @@
         QuickCardGame.contratSelected(self, contrat)
 
     def chooseContrat(self, xml_data):
-        """Called when the player as to select his contrat
+        """Called when the player has to select his contrat
         @param xml_data: SàT xml representation of the form"""
-        misc = {'callback': self.contratSelected}
-        form = XMLUI(self.parent.host, xml_data, title=_('Please choose your contrat'), options=['NO_CANCEL'], misc=misc)
+        form = XMLUI(self.parent.host, xml_data, title=_('Please choose your contrat'), flags=['NO_CANCEL'])
         form.show(valign='top')
 
     def showCards(self, game_stage, cards, data):
@@ -276,19 +282,13 @@
         QuickCardGame.myTurn(self)
 
     def showScores(self, xml_data, winners, loosers):
-        """Called when the player as to select hist contrat
+        """Called when the round is over, display the scores
         @param xml_data: SàT xml representation of the form"""
-        def _new_game(ignore):
-            self.resetRound()
-            for location in ['top', 'left', 'bottom', 'right']:
-                self.table.putCard(location, None)
-            self.parent.host.redraw()
-            self.parent.host.bridge.tarotGameReady(self.player_nick, self.referee, self.parent.host.profile)
         if not winners and not loosers:
             title = _("Draw game")
         else:
             title = _('You win \o/') if self.player_nick in winners else _('You loose :(')
-        form = XMLUI(self.parent.host, xml_data, title=title, options=['NO_CANCEL'], misc={'callback': _new_game})
+        form = XMLUI(self.parent.host, xml_data, title=title, flags=['NO_CANCEL'])
         form.show()
 
     def invalidCards(self, phase, played_cards, invalid_cards):