Пример #1
0
def test_solve_phalanx_possible_2():  # noqa: D103
    stack = [
        CardGenerator.troop(TroopColors.RED, 9),
        CardGenerator.troop(TroopColors.BLUE, 9),
    ]
    used_cards = [c for c in stack if isinstance(c, TroopCard)]
    strength, solved = possible_maximum_strength_for_phalanx(stack, 3, used_cards)
    assert strength == 9 * 3
    assert not solved
Пример #2
0
def test_solve_battalion_inpossible():  # noqa: D103
    stack = [
        CardGenerator.troop(TroopColors.YELLOW, 1),
        CardGenerator.troop(TroopColors.YELLOW, 9),
    ]
    used_cards = [CardGenerator.troop(TroopColors.YELLOW, n) for n in range(1, 11)]
    strength, solved = possible_maximum_strength_for_battalion(stack, 3, used_cards)
    assert strength == 0
    assert not solved
Пример #3
0
def test_solve_wedge_possible_2():  # noqa: D103
    stack = [
        CardGenerator.troop(TroopColors.RED, 3),
        CardGenerator.troop(TroopColors.RED, 4),
    ]
    used_cards = [c for c in stack if isinstance(c, TroopCard)]
    strength, solved = possible_maximum_strength_for_wedge(stack, 3, used_cards)
    assert strength == sum([3, 4, 5])
    assert not solved
Пример #4
0
def test_solve_host_possible_2():  # noqa: D103
    stack = [
        CardGenerator.troop(TroopColors.YELLOW, 1),
        CardGenerator.troop(TroopColors.GREEN, 3),
    ]
    used_cards = [c for c in stack if isinstance(c, TroopCard)]
    strength, solved = possible_maximum_strength_for_host(stack, 3, used_cards)
    assert strength == sum([1, 3, 10])
    assert not solved
Пример #5
0
def test_solve_battalion_possible_2():  # noqa: D103
    stack = [
        CardGenerator.troop(TroopColors.YELLOW, 1),
        CardGenerator.troop(TroopColors.YELLOW, 9),
    ]
    used_cards = [c for c in stack if isinstance(c, TroopCard)]
    strength, solved = possible_maximum_strength_for_battalion(stack, 3, used_cards)
    assert strength == sum([10, 9, 1])
    assert not solved
Пример #6
0
def test_solve_skirmish_inpossible():  # noqa: D103
    stack = [
        CardGenerator.troop(TroopColors.YELLOW, 1),
        CardGenerator.troop(TroopColors.GREEN, 3),
    ]
    used_cards = [c for c in stack if isinstance(c, TroopCard)]
    used_cards.extend([CardGenerator.troop(c, 2) for c in TroopColors])
    strength, solved = possible_maximum_strength_for_skirmish(stack, 3, used_cards)
    assert strength == 0
    assert not solved
Пример #7
0
def test_solve_skirmish_negative():  # noqa: D103
    stack = [
        CardGenerator.troop(TroopColors.RED, 2),
        CardGenerator.troop(TroopColors.YELLOW, 1),
        CardGenerator.troop(TroopColors.GREEN, 4),
    ]
    used_cards = [c for c in stack if isinstance(c, TroopCard)]
    strength, solved = possible_maximum_strength_for_skirmish(stack, 3, used_cards)
    assert strength == 0
    assert not solved
Пример #8
0
def test_solve_phalanx_wild():  # noqa: D103
    stack = [
        CardGenerator.troop(TroopColors.YELLOW, 9),
        CardGenerator.tactic(TacticMorales.LEADER_DARIUS),
        CardGenerator.troop(TroopColors.GREEN, 9),
    ]
    used_cards = [c for c in stack if isinstance(c, TroopCard)]
    strength, solved = possible_maximum_strength_for_phalanx(stack, 3, used_cards)
    assert strength == 9 * 3
    assert solved
