# HG changeset patch # User Goffi # Date 1306104319 -7200 # Node ID 71a9cc9b9d57d3e8c1e46242c839fb0b391889fb # Parent 7782a786b2f0fd1cb91f869fcfba8fc6fbdb21a1 Browser side: Tarot game - draw game managed - we can now play continuously \o/ diff -r 7782a786b2f0 -r 71a9cc9b9d57 browser_side/card_game.py --- a/browser_side/card_game.py Sun May 22 17:56:59 2011 +0200 +++ b/browser_side/card_game.py Mon May 23 00:45:19 2011 +0200 @@ -125,9 +125,6 @@ self._autoplay = None #XXX: use 0 to activate fake play, None else self.referee = referee self.players = players - self.played = {} - for player in players: - self.played[player] = None self.player_nick = player_nick self.bottom_nick = self.player_nick idx = self.players.index(self.player_nick) @@ -212,13 +209,6 @@ self.setCellVerticalAlignment(self.center_panel, HasAlignment.ALIGN_MIDDLE) self.setCellHorizontalAlignment(self.center_panel, HasAlignment.ALIGN_CENTER) - - """for side in zip(['left', 'top', 'right'], - [DockPanel.WEST, DockPanel.NORTH, DockPanel.EAST]): - _nick = getattr(self, "%s_nick" % side[0]) - _label = Label(_nick) - _label.setStyleName('cardGamePlayerNick') - self.add(_label, side[1])""" self.loadCards() self.mouse_over_card = None #contain the card to highlight self.visible_size = CARD_WIDTH/2 #number of pixels visible for cards @@ -403,9 +393,25 @@ """Show score at this end of a round""" ###XXX: we cheat here as XMLUI is not implemented yet #TODO: usr XMLUI - if self.player_nick in winners: - title = "You win !" + def _new_game(): + self.selected.clear() + del self.hand[:] + del self.to_show[:] + self.state = None + #empty hand + self.updateHand() + #nothing on the table + self.updateToShow() + for pos in ['top','left','bottom','right']: + getattr(self, "inner_%s" % pos).setWidget(None) + self._parent.host.bridge.call('tarotGameReady', None, self.player_nick, self.referee) + + if not winners and not loosers: + title = "Draw game" else: - title = "You loose :(" + if self.player_nick in winners: + title = "You win !" + else: + title = "You loose :(" body = re.sub(r'<.*?>',lambda x:'
' if '/elem' in x.group(0) else '', xml_data) #Q&D conversion to simple HTML text - SimpleDialog(title, body).show() + SimpleDialog(title, body, _new_game).show() diff -r 7782a786b2f0 -r 71a9cc9b9d57 browser_side/dialog.py --- a/browser_side/dialog.py Sun May 22 17:56:59 2011 +0200 +++ b/browser_side/dialog.py Mon May 23 00:45:19 2011 +0200 @@ -112,11 +112,12 @@ class SimpleDialog(DialogBox): - def __init__(self, title, body): + def __init__(self, title, body, callback = None): """Simple notice dialog box @param title: HTML put in the header @param body: HTML put in the body""" DialogBox.__init__(self, centered=True) + self.callback = callback _body = VerticalPanel() _body.setSpacing(4) _body.add(HTML(body)) @@ -127,3 +128,5 @@ def onClose(self): self.hide() + if self.callback: + self.callback() diff -r 7782a786b2f0 -r 71a9cc9b9d57 browser_side/register.py --- a/browser_side/register.py Sun May 22 17:56:59 2011 +0200 +++ b/browser_side/register.py Mon May 23 00:45:19 2011 +0200 @@ -48,8 +48,10 @@ vPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) self.loginBox = TextBox() self.loginBox.setName("login") + self.loginBox.setText("goffi_local") self.passBox = PasswordTextBox() self.passBox.setName("password") + self.passBox.setText("toto") grid = Grid(2, 2) grid.setText(0,0,"Login:") grid.setWidget(0,1, self.loginBox)