Mercurial > libervia-web
comparison browser_side/card_game.py @ 41:7782a786b2f0
Tarot game: score is now shown (need to use XMLUI later)
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 22 May 2011 17:56:59 +0200 |
parents | 305e81c7a32c |
children | 71a9cc9b9d57 |
comparison
equal
deleted
inserted
replaced
40:49f1829fb928 | 41:7782a786b2f0 |
---|---|
37 from pyjamas import DOM | 37 from pyjamas import DOM |
38 | 38 |
39 from pyjamas.dnd import makeDraggable | 39 from pyjamas.dnd import makeDraggable |
40 from pyjamas.ui.DragWidget import DragWidget, DragContainer | 40 from pyjamas.ui.DragWidget import DragWidget, DragContainer |
41 from jid import JID | 41 from jid import JID |
42 from dialog import ConfirmDialog | 42 from dialog import ConfirmDialog, SimpleDialog |
43 from tools import html_sanitize | 43 from tools import html_sanitize |
44 from datetime import datetime | 44 from datetime import datetime |
45 from time import time | 45 from time import time |
46 from games import TarotCard | 46 from games import TarotCard |
47 import re | |
47 | 48 |
48 | 49 |
49 | 50 |
50 CARD_WIDTH = 74 | 51 CARD_WIDTH = 74 |
51 CARD_HEIGHT = 136 | 52 CARD_HEIGHT = 136 |
395 def playCard(self, card): | 396 def playCard(self, card): |
396 self.hand.remove(card) | 397 self.hand.remove(card) |
397 self._parent.host.bridge.call('tarotGamePlayCards', None, self.player_nick, self.referee, [(card.suit, card.value)]) | 398 self._parent.host.bridge.call('tarotGamePlayCards', None, self.player_nick, self.referee, [(card.suit, card.value)]) |
398 self.state = "wait" | 399 self.state = "wait" |
399 self.updateHand() | 400 self.updateHand() |
401 | |
402 def tarotGameScore(self, xml_data, winners, loosers): | |
403 """Show score at this end of a round""" | |
404 ###XXX: we cheat here as XMLUI is not implemented yet | |
405 #TODO: usr XMLUI | |
406 if self.player_nick in winners: | |
407 title = "You <b>win</b> !" | |
408 else: | |
409 title = "You <b>loose</b> :(" | |
410 body = re.sub(r'<.*?>',lambda x:'<br />' if '/elem' in x.group(0) else '', xml_data) #Q&D conversion to simple HTML text | |
411 SimpleDialog(title, body).show() |