Tarot game:

- draw game managed
- we can now play continuously \o/
This commit is contained in:
Goffi 2011-05-23 00:46:51 +02:00
commit 2ff3e80b08
3 changed files with 63 additions and 10 deletions

View file

@ -274,7 +274,17 @@ class CardGame(QuickCardGame,urwid.WidgetWrap):
def showScores(self, xml_data, winners, loosers):
"""Called when the player as to select hist contrat
@param xml_data: SàT xml representation of the form"""
form = XMLUI(self.parent.host, xml_data, title = _('You win \o/') if self.player_nick in winners else _('You loose :('), options = ['NO_CANCEL'])
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, profile_key = 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.show()
def invalidCards(self, phase, played_cards, invalid_cards):

View file

@ -27,7 +27,7 @@ from sat.tools.jid import JID
class QuickCardGame():
def __init__(self, parent, referee, players, player_nick):
self._autoplay = None #XXX: use 0 to activate fake play, None else
self._autoplay = 0 #None #XXX: use 0 to activate fake play, None else
self.parent = parent
self.referee = referee
self.players = players
@ -50,6 +50,15 @@ class QuickCardGame():
self.to_show = []
self.state = None
def resetRound(self):
"""Reset the game's variables to be reatty to start the next round"""
del self.selected[:]
del self.hand[:]
del self.to_show[:]
self.state = None
for pl in self.played:
self.played[pl] = None
def getPlayerLocation(self, nick):
"""return player location (top,bottom,left or right)"""
for location in ['top','left','bottom','right']:
@ -91,10 +100,10 @@ class QuickCardGame():
self.to_show = []
for suit, value in cards:
self.to_show.append(self.cards[suit, value])
if game_stage == "chien" and data['attaquant'] == self.player_nick:
self.state = "wait_for_ecart"
else:
self.state = "chien"
if game_stage == "chien" and data['attaquant'] == self.player_nick:
self.state = "wait_for_ecart"
else:
self.state = "chien"
def myTurn(self):
"""Called when we have to play :)"""

View file

@ -105,7 +105,16 @@ class CardPanel(QuickCardGame,wx.Panel):
def showScores(self, xml_data, winners, loosers):
"""Called when the player as to select hist contrat
@param xml_data: SàT xml representation of the form"""
form = XMLUI(self.parent.host, xml_data, title = _('You win \o/') if self.player_nick in winners else _('You loose :('), options = ['NO_CANCEL'])
def _new_game(ignore):
self.resetRound()
self.Refresh()
self.parent.host.bridge.tarotGameReady(self.player_nick, self.referee, profile_key = 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})
def cardsPlayed(self, player, cards):
"""A card has been played by player"""