Commit | Line | Data |
---|---|---|
8ee66edd FC |
1 | from abc import ABCMeta |
2 | from lib.gameobject import LogicColleague, GameObject | |
3 | from lib.engine.engine import Engine | |
4 | ||
5 | ||
6 | class GameLogic(LogicColleague): | |
7 | ||
8 | def on_start(self): pass | |
9 | ||
10 | ||
11 | class GameFacade: | |
12 | ||
13 | def demand(self, tgt_state, *args): | |
14 | return self.fsm.demand(tgt_state, *args) | |
15 | ||
16 | ||
17 | class 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 | ||
33 | class Game(GameBase): # it adds the window | |
34 | ||
35 | def run(self): | |
36 | self.logic.on_start() | |
37 | base.run() |