Mercurial > libervia-backend
comparison src/plugins/plugin_misc_tarot.py @ 718:074970227bc0
plugin tools: turn src/plugin/games.py into a plugin and move it to src/plugins/plugin_misc_room_game.py
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 21 Nov 2013 18:23:08 +0100 |
parents | 358018c5c398 |
children | 56aa0e98c92e |
comparison
equal
deleted
inserted
replaced
717:358018c5c398 | 718:074970227bc0 |
---|---|
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 dataForm2XML |
26 from sat.tools.frontends.games import TarotCard | 26 from sat.tools.frontends.games import TarotCard |
27 from sat.tools.plugins.games import RoomGame | |
28 from time import time | 27 from time import time |
29 import random | 28 import random |
30 | 29 |
31 | 30 |
32 NS_CG = 'http://www.goffi.org/protocol/card_game' | 31 NS_CG = 'http://www.goffi.org/protocol/card_game' |
35 PLUGIN_INFO = { | 34 PLUGIN_INFO = { |
36 "name": "Tarot cards plugin", | 35 "name": "Tarot cards plugin", |
37 "import_name": "Tarot", | 36 "import_name": "Tarot", |
38 "type": "Misc", | 37 "type": "Misc", |
39 "protocols": [], | 38 "protocols": [], |
40 "dependencies": ["XEP-0045", "XEP-0249"], | 39 "dependencies": ["XEP-0045", "XEP-0249", "ROOM-GAME"], |
41 "main": "Tarot", | 40 "main": "Tarot", |
42 "handler": "yes", | 41 "handler": "yes", |
43 "description": _("""Implementation of Tarot card game""") | 42 "description": _("""Implementation of Tarot card game""") |
44 } | 43 } |
45 | 44 |
46 | 45 |
47 class Tarot(RoomGame): | 46 class Tarot(object): |
47 | |
48 def inheritFromRoomGame(self, host): | |
49 global RoomGame | |
50 RoomGame = host.plugins["ROOM-GAME"].__class__ | |
51 self.__class__ = type(self.__class__.__name__, (self.__class__, RoomGame, object), {}) | |
48 | 52 |
49 def __init__(self, host): | 53 def __init__(self, host): |
50 info(_("Plugin Tarot initialization")) | 54 info(_("Plugin Tarot initialization")) |
51 RoomGame.__init__(self, host, PLUGIN_INFO, (NS_CG, CG_TAG), | 55 self.inheritFromRoomGame(host) |
56 RoomGame._init_(self, host, PLUGIN_INFO, (NS_CG, CG_TAG), | |
52 game_init={'hand_size': 18, 'init_player': 0, 'current_player': None, 'contrat': None, 'stage': None}, | 57 game_init={'hand_size': 18, 'init_player': 0, 'current_player': None, 'contrat': None, 'stage': None}, |
53 player_init={'score': 0}) | 58 player_init={'score': 0}) |
54 self.contrats = [_('Passe'), _('Petite'), _('Garde'), _('Garde Sans'), _('Garde Contre')] | 59 self.contrats = [_('Passe'), _('Petite'), _('Garde'), _('Garde Sans'), _('Garde Contre')] |
55 host.bridge.addMethod("tarotGameLaunch", ".plugin", in_sign='asss', out_sign='', method=self.prepareRoom) # args: players, room_jid, profile | 60 host.bridge.addMethod("tarotGameLaunch", ".plugin", in_sign='asss', out_sign='', method=self.prepareRoom) # args: players, room_jid, profile |
56 host.bridge.addMethod("tarotGameCreate", ".plugin", in_sign='sass', out_sign='', method=self.createGame) # args: room_jid, players, profile | 61 host.bridge.addMethod("tarotGameCreate", ".plugin", in_sign='sass', out_sign='', method=self.createGame) # args: room_jid, players, profile |