def test_1_repeated_win(): def round_runner(g): game_round = start_round_from_player_cards( [cards.Guard(), cards.Baron()], [cards.King(), cards.Princess()], first_player=0, ) object.__setattr__(g.state, "round", game_round) # work around frozen dataclass player0, player1 = game_round.players play_with_choices(player0, CardType.GUARD, player1, cards.Princess) play_random_move(player1) end = game_round.state assert end.type == RoundState.Type.ROUND_END assert end.winner is player0 game = Game(["Alice", "Bob"]) alice, bob = game.players game.start() for i in range(1, 8): assert game.state.round_no == i round_runner(game) game.advance() assert +game.points == {alice: i} assert game.ended assert game.state.winner is alice
def test_start_newGame_setsCorrectGameState(new_game: Game): new_game.start() assert new_game.started assert not new_game.ended assert new_game.state.type == GameState.Type.ROUND # noinspection PyTypeChecker state: loveletter.game.PlayingRound = new_game.state assert state.round_no == 1 assert state.first_player is None assert new_game.current_round is state.round game_round = new_game.current_round assert isinstance(game_round, Round) assert not game_round.started assert game_round.num_players == new_game.num_players
def started_game(new_game: Game) -> Game: new_game.start() return new_game