Mercurial > libervia-backend
comparison frontends/quick_frontend/quick_card_game.py @ 162:ae50b53ff868
misc Tarot fixes
- wix, primitivus, quick_frontend: autoplay fonction is activated by changing self._autoplay from None to 0 in quick card game
- primitivus: added forgotten import of log methods
- primitivus: fix bad selected color for notification messages
- primitivus: score are now shown
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 06 Aug 2010 12:18:50 +0800 |
parents | 74aaf230a7c3 |
children | fd2db62ea5eb |
comparison
equal
deleted
inserted
replaced
161:c37826d80f2a | 162:ae50b53ff868 |
---|---|
25 | 25 |
26 | 26 |
27 class QuickCardGame(): | 27 class QuickCardGame(): |
28 | 28 |
29 def __init__(self, parent, referee, players, player_nick): | 29 def __init__(self, parent, referee, players, player_nick): |
30 self.__fake_idx = 0 #gof: | 30 self._autoplay = None #XXX: use 0 to activate fake play, None else |
31 self.parent = parent | 31 self.parent = parent |
32 self.referee = referee | 32 self.referee = referee |
33 self.players = players | 33 self.players = players |
34 self.played = {} | 34 self.played = {} |
35 for player in players: | 35 for player in players: |
99 def myTurn(self): | 99 def myTurn(self): |
100 """Called when we have to play :)""" | 100 """Called when we have to play :)""" |
101 if self.state == "chien": | 101 if self.state == "chien": |
102 self.to_show = [] | 102 self.to_show = [] |
103 self.state = "play" | 103 self.state = "play" |
104 #self.__fakePlay() #gof: | 104 self.__fakePlay() |
105 | 105 |
106 def __fakePlay(self): | 106 def __fakePlay(self): |
107 """Convenience method for stupid autoplay | 107 """Convenience method for stupid autoplay |
108 /!\ don't forgot to comment any interactive dialog for invalid card""" | 108 /!\ don't forgot to comment any interactive dialog for invalid card""" |
109 #gof: | 109 if self._autoplay == None: |
110 if self.__fake_idx >= len(self.hand): | 110 return |
111 self.__fake_idx = 0 | 111 if self._autoplay >= len(self.hand): |
112 card = self.hand[self.__fake_idx] | 112 self._autoplay = 0 |
113 card = self.hand[self._autoplay] | |
113 self.parent.host.bridge.tarotGamePlayCards(self.player_nick, self.referee, [(card.suit, card.value)], profile_key = self.parent.host.profile) | 114 self.parent.host.bridge.tarotGamePlayCards(self.player_nick, self.referee, [(card.suit, card.value)], profile_key = self.parent.host.profile) |
114 del self.hand[self.__fake_idx] | 115 del self.hand[self._autoplay] |
115 self.state = "wait" | 116 self.state = "wait" |
116 self.__fake_idx+=1 | 117 self._autoplay+=1 |
117 | 118 |
118 def showScores(self, xml_data, winners, loosers): | 119 def showScores(self, xml_data, winners, loosers): |
119 """Called when the player as to select hist contrat | 120 """Called at the end of a game |
120 @param xml_data: SàT xml representation of the form""" | 121 @param xml_data: SàT xml representation of the scores |
122 @param winners: list of winners' nicks | |
123 @param loosers: list of loosers' nicks""" | |
121 raise NotImplementedError | 124 raise NotImplementedError |
122 | 125 |
123 def cardsPlayed(self, player, cards): | 126 def cardsPlayed(self, player, cards): |
124 """A card has been played by player""" | 127 """A card has been played by player""" |
125 if self.to_show: | 128 if self.to_show: |
147 | 150 |
148 for suit, value in played_cards: | 151 for suit, value in played_cards: |
149 self.hand.append(self.cards[suit, value]) | 152 self.hand.append(self.cards[suit, value]) |
150 | 153 |
151 self.hand.sort() | 154 self.hand.sort() |
152 #self.__fakePlay() #gof: | 155 self.__fakePlay() |
153 | 156 |