plugin card_game: update to use the new XMLUI mechanism:

TODO: the new round is not starting after the scores have been displayed
This commit is contained in:
souliane 2014-02-26 02:17:43 +01:00
commit 5b3d5a2f42
2 changed files with 71 additions and 36 deletions

View file

@ -249,6 +249,13 @@ class CardGame(QuickCardGame, urwid.WidgetWrap):
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 @@ class CardGame(QuickCardGame, urwid.WidgetWrap):
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 @@ class CardGame(QuickCardGame, urwid.WidgetWrap):
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):

View file

@ -85,6 +85,11 @@ class CardPanel(QuickCardGame, wx.Panel):
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 @@ class CardPanel(QuickCardGame, wx.Panel):
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"""