ya2 · news · projects · code · about

refactoring of functional tests
[pmachines.git] / lib / game.py
CommitLineData
8ee66edd
FC
1from abc import ABCMeta
2from lib.gameobject import LogicColleague, GameObject
3from lib.engine.engine import Engine
4
5
6class GameLogic(LogicColleague):
7
8 def on_start(self): pass
9
10
11class GameFacade:
12
13 def demand(self, tgt_state, *args):
14 return self.fsm.demand(tgt_state, *args)
15
16
17class GameBase(GameObject, GameFacade): # it doesn't manage the window
18 __metaclass__ = ABCMeta
19
20 def __init__(self, cfg, client_cls=None):
21 self.logic = LogicColleague(self)
22 self.eng = Engine(cfg, self.destroy, client_cls)
23 GameObject.__init__(self)
24
25 def destroy(self):
26 self.logic.destroy()
27 GameObject.destroy(self)
28 # self.eng = self.eng.destroy()
29 self.eng.server.destroy()
30 self.eng.client.destroy()
31
32
33class Game(GameBase): # it adds the window
34
35 def run(self):
36 self.logic.on_start()
37 base.run()