Пример #9
0
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
Пример #10
0
def test_solve_wedge_shield():  # noqa: D103
    stack = [
        CardGenerator.troop(TroopColors.RED, 3),
        CardGenerator.troop(TroopColors.RED, 4),
        CardGenerator.tactic(TacticMorales.SHIELD_BEARERS),
    ]
    used_cards = [c for c in stack if isinstance(c, TroopCard)]
    strength, solved = possible_maximum_strength_for_wedge(stack, 3, used_cards)
    assert strength == sum([2, 3, 4])
    assert solved
Пример #11
0
def test_solve_wedge_wild():  # noqa: D103
    stack = [
        CardGenerator.troop(TroopColors.RED, 3),
        CardGenerator.troop(TroopColors.RED, 4),
        CardGenerator.tactic(TacticMorales.LEADER_ALEXANDER),
    ]
    used_cards = [c for c in stack if isinstance(c, TroopCard)]
    strength, solved = possible_maximum_strength_for_wedge(stack, 3, used_cards)
    assert strength == sum([3, 4, 5])
    assert solved
Пример #12
0
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
Пример #13
0
def test_solve_host_inpossible():  # noqa: D103
    stack = [
        CardGenerator.troop(TroopColors.YELLOW, 1),
        CardGenerator.troop(TroopColors.GREEN, 3),
    ]

    # used_cards = [c for c in stack if isinstance(c, TroopCard)]
    used_cards = [CardGenerator.troop(c, n) for c in TroopColors for n in range(1, 11)]
    strength, solved = possible_maximum_strength_for_host(stack, 3, used_cards)
    assert strength == 0
    assert not solved
Пример #14
0
def test_solve_wedge_inpossible():  # noqa: D103
    stack = [
        CardGenerator.troop(TroopColors.RED, 3),
        CardGenerator.troop(TroopColors.RED, 4),
    ]
    used_cards = [c for c in stack if isinstance(c, TroopCard)]
    used_cards.extend(
        [
            CardGenerator.troop(TroopColors.RED, 2),
            CardGenerator.troop(TroopColors.RED, 5),
        ]
    )
    strength, solved = possible_maximum_strength_for_wedge(stack, 3, used_cards)
    assert strength == 0
    assert not solved
Пример #15
0
def test_solve_skirmish_possible_1():  # noqa: D103
    stack = [
        CardGenerator.troop(TroopColors.YELLOW, 1),
    ]
    used_cards = [c for c in stack if isinstance(c, TroopCard)]
    strength, solved = possible_maximum_strength_for_skirmish(stack, 3, used_cards)
    assert strength == sum([1, 2, 3])
    assert not solved
Пример #16
0
def test_solve_wedge_cavalry_and_wild():  # noqa: D103
    stack = [
        CardGenerator.tactic(TacticMorales.LEADER_ALEXANDER),
        CardGenerator.tactic(TacticMorales.COMPANION_CAVALRY),
        CardGenerator.troop(TroopColors.RED, 9),
    ]
    used_cards = [c for c in stack if isinstance(c, TroopCard)]
    strength, solved = possible_maximum_strength_for_wedge(stack, 3, used_cards)
    assert strength == sum([8, 9, 10])
    assert solved
Пример #17
0
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
Пример #18
0
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
Пример #19
0
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
Пример #20
0
def test_flag_deepcopy():  # noqa
    flag = Flag()
    c_r3 = CardGenerator.troop(TroopColors.RED, 3)
    flag.add_stack(PLAYER_A, c_r3)
    c_ld = CardGenerator.tactic(Tactics.LEADER_DARIUS)
    flag.add_stack(PLAYER_B, c_ld)
Пример #21
0
def test_valid_troop_card():  # noqa
    card = CardGenerator.troop(TroopColors.RED, 3)
    assert card.get_color() == TroopColors.RED
    assert card.get_played_type() == PlayedCardType.TROOP_AND_MORALE_TACTICS
    assert card.get_troop() == 3
Пример #22
0
def test_flag_stack_troop():  # noqa
    flag = Flag()
    c_r3 = CardGenerator.troop(TroopColors.RED, 3)
    flag.add_stack(PLAYER_A, c_r3)
    assert len(flag.get_stacked_cards(PLAYER_A)) == 1
    assert flag.remove_stack_troops(PLAYER_A, TroopColors.RED, 3) == c_r3