comparison src/plugins/plugin_misc_tarot.py @ 630:0b914394e74f

core: added advanced list to XMLUI (need improvment, very basic so far) - the advanced list use headers which can be used as columns - in the future, should provide the ability to highly customize list disposition, in a way similar to Amarok 2's playlist.
author Goffi <goffi@goffi.org>
date Sun, 08 Sep 2013 18:05:19 +0200
parents 84a6e83157c2
children 2805fa3f4bdf
comparison
equal deleted inserted replaced
629:204930b870e1 630:0b914394e74f
23 import random 23 import random
24 24
25 from zope.interface import implements 25 from zope.interface import implements
26 26
27 from wokkel import disco, iwokkel, data_form 27 from wokkel import disco, iwokkel, data_form
28 from sat.tools.xml_tools import dataForm2xml 28 from sat.tools.xml_tools import dataForm2XML
29 from sat.tools.games import TarotCard 29 from sat.tools.games import TarotCard
30 30
31 from time import time 31 from time import time
32 32
33 try: 33 try:
598 elif elt.name == 'hand': # a new hand has been received 598 elif elt.name == 'hand': # a new hand has been received
599 self.host.bridge.tarotGameNew(room_jid.userhost(), self.__xml_to_list(elt), profile) 599 self.host.bridge.tarotGameNew(room_jid.userhost(), self.__xml_to_list(elt), profile)
600 600
601 elif elt.name == 'contrat': # it's time to choose contrat 601 elif elt.name == 'contrat': # it's time to choose contrat
602 form = data_form.Form.fromElement(elt.firstChildElement()) 602 form = data_form.Form.fromElement(elt.firstChildElement())
603 xml_data = dataForm2xml(form) 603 xml_data = dataForm2XML(form)
604 self.host.bridge.tarotGameChooseContrat(room_jid.userhost(), xml_data, profile) 604 self.host.bridge.tarotGameChooseContrat(room_jid.userhost(), xml_data, profile)
605 605
606 elif elt.name == 'contrat_choosed': 606 elif elt.name == 'contrat_choosed':
607 #TODO: check we receive the contrat from the right person 607 #TODO: check we receive the contrat from the right person
608 #TODO: use proper XEP-0004 way for answering form 608 #TODO: use proper XEP-0004 way for answering form
751 for winner in elt.elements(name='winner', uri=NS_CG): 751 for winner in elt.elements(name='winner', uri=NS_CG):
752 winners.append(unicode(winner)) 752 winners.append(unicode(winner))
753 for looser in elt.elements(name='looser', uri=NS_CG): 753 for looser in elt.elements(name='looser', uri=NS_CG):
754 loosers.append(unicode(looser)) 754 loosers.append(unicode(looser))
755 form = data_form.Form.fromElement(form_elt) 755 form = data_form.Form.fromElement(form_elt)
756 xml_data = dataForm2xml(form) 756 xml_data = dataForm2XML(form)
757 self.host.bridge.tarotGameScore(room_jid.userhost(), xml_data, winners, loosers, profile) 757 self.host.bridge.tarotGameScore(room_jid.userhost(), xml_data, winners, loosers, profile)
758 elif elt.name == 'error': 758 elif elt.name == 'error':
759 if elt['type'] == 'invalid_cards': 759 if elt['type'] == 'invalid_cards':
760 played_cards = self.__xml_to_list(elt.elements(name='played', uri=NS_CG).next()) 760 played_cards = self.__xml_to_list(elt.elements(name='played', uri=NS_CG).next())
761 invalid_cards = self.__xml_to_list(elt.elements(name='invalid', uri=NS_CG).next()) 761 invalid_cards = self.__xml_to_list(elt.elements(name='invalid', uri=NS_CG).next())