Tarot: bidding phase

- quick_app: command line is now parsed, "profile" option allow to select it
- xml_tools: list-single is now managed
- plugin tarot: method and signal to manage contract (contrat): tarotChooseContrat & tarotGameContratChoosed
- wix: Q&D Form hack to manage more generic form (not only registration), used to show contract selection form
This commit is contained in:
Goffi 2010-05-27 19:26:19 +09:30
commit 2f2a611ba3

View file

@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
from logging import debug, info, error
from tools.jid import JID
from sat_bridge_frontend.DBus import DBusBridgeFrontend
from optparse import OptionParser
import pdb
import gettext
@ -34,6 +35,7 @@ class QuickApp():
self.rosterList = {}
self.profiles = {}
self.single_profile = single_profile
self.check_options()
## bridge ##
self.bridge=DBusBridgeFrontend()
@ -48,6 +50,7 @@ class QuickApp():
self.bridge.register("roomNewSubject", self.roomNewSubject)
self.bridge.register("tarotGameStarted", self.tarotGameStarted)
self.bridge.register("tarotGameNew", self.tarotGameNew)
self.bridge.register("tarotChooseContrat", self.tarotChooseContrat)
self.bridge.register("subscribe", self.subscribe)
self.bridge.register("paramUpdate", self.paramUpdate)
self.bridge.register("contactDeleted", self.contactDeleted)
@ -63,6 +66,20 @@ class QuickApp():
"""Tell if the profile is currently followed by the application"""
return profile in self.profiles.keys()
def check_options(self):
"""Check command line options"""
usage=_("""
%prog [options]
%prog --help for options list
""")
parser = OptionParser(usage=usage)
parser.add_option("-p", "--profile", help=_("Select the profile to use"))
(self.options, args) = parser.parse_args()
return args
def plug_profile(self, profile_key='@DEFAULT@'):
"""Tell application which profile must be used"""
if self.single_profile and self.profiles:
@ -134,6 +151,8 @@ class QuickApp():
return
debug(_("Connected"))
self.setStatusOnline(True)
self.bridge.joinMUC('conference.necton2.int', 'test', self.profiles[self.profile]['whoami'].node, self.profile) #gof:
def disconnected(self, profile):
"""called when the connection is closed"""
@ -262,9 +281,16 @@ class QuickApp():
debug (_("New Tarot Game"))
print "room: %s, hand: %s" % (room_jid,hand)
if self.chat_wins.has_key(room_jid):
print "gof:",self.chat_wins[room_jid].getGame("Tarot")
self.chat_wins[room_jid].getGame("Tarot").newGame(hand)
def tarotChooseContrat(self, room_jid, xml_data, profile):
"""Called when the player has too select his contrat"""
if not self.__check_profile(profile):
return
debug (_("Tarot: need to select a contrat"))
if self.chat_wins.has_key(room_jid):
self.chat_wins[room_jid].getGame("Tarot").chooseContrat(xml_data)
def subscribe(self, type, raw_jid, profile):