comparison frontends/src/quick_frontend/quick_card_game.py @ 328:809733b8d9be

Tarot game: - draw game managed - we can now play continuously \o/
author Goffi <goffi@goffi.org>
date Mon, 23 May 2011 00:46:51 +0200
parents b1794cbb88e5
children be9f682c53a5
comparison
equal deleted inserted replaced
327:7c9784658163 328:809733b8d9be
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._autoplay = None #XXX: use 0 to activate fake play, None else 30 self._autoplay = 0 #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:
48 self.hand_size = 13 #number of cards in a hand 48 self.hand_size = 13 #number of cards in a hand
49 self.hand = [] 49 self.hand = []
50 self.to_show = [] 50 self.to_show = []
51 self.state = None 51 self.state = None
52 52
53 def resetRound(self):
54 """Reset the game's variables to be reatty to start the next round"""
55 del self.selected[:]
56 del self.hand[:]
57 del self.to_show[:]
58 self.state = None
59 for pl in self.played:
60 self.played[pl] = None
61
53 def getPlayerLocation(self, nick): 62 def getPlayerLocation(self, nick):
54 """return player location (top,bottom,left or right)""" 63 """return player location (top,bottom,left or right)"""
55 for location in ['top','left','bottom','right']: 64 for location in ['top','left','bottom','right']:
56 if getattr(self,'%s_nick' % location) == nick: 65 if getattr(self,'%s_nick' % location) == nick:
57 return location 66 return location
89 def showCards(self, game_stage, cards, data): 98 def showCards(self, game_stage, cards, data):
90 """Display cards in the middle of the game (to show for e.g. chien ou poignée)""" 99 """Display cards in the middle of the game (to show for e.g. chien ou poignée)"""
91 self.to_show = [] 100 self.to_show = []
92 for suit, value in cards: 101 for suit, value in cards:
93 self.to_show.append(self.cards[suit, value]) 102 self.to_show.append(self.cards[suit, value])
94 if game_stage == "chien" and data['attaquant'] == self.player_nick: 103 if game_stage == "chien" and data['attaquant'] == self.player_nick:
95 self.state = "wait_for_ecart" 104 self.state = "wait_for_ecart"
96 else: 105 else:
97 self.state = "chien" 106 self.state = "chien"
98 107
99 def myTurn(self): 108 def myTurn(self):
100 """Called when we have to play :)""" 109 """Called when we have to play :)"""
101 if self.state == "chien": 110 if self.state == "chien":
102 self.to_show = [] 111 self.to_show = []