comparison src/plugins/plugin_misc_tarot.py @ 761:2f8d72226bc0

core (xml_tools): dataForm*2XML renamed to dataForm*2XMLUI and now return XMLUI instead of raw XML + submit_id is managed, and session_id is returned if present
author Goffi <goffi@goffi.org>
date Tue, 24 Dec 2013 15:43:22 +0100
parents 56aa0e98c92e
children bfabeedbf32e
comparison
equal deleted inserted replaced
760:73a0077f80cc 761:2f8d72226bc0
20 from logging import debug, info, warning, error 20 from logging import debug, info, warning, error
21 from twisted.words.xish import domish 21 from twisted.words.xish import domish
22 from twisted.words.protocols.jabber import jid 22 from twisted.words.protocols.jabber import jid
23 from wokkel import data_form 23 from wokkel import data_form
24 24
25 from sat.tools.xml_tools import dataForm2XML 25 from sat.tools.xml_tools import dataForm2XMLUI
26 from sat_frontends.tools.games import TarotCard 26 from sat_frontends.tools.games import TarotCard
27 from time import time 27 from time import time
28 import random 28 import random
29 29
30 30
472 elif elt.name == 'hand': # a new hand has been received 472 elif elt.name == 'hand': # a new hand has been received
473 self.host.bridge.tarotGameNew(room_jid.userhost(), self.__xml_to_list(elt), profile) 473 self.host.bridge.tarotGameNew(room_jid.userhost(), self.__xml_to_list(elt), profile)
474 474
475 elif elt.name == 'contrat': # it's time to choose contrat 475 elif elt.name == 'contrat': # it's time to choose contrat
476 form = data_form.Form.fromElement(elt.firstChildElement()) 476 form = data_form.Form.fromElement(elt.firstChildElement())
477 xml_data = dataForm2XML(form) 477 xml_data = dataForm2XMLUI(form, "").toXml()
478 self.host.bridge.tarotGameChooseContrat(room_jid.userhost(), xml_data, profile) 478 self.host.bridge.tarotGameChooseContrat(room_jid.userhost(), xml_data, profile)
479 479
480 elif elt.name == 'contrat_choosed': 480 elif elt.name == 'contrat_choosed':
481 #TODO: check we receive the contrat from the right person 481 #TODO: check we receive the contrat from the right person
482 #TODO: use proper XEP-0004 way for answering form 482 #TODO: use proper XEP-0004 way for answering form
611 for winner in elt.elements(name='winner', uri=NS_CG): 611 for winner in elt.elements(name='winner', uri=NS_CG):
612 winners.append(unicode(winner)) 612 winners.append(unicode(winner))
613 for looser in elt.elements(name='looser', uri=NS_CG): 613 for looser in elt.elements(name='looser', uri=NS_CG):
614 loosers.append(unicode(looser)) 614 loosers.append(unicode(looser))
615 form = data_form.Form.fromElement(form_elt) 615 form = data_form.Form.fromElement(form_elt)
616 xml_data = dataForm2XML(form) 616 xml_data = dataForm2XMLUI(form, "").toXml()
617 self.host.bridge.tarotGameScore(room_jid.userhost(), xml_data, winners, loosers, profile) 617 self.host.bridge.tarotGameScore(room_jid.userhost(), xml_data, winners, loosers, profile)
618 elif elt.name == 'error': 618 elif elt.name == 'error':
619 if elt['type'] == 'invalid_cards': 619 if elt['type'] == 'invalid_cards':
620 played_cards = self.__xml_to_list(elt.elements(name='played', uri=NS_CG).next()) 620 played_cards = self.__xml_to_list(elt.elements(name='played', uri=NS_CG).next())
621 invalid_cards = self.__xml_to_list(elt.elements(name='invalid', uri=NS_CG).next()) 621 invalid_cards = self.__xml_to_list(elt.elements(name='invalid', uri=NS_CG).next())