Tarot game: score calculation

- plugin tarot: score validity is now checked (some of attackers and defender must equal 91)
- plugin tarot: new signal tarotGameScore to give the scores and winners/loosers
- wix: score are now displayed at the end of the game
- xml_tools: 'fixed' type is now managed in dataForm2xml
This commit is contained in:
Goffi 2010-06-02 15:57:23 +09:30
commit 1a9f7e8396
2 changed files with 139 additions and 20 deletions

View file

@ -53,6 +53,7 @@ class QuickApp():
self.bridge.register("tarotGameChooseContrat", self.tarotChooseContrat)
self.bridge.register("tarotGameShowCards", self.tarotShowCards)
self.bridge.register("tarotGameYourTurn", self.tarotMyTurn)
self.bridge.register("tarotGameScore", self.tarotScore)
self.bridge.register("tarotGameCardsPlayed", self.tarotCardsPlayed)
self.bridge.register("subscribe", self.subscribe)
self.bridge.register("paramUpdate", self.paramUpdate)
@ -308,6 +309,14 @@ class QuickApp():
if self.chat_wins.has_key(room_jid):
self.chat_wins[room_jid].getGame("Tarot").MyTurn()
def tarotScore(self, room_jid, xml_data, winners, loosers, profile):
"""Called when the game is finished and the score are updated"""
if not self.__check_profile(profile):
return
debug (_("Tarot: score received"))
if self.chat_wins.has_key(room_jid):
self.chat_wins[room_jid].getGame("Tarot").showScores(xml_data, winners, loosers)
def tarotCardsPlayed(self, room_jid, player, cards, profile):
if not self.__check_profile(profile):
return

View file

@ -174,7 +174,20 @@ class CardPanel(wx.Panel):
if self.state == "chien":
self.to_show = []
self.state = "play"
#tmp gof: FIXME
card = self.hand[-1]
self.parent.host.bridge.tarotGamePlayCards(self.player_nick, self.referee, [(card.suit, card.value)], profile_key = self.parent.host.profile)
del self.hand[-1]
self.state = "wait"
self._recalc_ori()
self.Refresh()
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 = Form(self.parent.host, xml_data, title = _('You win \o/') if self.player_nick in winners else _('You loose :('), options = ['NO_CANCEL'])
def cardsPlayed(self, player, cards):
"""A card has been played by player"""
if self.to_show: