comparison frontends/wix/card_game.py @ 90:4020931569b8

Tarot Game: session initialization
author Goffi <goffi@goffi.org>
date Sun, 23 May 2010 16:39:05 +0930
parents 66d784082930
children 39c672544593
comparison
equal deleted inserted replaced
89:23caf1051099 90:4020931569b8
81 81
82 82
83 class CardPanel(wx.Panel): 83 class CardPanel(wx.Panel):
84 """This class is used to display the cards""" 84 """This class is used to display the cards"""
85 85
86 def __init__(self, parent, players, user): 86 def __init__(self, parent, referee, players, user):
87 wx.Panel.__init__(self, parent) 87 wx.Panel.__init__(self, parent)
88 self.parent = parent
89 self.referee = referee
88 self.players = players 90 self.players = players
89 self.user = user 91 self.user = user
90 self.bottom_nick = self.user 92 self.bottom_nick = self.user
91 idx = self.players.index(self.user) 93 idx = self.players.index(self.user)
92 idx = (idx + 1) % len(self.players) 94 idx = (idx + 1) % len(self.players)
105 self.SetBackgroundColour(wx.GREEN) 107 self.SetBackgroundColour(wx.GREEN)
106 self.Bind(wx.EVT_SIZE, self.onResize) 108 self.Bind(wx.EVT_SIZE, self.onResize)
107 self.Bind(wx.EVT_PAINT, self.onPaint) 109 self.Bind(wx.EVT_PAINT, self.onPaint)
108 self.Bind(wx.EVT_MOTION, self.onMouseMove) 110 self.Bind(wx.EVT_MOTION, self.onMouseMove)
109 self.Bind(wx.EVT_LEFT_UP, self.onMouseClick) 111 self.Bind(wx.EVT_LEFT_UP, self.onMouseClick)
112 self.parent.host.bridge.tarotGameReady(user, referee, profile_key = self.parent.host.profile)
110 113
111 def load_cards(self, dir): 114 def load_cards(self, dir):
112 """Load all the cards in memory 115 """Load all the cards in memory
113 @param dir: directory where the PNG files are""" 116 @param dir: directory where the PNG files are"""
114 self.cards={} 117 self.cards={}
128 for value in map(str,range(1,11))+["valet","cavalier","dame","roi"]: 131 for value in map(str,range(1,11))+["valet","cavalier","dame","roi"]:
129 self.idx_cards.append(self.cards[family, value])""" #XXX: no need to sort the cards ! 132 self.idx_cards.append(self.cards[family, value])""" #XXX: no need to sort the cards !
130 133
131 def newGame(self, hand): 134 def newGame(self, hand):
132 """Start a new game, with given hand""" 135 """Start a new game, with given hand"""
136 print "gof: new game ici avec",hand
133 assert (len(self.hand) == 0) 137 assert (len(self.hand) == 0)
134 for family, value in hand: 138 for family, value in hand:
135 self.hand.append(self.cards[family, value]) 139 self.hand.append(self.cards[family, value])
136 self.hand.sort() 140 self.hand.sort()
137 self.my_turn = True 141 self.my_turn = True
196 idx-=1 200 idx-=1
197 if self.hand[idx] == self.selected: 201 if self.hand[idx] == self.selected:
198 del self.hand[idx] 202 del self.hand[idx]
199 self._recalc_ori() 203 self._recalc_ori()
200 self.Refresh() 204 self.Refresh()
201
202 class CardGame(wx.Frame, QuickChat):
203 """The window used to play all kind of card games"""
204
205 def __init__(self, host):
206 wx.Frame.__init__(self, None, pos=(0,0), size=(950,500))
207
208 self.host = host
209
210 self.sizer = wx.BoxSizer(wx.VERTICAL)
211 self.panel = CardPanel(self)
212 self.sizer.Add(self.panel, 1, flag=wx.EXPAND)
213 self.SetSizer(self.sizer)
214 self.SetAutoLayout(True)
215
216
217 #events
218