diff frontends/src/wix/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 5a6354ff468c
line wrap: on
line diff
--- a/frontends/src/wix/card_game.py	Wed Feb 26 02:13:29 2014 +0100
+++ b/frontends/src/wix/card_game.py	Wed Feb 26 02:17:43 2014 +0100
@@ -85,6 +85,11 @@
 
     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()
+            self.Refresh()
+            self.parent.host.bridge.tarotGameReady(self.player_nick, self.referee, self.parent.host.profile)
+            return
         QuickCardGame.newGame(self, hand)
         self._recalc_ori()
         self.Refresh()
@@ -97,24 +102,18 @@
         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)
+        XMLUI(self.parent.host, xml_data, title=_('Please choose your contrat'), flags=['NO_CANCEL'])
 
     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()
-            self.Refresh()
-            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})
+        XMLUI(self.parent.host, xml_data, title=title, flags=['NO_CANCEL'])
 
     def cardsPlayed(self, player, cards):
         """A card has been played by player"""