Main
Entrypoint to control the Gamecontrol
CrazyComet (Game)
Gameclass for the gamecontrol
Attributes:
Name | Type | Description |
---|---|---|
max_score |
int |
Score at which one team wins |
on_end(self)
async
Executed, when the game ends
Source code in src/main.py
async def on_end(self):
await self.tower.game_stop()
on_exit(self, err=None)
async
Executed, when the game loop is exited
Parameters:
Name | Type | Description | Default |
---|---|---|---|
err |
Exception |
Value of the exception when the game exited with none zero code |
None |
Source code in src/main.py
async def on_exit(self, err: Exception = None):
return await super().on_exit(err=err)
on_init(self)
async
Executed, when the game is startet with Game.run()
Source code in src/main.py
async def on_init(self):
self.tower = TowerControl()
await self.tower.set_start_position()
on_pregame(self)
async
Executed, before a new game starts
Source code in src/main.py
async def on_pregame(self):
self.tower.set_score(0, self.max_score * 2)
self.tower.game_run()
on_score(self)
async
Executed, when a player scores one or more points
Source code in src/main.py
async def on_score(self):
scores = self.players.score
score_A = 0
score_B = 0
for seat, score in scores.items():
if seat in self.config['team_A']:
score_A += score
elif seat in self.config['team_B']:
score_B += score
self.tower.set_score(score_A + score_B, self.max_score * 2)
if score_A >= self.max_score:
logging.info("Team A wins !!!")
await self.set_game_state(GameState.END)
elif score_B >= self.max_score:
logging.info("Team B wins !!!")
await self.set_game_state(GameState.END)