comparison src/plugins/plugin_misc_quiz.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
26 import random 26 import random
27 27
28 from wokkel import data_form 28 from wokkel import data_form
29 from sat.tools.xml_tools import dataForm2XML 29 from sat.tools.xml_tools import dataForm2XML
30 from sat.tools.frontends.games import TarotCard 30 from sat.tools.frontends.games import TarotCard
31 from sat.tools.plugins.games import RoomGame
32 from time import time 31 from time import time
33 32
34 33
35 NS_QG = 'http://www.goffi.org/protocol/quiz' 34 NS_QG = 'http://www.goffi.org/protocol/quiz'
36 QG_TAG = 'quiz' 35 QG_TAG = 'quiz'
38 PLUGIN_INFO = { 37 PLUGIN_INFO = {
39 "name": "Quiz game plugin", 38 "name": "Quiz game plugin",
40 "import_name": "Quiz", 39 "import_name": "Quiz",
41 "type": "Game", 40 "type": "Game",
42 "protocols": [], 41 "protocols": [],
43 "dependencies": ["XEP-0045", "XEP-0249"], 42 "dependencies": ["XEP-0045", "XEP-0249", "ROOM-GAME"],
44 "main": "Quiz", 43 "main": "Quiz",
45 "handler": "yes", 44 "handler": "yes",
46 "description": _("""Implementation of Quiz game""") 45 "description": _("""Implementation of Quiz game""")
47 } 46 }
48 47
49 48
50 class Quiz(RoomGame): 49 class Quiz(object):
50
51 def inheritFromRoomGame(self, host):
52 global RoomGame
53 RoomGame = host.plugins["ROOM-GAME"].__class__
54 self.__class__ = type(self.__class__.__name__, (self.__class__, RoomGame, object), {})
51 55
52 def __init__(self, host): 56 def __init__(self, host):
53 info(_("Plugin Quiz initialization")) 57 info(_("Plugin Quiz initialization"))
54 RoomGame.__init__(self, host, PLUGIN_INFO, (NS_QG, QG_TAG), game_init={'stage': None}, player_init={'score': 0}) 58 self.inheritFromRoomGame(host)
59 RoomGame._init_(self, host, PLUGIN_INFO, (NS_QG, QG_TAG), game_init={'stage': None}, player_init={'score': 0})
55 host.bridge.addMethod("quizGameLaunch", ".plugin", in_sign='asss', out_sign='', method=self.prepareRoom) # args: players, room_jid, profile 60 host.bridge.addMethod("quizGameLaunch", ".plugin", in_sign='asss', out_sign='', method=self.prepareRoom) # args: players, room_jid, profile
56 host.bridge.addMethod("quizGameCreate", ".plugin", in_sign='sass', out_sign='', method=self.createGame) # args: room_jid, players, profile 61 host.bridge.addMethod("quizGameCreate", ".plugin", in_sign='sass', out_sign='', method=self.createGame) # args: room_jid, players, profile
57 host.bridge.addMethod("quizGameReady", ".plugin", in_sign='sss', out_sign='', method=self.playerReady) # args: player, referee, profile 62 host.bridge.addMethod("quizGameReady", ".plugin", in_sign='sss', out_sign='', method=self.playerReady) # args: player, referee, profile
58 host.bridge.addMethod("quizGameAnswer", ".plugin", in_sign='ssss', out_sign='', method=self.playerAnswer) 63 host.bridge.addMethod("quizGameAnswer", ".plugin", in_sign='ssss', out_sign='', method=self.playerAnswer)
59 host.bridge.addSignal("quizGameStarted", ".plugin", signature='ssass') # args: room_jid, referee, players, profile 64 host.bridge.addSignal("quizGameStarted", ".plugin", signature='ssass') # args: room_jid, referee, players, profile