comparison frontends/wix/card_game.py @ 99:63c9067a1499

Tarot game: invalid cards management - tarot plugin: card validity check, new signal tarotGameInvalidCards - wix: when an invalid cards signal is received, the cards are back in the hand, and the state change so the player as to play again.
author Goffi <goffi@goffi.org>
date Fri, 18 Jun 2010 15:19:32 +0800
parents 01d7bd6f0e86
children 94011f553cd0
comparison
equal deleted inserted replaced
98:dd556233a1b1 99:63c9067a1499
191 for suit, value in cards: 191 for suit, value in cards:
192 pl_cards.append(self.cards[suit, value]) 192 pl_cards.append(self.cards[suit, value])
193 self.played[player] = pl_cards[0] 193 self.played[player] = pl_cards[0]
194 self.Refresh() 194 self.Refresh()
195 195
196 def invalidCards(self, phase, played_cards, invalid_cards):
197 """Invalid cards have been played
198 @param phase: phase of the game
199 @param played_cards: all the cards played
200 @param invalid_cards: cards which are invalid"""
201
202 if phase == "play":
203 self.state = "play"
204 elif phase == "ecart":
205 self.state = "ecart"
206 else:
207 error ('INTERNAL ERROR: unmanaged game phase')
208
209 for suit, value in played_cards:
210 self.hand.append(self.cards[suit, value])
211
212 self._recalc_ori()
213 self.Refresh()
214 self.hand.sort()
215 wx.MessageDialog(self, _("Cards played are invalid !"), _("Error"), wx.OK | wx.ICON_ERROR).ShowModal()
216
217
218
196 219
197 def _is_on_hand(self, pos_x, pos_y): 220 def _is_on_hand(self, pos_x, pos_y):
198 """Return True if the coordinate are on the hand cards""" 221 """Return True if the coordinate are on the hand cards"""
199 if pos_x > self.orig_x and pos_y > self.orig_y \ 222 if pos_x > self.orig_x and pos_y > self.orig_y \
200 and pos_x < self.orig_x + (len(self.hand)+1) * self.visible_size \ 223 and pos_x < self.orig_x + (len(self.hand)+1) * self.visible_size \