diff 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
line wrap: on
line diff
--- a/browser_side/card_game.py	Sun May 22 00:17:47 2011 +0200
+++ b/browser_side/card_game.py	Sun May 22 17:56:59 2011 +0200
@@ -39,11 +39,12 @@
 from pyjamas.dnd import makeDraggable
 from pyjamas.ui.DragWidget import DragWidget, DragContainer
 from jid import JID
-from dialog import ConfirmDialog
+from dialog import ConfirmDialog, SimpleDialog
 from tools import html_sanitize
 from datetime import datetime
 from time import time
 from games import TarotCard
+import re
 
 
 
@@ -397,3 +398,14 @@
         self._parent.host.bridge.call('tarotGamePlayCards', None, self.player_nick, self.referee, [(card.suit, card.value)])
         self.state = "wait"
         self.updateHand()
+
+    def tarotGameScore(self, xml_data, winners, loosers):
+        """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 <b>win</b> !"
+        else:
+            title = "You <b>loose</b> :("
+        body = re.sub(r'<.*?>',lambda x:'<br />' if '/elem' in x.group(0) else '', xml_data) #Q&D conversion to simple HTML text
+        SimpleDialog(title, body).show()