Mercurial > libervia-backend
comparison frontends/src/primitivus/card_game.py @ 323:7bc1b3401ecb
primitivus: fixed state state change in tarot game
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 10 May 2011 15:46:01 +0200 |
parents | b1794cbb88e5 |
children | 809733b8d9be |
comparison
equal
deleted
inserted
replaced
322:2b9b6b6ec717 | 323:7bc1b3401ecb |
---|---|
290 | 290 |
291 def cardsPlayed(self, player, cards): | 291 def cardsPlayed(self, player, cards): |
292 """A card has been played by player""" | 292 """A card has been played by player""" |
293 QuickCardGame.cardsPlayed(self, player, cards) | 293 QuickCardGame.cardsPlayed(self, player, cards) |
294 self.table.putCard(self.getPlayerLocation(player),self.played[player]) | 294 self.table.putCard(self.getPlayerLocation(player),self.played[player]) |
295 self._checkState() | |
295 self.parent.host.redraw() | 296 self.parent.host.redraw() |
296 | 297 |
297 ##EVENTS## | 298 def _checkState(self): |
298 def onClick(self, hand, card_wid): | |
299 """Called when user do an action on the hand""" | |
300 if not self.state in ['play','ecart','wait_for_ecart']: | |
301 #it's not our turn, we ignore the click | |
302 card_wid.select(False) | |
303 return | |
304 if isinstance(self.center.widget_list[1].original_widget, Hand): #if we have a hand displayed | 299 if isinstance(self.center.widget_list[1].original_widget, Hand): #if we have a hand displayed |
305 self.center.widget_list[1] = urwid.Filler(self.table) #we show again the table | 300 self.center.widget_list[1] = urwid.Filler(self.table) #we show again the table |
306 if self.state == "chien": | 301 if self.state == "chien": |
307 self.to_show = [] | 302 self.to_show = [] |
308 self.state = "wait" | 303 self.state = "wait" |
310 self.state = "ecart" | 305 self.state = "ecart" |
311 self.hand.extend(self.to_show) | 306 self.hand.extend(self.to_show) |
312 self.hand.sort() | 307 self.hand.sort() |
313 self.to_show = [] | 308 self.to_show = [] |
314 self.hand_wid.update(self.hand) | 309 self.hand_wid.update(self.hand) |
310 | |
311 | |
312 ##EVENTS## | |
313 def onClick(self, hand, card_wid): | |
314 """Called when user do an action on the hand""" | |
315 if not self.state in ['play','ecart','wait_for_ecart']: | |
316 #it's not our turn, we ignore the click | |
317 card_wid.select(False) | |
318 return | |
319 self._checkState() | |
315 if self.state == "ecart": | 320 if self.state == "ecart": |
316 if len(self.hand_wid.getSelected()) == 6: | 321 if len(self.hand_wid.getSelected()) == 6: |
317 pop_up_widget = sat_widgets.ConfirmDialog(_("Do you put these cards in chien ?"), yes_cb=self.onEcartDone, no_cb=self.parent.host.removePopUp) | 322 pop_up_widget = sat_widgets.ConfirmDialog(_("Do you put these cards in chien ?"), yes_cb=self.onEcartDone, no_cb=self.parent.host.removePopUp) |
318 self.parent.host.showPopUp(pop_up_widget) | 323 self.parent.host.showPopUp(pop_up_widget) |
319 elif self.state == "play": | 324 elif self.state == "play": |