diff 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
line wrap: on
line diff
--- a/src/plugins/plugin_misc_quiz.py	Thu Nov 21 15:49:53 2013 +0100
+++ b/src/plugins/plugin_misc_quiz.py	Thu Nov 21 18:23:08 2013 +0100
@@ -28,7 +28,6 @@
 from wokkel import data_form
 from sat.tools.xml_tools import dataForm2XML
 from sat.tools.frontends.games import TarotCard
-from sat.tools.plugins.games import RoomGame
 from time import time
 
 
@@ -40,18 +39,24 @@
     "import_name": "Quiz",
     "type": "Game",
     "protocols": [],
-    "dependencies": ["XEP-0045", "XEP-0249"],
+    "dependencies": ["XEP-0045", "XEP-0249", "ROOM-GAME"],
     "main": "Quiz",
     "handler": "yes",
     "description": _("""Implementation of Quiz game""")
 }
 
 
-class Quiz(RoomGame):
+class Quiz(object):
+
+    def inheritFromRoomGame(self, host):
+        global RoomGame
+        RoomGame = host.plugins["ROOM-GAME"].__class__
+        self.__class__ = type(self.__class__.__name__, (self.__class__, RoomGame, object), {})
 
     def __init__(self, host):
         info(_("Plugin Quiz initialization"))
-        RoomGame.__init__(self, host, PLUGIN_INFO, (NS_QG, QG_TAG), game_init={'stage': None}, player_init={'score': 0})
+        self.inheritFromRoomGame(host)
+        RoomGame._init_(self, host, PLUGIN_INFO, (NS_QG, QG_TAG), game_init={'stage': None}, player_init={'score': 0})
         host.bridge.addMethod("quizGameLaunch", ".plugin", in_sign='asss', out_sign='', method=self.prepareRoom)  # args: players, room_jid, profile
         host.bridge.addMethod("quizGameCreate", ".plugin", in_sign='sass', out_sign='', method=self.createGame)  # args: room_jid, players, profile
         host.bridge.addMethod("quizGameReady", ".plugin", in_sign='sss', out_sign='', method=self.playerReady)  # args: player, referee, profile