# HG changeset patch # User Goffi # Date 1356658054 -3600 # Node ID da6eaa2af092f416b1ad6255f552fafad286df18 # Parent 0bb2e0d1c87807b7c1868490131bca047f34432d plugin Tarot: fixed plugin diff -r 0bb2e0d1c878 -r da6eaa2af092 src/plugins/plugin_misc_tarot.py --- a/src/plugins/plugin_misc_tarot.py Fri Dec 28 01:00:31 2012 +0100 +++ b/src/plugins/plugin_misc_tarot.py Fri Dec 28 02:27:34 2012 +0100 @@ -21,10 +21,7 @@ from logging import debug, info, warning, error from twisted.words.xish import domish -from twisted.internet import protocol, defer, threads, reactor -from twisted.words.protocols.jabber import client, jid, xmlstream -from twisted.words.protocols.jabber import error as jab_error -from twisted.words.protocols.jabber.xmlstream import IQ +from twisted.words.protocols.jabber import jid import random from zope.interface import implements @@ -110,6 +107,7 @@ for card in cards_list_elt.elements(): cards_list.append((card['suit'], card['value'])) return cards_list + def __create_started_elt(self, players): """Create a game_started domish element""" @@ -425,7 +423,7 @@ self.createGame(_room_jid.userhost(), players, profile_key=profile) return True - def launchGame(self, players, profile_key='@DEFAULT@'): + def launchGame(self, players, profile_key='@NONE@'): """Launch a game: helper method to create a room, invite players, and create the tarot game @param players: list for players jid""" debug(_('Launching tarot game')) @@ -458,7 +456,7 @@ return _jid, xmlstream = self.host.getJidNStream(profile) - d = self.host.plugins["XEP-0045"].join(muc_service.userhost(), room_name, _jid.user, profile).addCallback(tarotRoomJoined) + d = self.host.plugins["XEP-0045"].join(jid.JID("%s@%s" % (room_name, muc_service.userhost())), _jid.user, {}, profile).addCallback(tarotRoomJoined) client = self.host.getClient(profile) if not client: @@ -469,7 +467,7 @@ - def createGame(self, room_jid_param, players, profile_key='@DEFAULT@'): + def createGame(self, room_jid_param, players, profile_key='@NONE@'): """Create a new game @param room_jid_param: jid of the room @param players: list of players nick (nick must exist in the room) @@ -499,7 +497,7 @@ mess.firstChildElement().addChild(self.__create_started_elt(players)) self.host.profiles[profile].xmlstream.send(mess) - def newPlayerReady(self, player, referee, profile_key='@DEFAULT@'): + def newPlayerReady(self, player, referee, profile_key='@NONE@'): """Must be called when player is ready to start a new game""" profile = self.host.memory.getProfileName(profile_key) if not profile: @@ -511,7 +509,7 @@ ready_elt['player'] = player self.host.profiles[profile].xmlstream.send(mess) - def contratChoosed(self, player, referee, contrat, profile_key='@DEFAULT@'): + def contratChoosed(self, player, referee, contrat, profile_key='@NONE@'): """Must be call by player when the contrat is selected @param player: player's name @param referee: arbiter jid @@ -528,7 +526,7 @@ contrat_elt['player'] = player self.host.profiles[profile].xmlstream.send(mess) - def play_cards(self, player, referee, cards, profile_key='@DEFAULT@'): + def play_cards(self, player, referee, cards, profile_key='@NONE@'): """Must be call by player when the contrat is selected @param player: player's name @param referee: arbiter jid @@ -762,17 +760,17 @@ form_elt = elt.elements(name='x',uri='jabber:x:data').next() winners = [] loosers = [] - for winner in elt.elements(name='winner', uri=''): + for winner in elt.elements(name='winner', uri=NS_CG): winners.append(unicode(winner)) - for looser in elt.elements(name='looser', uri=''): + for looser in elt.elements(name='looser', uri=NS_CG): loosers.append(unicode(looser)) form = data_form.Form.fromElement(form_elt) xml_data = dataForm2xml(form) self.host.bridge.tarotGameScore(room_jid.userhost(), xml_data, winners, loosers, profile) elif elt.name == 'error': if elt['type'] == 'invalid_cards': - played_cards = self.__xml_to_list(elt.elements(name='played',uri='').next()) - invalid_cards = self.__xml_to_list(elt.elements(name='invalid',uri='').next()) + played_cards = self.__xml_to_list(elt.elements(name='played',uri=NS_CG).next()) + invalid_cards = self.__xml_to_list(elt.elements(name='invalid',uri=NS_CG).next()) self.host.bridge.tarotGameInvalidCards(room_jid.userhost(), elt['phase'], played_cards, invalid_cards, profile) else: error (_('Unmanaged error type: %s') % elt['type'])