Mercurial > libervia-backend
comparison frontends/primitivus/card_game.py @ 153:f197b52796ee
Primitivus: begining of management for actionResult
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 31 Jul 2010 00:34:05 +0800 |
parents | 63d20bda5754 |
children | 2fa58703f1b7 |
comparison
equal
deleted
inserted
replaced
152:b1f1955d96b3 | 153:f197b52796ee |
---|---|
92 | 92 |
93 def getSelected(self): | 93 def getSelected(self): |
94 """Return a list of selected cards""" | 94 """Return a list of selected cards""" |
95 _selected = [] | 95 _selected = [] |
96 for wid in self.columns.widget_list: | 96 for wid in self.columns.widget_list: |
97 if wid.__class__ == CardDisplayer and wid.isSelected(): | 97 if isinstance(wid, CardDisplayer) and wid.isSelected(): |
98 _selected.append(wid.getCard()) | 98 _selected.append(wid.getCard()) |
99 return _selected | 99 return _selected |
100 | 100 |
101 def update(self, hand): | 101 def update(self, hand): |
102 """Update the hand displayed in this widget | 102 """Update the hand displayed in this widget |
167 def putCard(self, location, card): | 167 def putCard(self, location, card): |
168 """Put a card on the table | 168 """Put a card on the table |
169 @param location: where to put the card (top, left, bottom or right) | 169 @param location: where to put the card (top, left, bottom or right) |
170 @param card: Card to play or None""" | 170 @param card: Card to play or None""" |
171 assert location in ['top','left','bottom','right'] | 171 assert location in ['top','left','bottom','right'] |
172 assert card.__class__ == Card or card == None | 172 assert isinstance(card,Card) or card == None |
173 if [getattr(self, place) for place in ['top','left','bottom','right']].count(None) == 0: | 173 if [getattr(self, place) for place in ['top','left','bottom','right']].count(None) == 0: |
174 #If the table is full of card, we remove them | 174 #If the table is full of card, we remove them |
175 self.top = self.left = self.bottom = self.right = None | 175 self.top = self.left = self.bottom = self.right = None |
176 setattr(self, location, card) | 176 setattr(self, location, card) |
177 self._invalidate() | 177 self._invalidate() |
288 """Called when user do an action on the hand""" | 288 """Called when user do an action on the hand""" |
289 if not self.state in ['play','ecart','wait_for_ecart']: | 289 if not self.state in ['play','ecart','wait_for_ecart']: |
290 #it's not our turn, we ignore the click | 290 #it's not our turn, we ignore the click |
291 card_wid.select(False) | 291 card_wid.select(False) |
292 return | 292 return |
293 if self.center.widget_list[1].original_widget.__class__ == Hand: #if we have a hand displayed | 293 if isinstance(self.center.widget_list[1].original_widget, Hand): #if we have a hand displayed |
294 self.center.widget_list[1] = urwid.Filler(self.table) #we show again the table | 294 self.center.widget_list[1] = urwid.Filler(self.table) #we show again the table |
295 if self.state == "chien": | 295 if self.state == "chien": |
296 self.to_show = [] | 296 self.to_show = [] |
297 self.state = "wait" | 297 self.state = "wait" |
298 elif self.state == "wait_for_ecart": | 298 elif self.state == "wait_for_ecart": |