Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
877:386ab96af575 | 878:36c6495d86b0 |
---|---|
83 self.cards[card.suit, card.value]=card | 83 self.cards[card.suit, card.value]=card |
84 self.deck.append(card) | 84 self.deck.append(card) |
85 | 85 |
86 def newGame(self, hand): | 86 def newGame(self, hand): |
87 """Start a new game, with given hand""" | 87 """Start a new game, with given hand""" |
88 if hand is []: # reset the display after the scores have been showed | |
89 self.resetRound() | |
90 self.Refresh() | |
91 self.parent.host.bridge.tarotGameReady(self.player_nick, self.referee, self.parent.host.profile) | |
92 return | |
88 QuickCardGame.newGame(self, hand) | 93 QuickCardGame.newGame(self, hand) |
89 self._recalc_ori() | 94 self._recalc_ori() |
90 self.Refresh() | 95 self.Refresh() |
91 | 96 |
92 def contratSelected(self, data): | 97 def contratSelected(self, data): |
95 debug (_("Contrat choosed")) | 100 debug (_("Contrat choosed")) |
96 contrat = data[0][1] | 101 contrat = data[0][1] |
97 QuickCardGame.contratSelected(self, contrat) | 102 QuickCardGame.contratSelected(self, contrat) |
98 | 103 |
99 def chooseContrat(self, xml_data): | 104 def chooseContrat(self, xml_data): |
100 """Called when the player as to select his contrat | 105 """Called when the player has to select his contrat |
101 @param xml_data: SàT xml representation of the form""" | 106 @param xml_data: SàT xml representation of the form""" |
102 misc = {'callback': self.contratSelected} | 107 XMLUI(self.parent.host, xml_data, title=_('Please choose your contrat'), flags=['NO_CANCEL']) |
103 form = XMLUI(self.parent.host, xml_data, title = _('Please choose your contrat'), options = ['NO_CANCEL'], misc = misc) | |
104 | 108 |
105 def showScores(self, xml_data, winners, loosers): | 109 def showScores(self, xml_data, winners, loosers): |
106 """Called when the player as to select hist contrat | 110 """Called when the round is over, display the scores |
107 @param xml_data: SàT xml representation of the form""" | 111 @param xml_data: SàT xml representation of the form""" |
108 def _new_game(ignore): | |
109 self.resetRound() | |
110 self.Refresh() | |
111 self.parent.host.bridge.tarotGameReady(self.player_nick, self.referee, self.parent.host.profile) | |
112 | |
113 if not winners and not loosers: | 112 if not winners and not loosers: |
114 title = _("Draw game") | 113 title = _("Draw game") |
115 else: | 114 else: |
116 title = _('You win \o/') if self.player_nick in winners else _('You loose :(') | 115 title = _('You win \o/') if self.player_nick in winners else _('You loose :(') |
117 form = XMLUI(self.parent.host, xml_data, title = title, options = ['NO_CANCEL'], misc={'callback':_new_game}) | 116 XMLUI(self.parent.host, xml_data, title=title, flags=['NO_CANCEL']) |
118 | 117 |
119 def cardsPlayed(self, player, cards): | 118 def cardsPlayed(self, player, cards): |
120 """A card has been played by player""" | 119 """A card has been played by player""" |
121 QuickCardGame.cardsPlayed(self, player, cards) | 120 QuickCardGame.cardsPlayed(self, player, cards) |
122 self.Refresh() | 121 self.Refresh() |