Esempio n. 1
0
def test_messages_get_over_game_data():
    player_a = Player(x=1, y=2, player_id=0)
    player_b = Player(x=1, y=2, player_id=1)
    player_a.score = 20
    player_b.score = 40
    game = Game()
    game.alive_players = [player_a, player_b]

    assert messages.get_over_game_data(game) == dict(
        status='game',
        action='over',
        winner=player_b.id.hex,
    )
Esempio n. 2
0
    async def step(self):
        is_ready = self.is_ready()
        is_over = self.is_over()

        if not self.was_ready and is_ready:
            self.was_ready = True
            await self.broadcast(messages.get_start_game_data())

        if is_over and not self.was_over:
            self.was_over = True
            await self.broadcast(messages.get_over_game_data(self))
            if self.turn_off_after_end:
                exit(0)  # little dangerous lol

        if is_ready and not is_over:
            await self.logic.step()
            await self.send_informations()
        if self.drawer is not None:
            self.drawer.render()