diff libervia.py @ 36:1d406077b49b

Tarot Game: first draft
author Goffi <goffi@goffi.org>
date Tue, 17 May 2011 01:33:12 +0200
parents d43d6e4b9dc8
children b306aa090438
line wrap: on
line diff
--- a/libervia.py	Mon May 16 18:19:35 2011 +0200
+++ b/libervia.py	Tue May 17 01:33:12 2011 +0200
@@ -66,7 +66,7 @@
     def __init__(self):
         LiberviaJsonProxy.__init__(self, "/json_api",
                         ["getContacts", "sendMessage", "sendMblog", "getMblogNodes", "getProfileJid", "getHistory",
-                         "getPresenceStatus", "getRoomJoined", "launchTarotGame"])
+                         "getPresenceStatus", "getRoomJoined", "launchTarotGame", "getTarotCardsPaths"])
 
 class BridgeSignals(LiberviaJsonProxy):
     def __init__(self):
@@ -167,6 +167,8 @@
             self._roomUserJoinedCb(*args)
         elif name == 'roomUserLeft':
             self._roomUserLeftCb(*args)
+        elif name == 'tarotGameStarted':
+            self._tarotGameStartedCb(*args)
 
     def _getProfileJidCB(self, jid):
         self.whoami = JID(jid)
@@ -189,7 +191,7 @@
             else:
                 _groups=None
             for panel in self.mpanels:
-                if isinstance(panel,MicroblogPanel) and (panel.isJidAccepted(sender) or _groups == None or _groups.intersection(panel.accepted_groups)):
+                if isinstance(panel,MicroblogPanel) and (panel.isJidAccepted(sender) or _groups == None or _groups.intersection(panel.accepted_groups)): #TODO: check this
                     content = data['content']
                     author = data.get('author')
                     timestamp = float(data.get('timestamp',0)) #XXX: int doesn't work here
@@ -231,7 +233,13 @@
         for panel in self.mpanels + self.other_panels:
             if isinstance(panel,ChatPanel) and panel.type == 'group' and panel.target.bare == "%s@%s" % (room_id, room_service):
                 panel.userLeft(user_nick, user_data)
-            
+        
+    def _tarotGameStartedCb(self, room_jid, referee, players):
+        print ("Tarot Game Started \o/")
+        for panel in self.mpanels + self.other_panels:
+            if isinstance(panel,ChatPanel) and panel.type == 'group' and panel.target.bare == room_jid:
+                panel.startGame("Tarot", referee, players)
+
     def _getPresenceStatusCB(self, presence_data):
         for entity in presence_data:
             for resource in presence_data[entity]: