Mercurial > libervia-web
comparison libervia.py @ 37:b306aa090438
Tarot game: game launching (first hand showed), and contract selection
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 18 May 2011 01:45:28 +0200 |
parents | 1d406077b49b |
children | 7bea2ae0c4fb |
comparison
equal
deleted
inserted
replaced
36:1d406077b49b | 37:b306aa090438 |
---|---|
64 | 64 |
65 class BridgeCall(LiberviaJsonProxy): | 65 class BridgeCall(LiberviaJsonProxy): |
66 def __init__(self): | 66 def __init__(self): |
67 LiberviaJsonProxy.__init__(self, "/json_api", | 67 LiberviaJsonProxy.__init__(self, "/json_api", |
68 ["getContacts", "sendMessage", "sendMblog", "getMblogNodes", "getProfileJid", "getHistory", | 68 ["getContacts", "sendMessage", "sendMblog", "getMblogNodes", "getProfileJid", "getHistory", |
69 "getPresenceStatus", "getRoomJoined", "launchTarotGame", "getTarotCardsPaths"]) | 69 "getPresenceStatus", "getRoomJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed"]) |
70 | 70 |
71 class BridgeSignals(LiberviaJsonProxy): | 71 class BridgeSignals(LiberviaJsonProxy): |
72 def __init__(self): | 72 def __init__(self): |
73 LiberviaJsonProxy.__init__(self, "/json_signal_api", | 73 LiberviaJsonProxy.__init__(self, "/json_signal_api", |
74 ["getSignals"]) | 74 ["getSignals"]) |
167 self._roomUserJoinedCb(*args) | 167 self._roomUserJoinedCb(*args) |
168 elif name == 'roomUserLeft': | 168 elif name == 'roomUserLeft': |
169 self._roomUserLeftCb(*args) | 169 self._roomUserLeftCb(*args) |
170 elif name == 'tarotGameStarted': | 170 elif name == 'tarotGameStarted': |
171 self._tarotGameStartedCb(*args) | 171 self._tarotGameStartedCb(*args) |
172 elif name == 'tarotGameNew' or \ | |
173 name == 'tarotGameChooseContrat': | |
174 self._tarotGameGenericCb(name, args[0], args[1:]) | |
172 | 175 |
173 def _getProfileJidCB(self, jid): | 176 def _getProfileJidCB(self, jid): |
174 self.whoami = JID(jid) | 177 self.whoami = JID(jid) |
175 #we can now ask our status | 178 #we can now ask our status |
176 self.bridge.call('getPresenceStatus', self._getPresenceStatusCB) | 179 self.bridge.call('getPresenceStatus', self._getPresenceStatusCB) |
177 #and the rooms where we are | 180 #and the rooms where we are |
178 self.bridge.call('getRoomJoined', self._getRoomJoinedCB) | 181 self.bridge.call('getRoomJoined', self._getRoomJoinedCB) |
179 | |
180 | |
181 | 182 |
182 ## Signals callbacks ## | 183 ## Signals callbacks ## |
183 | 184 |
184 def _personalEventCb(self, sender, event_type, data, profile): | 185 def _personalEventCb(self, sender, event_type, data, profile): |
185 if event_type == "MICROBLOG": | 186 if event_type == "MICROBLOG": |
238 print ("Tarot Game Started \o/") | 239 print ("Tarot Game Started \o/") |
239 for panel in self.mpanels + self.other_panels: | 240 for panel in self.mpanels + self.other_panels: |
240 if isinstance(panel,ChatPanel) and panel.type == 'group' and panel.target.bare == room_jid: | 241 if isinstance(panel,ChatPanel) and panel.type == 'group' and panel.target.bare == room_jid: |
241 panel.startGame("Tarot", referee, players) | 242 panel.startGame("Tarot", referee, players) |
242 | 243 |
244 def _tarotGameGenericCb(self, event_name, room_jid, args): | |
245 for panel in self.mpanels + self.other_panels: | |
246 if isinstance(panel,ChatPanel) and panel.type == 'group' and panel.target.bare == room_jid: | |
247 getattr(panel.getGame("Tarot"), event_name)(*args) | |
248 | |
243 def _getPresenceStatusCB(self, presence_data): | 249 def _getPresenceStatusCB(self, presence_data): |
244 for entity in presence_data: | 250 for entity in presence_data: |
245 for resource in presence_data[entity]: | 251 for resource in presence_data[entity]: |
246 args = presence_data[entity][resource] | 252 args = presence_data[entity][resource] |
247 self._presenceUpdateCb("%s/%s" % (entity, resource), *args) | 253 self._presenceUpdateCb("%s/%s" % (entity, resource), *args) |