def vshuman_main(arg: List[str]) -> None: game = Game(GameState.new(), (HumanPlayer(PLAYER_A), HumanPlayer(PLAYER_B))) while game.run() == PLAYER_UNRESOLVED: pass print(f"Player {game.run() + 1} win!") print(repr(game.get_state()))
def test_solve_failed_wedge_but_battalion_vs_battalion(): # noqa: D103 state = GameState.new() flag: Flag = state.get_flags()[0] flag.add_stack(PLAYER_A, CardGenerator.troop(TroopColors.RED, 3)) flag.add_stack(PLAYER_A, CardGenerator.troop(TroopColors.RED, 4)) flag.add_stack(PLAYER_A, CardGenerator.troop(TroopColors.RED, 7)) flag.add_stack(PLAYER_B, CardGenerator.troop(TroopColors.BLUE, 1)) flag.add_stack(PLAYER_B, CardGenerator.troop(TroopColors.BLUE, 3)) flag.add_stack(PLAYER_B, CardGenerator.troop(TroopColors.BLUE, 6)) assert _check_resolve(flag, state) == PLAYER_A
def test_solve_wild_wedge_vs_phalanx(): # noqa: D103 state = GameState.new() flag: Flag = state.get_flags()[0] flag.add_stack(PLAYER_A, CardGenerator.troop(TroopColors.RED, 3)) flag.add_stack(PLAYER_A, CardGenerator.troop(TroopColors.RED, 4)) flag.add_stack(PLAYER_A, CardGenerator.tactic(TacticMorales.LEADER_ALEXANDER)) flag.add_stack(PLAYER_B, CardGenerator.troop(TroopColors.BLUE, 8)) flag.add_stack(PLAYER_B, CardGenerator.troop(TroopColors.GREEN, 8)) flag.add_stack(PLAYER_B, CardGenerator.troop(TroopColors.YELLOW, 8)) assert _check_resolve(flag, state) == PLAYER_A
def test_solve_same_wedge_reversed(): # noqa: D103 state = GameState.new() flag: Flag = state.get_flags()[0] flag.add_stack(PLAYER_B, CardGenerator.troop(TroopColors.BLUE, 2)) flag.add_stack(PLAYER_B, CardGenerator.troop(TroopColors.BLUE, 3)) flag.add_stack(PLAYER_B, CardGenerator.troop(TroopColors.BLUE, 4)) flag.add_stack(PLAYER_A, CardGenerator.troop(TroopColors.RED, 3)) flag.add_stack(PLAYER_A, CardGenerator.troop(TroopColors.RED, 4)) flag.add_stack(PLAYER_A, CardGenerator.troop(TroopColors.RED, 2)) assert _check_resolve(flag, state) == PLAYER_B
def test_solve_superwild_wedge_vs_wedge(): # noqa: D103 state = GameState.new() flag: Flag = state.get_flags()[0] flag.add_stack(PLAYER_A, CardGenerator.troop(TroopColors.RED, 9)) flag.add_stack(PLAYER_A, CardGenerator.tactic(TacticMorales.COMPANION_CAVALRY)) flag.add_stack(PLAYER_A, CardGenerator.tactic(TacticMorales.LEADER_ALEXANDER)) flag.add_stack(PLAYER_B, CardGenerator.troop(TroopColors.BLUE, 2)) flag.add_stack(PLAYER_B, CardGenerator.troop(TroopColors.BLUE, 3)) flag.add_stack(PLAYER_B, CardGenerator.troop(TroopColors.BLUE, 4)) assert _check_resolve(flag, state) == PLAYER_A
def test_resolve_unresolvable(): # noqa: D103 state = GameState.new() flag: Flag = state.get_flags()[0] assert _check_resolve(flag, state) == PLAYER_UNRESOLVED flag.add_stack(PLAYER_A, CardGenerator.troop(TroopColors.RED, 3)) assert flag.get_last_stacked_player() == PLAYER_A assert len(flag.get_stacked_cards(PLAYER_A)) == 1 assert len(flag.get_stacked_cards(PLAYER_B)) == 0 assert _check_resolve(flag, state) == PLAYER_UNRESOLVED flag.add_stack(PLAYER_A, CardGenerator.troop(TroopColors.RED, 4)) assert flag.get_last_stacked_player() == PLAYER_A assert len(flag.get_stacked_cards(PLAYER_A)) == 2 assert len(flag.get_stacked_cards(PLAYER_B)) == 0 assert _check_resolve(flag, state) == PLAYER_UNRESOLVED flag.add_stack(PLAYER_A, CardGenerator.troop(TroopColors.RED, 5)) assert flag.get_last_stacked_player() == PLAYER_A assert len(flag.get_stacked_cards(PLAYER_A)) == 3 assert len(flag.get_stacked_cards(PLAYER_B)) == 0 assert _check_resolve(flag, state) == PLAYER_UNRESOLVED flag.add_stack(PLAYER_B, CardGenerator.troop(TroopColors.BLUE, 4)) assert flag.get_last_stacked_player() == PLAYER_B assert len(flag.get_stacked_cards(PLAYER_A)) == 3 assert len(flag.get_stacked_cards(PLAYER_B)) == 1 assert _check_resolve(flag, state) == PLAYER_UNRESOLVED flag.add_stack(PLAYER_B, CardGenerator.troop(TroopColors.BLUE, 5)) assert flag.get_last_stacked_player() == PLAYER_B assert len(flag.get_stacked_cards(PLAYER_A)) == 3 assert len(flag.get_stacked_cards(PLAYER_B)) == 2 assert _check_resolve(flag, state) == PLAYER_UNRESOLVED flag.remove_stack_troops(PLAYER_A, TroopColors.RED, 3) assert flag.get_last_stacked_player() == PLAYER_B assert len(flag.get_stacked_cards(PLAYER_A)) == 2 assert len(flag.get_stacked_cards(PLAYER_B)) == 2 assert _check_resolve(flag, state) == PLAYER_UNRESOLVED flag.add_stack(PLAYER_B, CardGenerator.troop(TroopColors.BLUE, 6)) assert flag.get_last_stacked_player() == PLAYER_B assert len(flag.get_stacked_cards(PLAYER_A)) == 2 assert len(flag.get_stacked_cards(PLAYER_B)) == 3 assert _check_resolve(flag, state) == PLAYER_UNRESOLVED