Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
877:386ab96af575 | 878:36c6495d86b0 |
---|---|
247 self.cards[card.suit, card.value] = card | 247 self.cards[card.suit, card.value] = card |
248 self.deck.append(card) | 248 self.deck.append(card) |
249 | 249 |
250 def newGame(self, hand): | 250 def newGame(self, hand): |
251 """Start a new game, with given hand""" | 251 """Start a new game, with given hand""" |
252 if hand is []: # reset the display after the scores have been showed | |
253 self.resetRound() | |
254 for location in ['top', 'left', 'bottom', 'right']: | |
255 self.table.putCard(location, None) | |
256 self.parent.host.redraw() | |
257 self.parent.host.bridge.tarotGameReady(self.player_nick, self.referee, self.parent.host.profile) | |
258 return | |
252 QuickCardGame.newGame(self, hand) | 259 QuickCardGame.newGame(self, hand) |
253 self.hand_wid.update(self.hand) | 260 self.hand_wid.update(self.hand) |
254 self.parent.host.redraw() | 261 self.parent.host.redraw() |
255 | 262 |
256 def contratSelected(self, data): | 263 def contratSelected(self, data): |
258 @param data: form result""" | 265 @param data: form result""" |
259 contrat = data[0][1] | 266 contrat = data[0][1] |
260 QuickCardGame.contratSelected(self, contrat) | 267 QuickCardGame.contratSelected(self, contrat) |
261 | 268 |
262 def chooseContrat(self, xml_data): | 269 def chooseContrat(self, xml_data): |
263 """Called when the player as to select his contrat | 270 """Called when the player has to select his contrat |
264 @param xml_data: SàT xml representation of the form""" | 271 @param xml_data: SàT xml representation of the form""" |
265 misc = {'callback': self.contratSelected} | 272 form = XMLUI(self.parent.host, xml_data, title=_('Please choose your contrat'), flags=['NO_CANCEL']) |
266 form = XMLUI(self.parent.host, xml_data, title=_('Please choose your contrat'), options=['NO_CANCEL'], misc=misc) | |
267 form.show(valign='top') | 273 form.show(valign='top') |
268 | 274 |
269 def showCards(self, game_stage, cards, data): | 275 def showCards(self, game_stage, cards, data): |
270 """Display cards in the middle of the game (to show for e.g. chien ou poignée)""" | 276 """Display cards in the middle of the game (to show for e.g. chien ou poignée)""" |
271 QuickCardGame.showCards(self, game_stage, cards, data) | 277 QuickCardGame.showCards(self, game_stage, cards, data) |
274 | 280 |
275 def myTurn(self): | 281 def myTurn(self): |
276 QuickCardGame.myTurn(self) | 282 QuickCardGame.myTurn(self) |
277 | 283 |
278 def showScores(self, xml_data, winners, loosers): | 284 def showScores(self, xml_data, winners, loosers): |
279 """Called when the player as to select hist contrat | 285 """Called when the round is over, display the scores |
280 @param xml_data: SàT xml representation of the form""" | 286 @param xml_data: SàT xml representation of the form""" |
281 def _new_game(ignore): | |
282 self.resetRound() | |
283 for location in ['top', 'left', 'bottom', 'right']: | |
284 self.table.putCard(location, None) | |
285 self.parent.host.redraw() | |
286 self.parent.host.bridge.tarotGameReady(self.player_nick, self.referee, self.parent.host.profile) | |
287 if not winners and not loosers: | 287 if not winners and not loosers: |
288 title = _("Draw game") | 288 title = _("Draw game") |
289 else: | 289 else: |
290 title = _('You win \o/') if self.player_nick in winners else _('You loose :(') | 290 title = _('You win \o/') if self.player_nick in winners else _('You loose :(') |
291 form = XMLUI(self.parent.host, xml_data, title=title, options=['NO_CANCEL'], misc={'callback': _new_game}) | 291 form = XMLUI(self.parent.host, xml_data, title=title, flags=['NO_CANCEL']) |
292 form.show() | 292 form.show() |
293 | 293 |
294 def invalidCards(self, phase, played_cards, invalid_cards): | 294 def invalidCards(self, phase, played_cards, invalid_cards): |
295 """Invalid cards have been played | 295 """Invalid cards have been played |
296 @param phase: phase of the game | 296 @param phase: phase of the game |