示例#1
0
def test_deathwing(initialized_game):
    initialized_game.player_board[0] = PlayerBoard(0, HeroType.DEATHWING, 1, 1,
                                                   [HarvestGolem()])
    initialized_game.player_board[1] = PlayerBoard(0,
                                                   None,
                                                   1,
                                                   1, [PunchingBag(attack=10)],
                                                   enemy_is_deathwing=True)

    initialized_game.start_of_game()
    initialized_game.single_round()
    assert initialized_game.player_board[0].minions[0].attack == 4

    initialized_game.player_board[0] = PlayerBoard(0,
                                                   HeroType.DEATHWING,
                                                   1,
                                                   1, [HarvestGolem()],
                                                   enemy_is_deathwing=True)
    initialized_game.player_board[1] = PlayerBoard(0,
                                                   HeroType.DEATHWING,
                                                   1,
                                                   1, [PunchingBag(attack=10)],
                                                   enemy_is_deathwing=True)
    initialized_game.start_of_game()
    initialized_game.single_round()
    assert initialized_game.player_board[0].minions[0].attack == 6
示例#2
0
def test_minion_deathrattle_return_attack(initialized_game):
    # if a minion with deathrattle (or reborn) attacks and survives and on the next opposing attack
    # it is attacked and killed, its left most deathrattle minion (or its reborn self) should be next in the attack order
    attacker_board = initialized_game.player_board[0]
    defender_board = initialized_game.player_board[1]

    # TEST DEATHRATTLE
    attacker_board.set_minions([HarvestGolem(taunt=True), Imp()])
    defender_board.set_minions([Sellemental(), Sellemental(), Sellemental()])

    initialized_game.start_of_game(0)
    # Golem Attacks
    initialized_game.single_round()
    # Golem is attacked and killed
    initialized_game.single_round()
    attacker = attacker_board.select_attacking_minion()
    assert (attacker.name == "Damaged Golem")

    # TEST REBORN
    attacker_board.set_minions([BronzeWarden(taunt=True), HarvestGolem()])
    defender_board.set_minions([Sellemental(), Sellemental(), Sellemental()])

    initialized_game.start_of_game(0)
    # Dragon Attacks
    initialized_game.single_round()
    # Dragon is attacked and killed
    initialized_game.single_round()
    # Reborn dragon should still be the next attacker
    attacker = attacker_board.select_attacking_minion()
    assert (attacker.reborn_triggered)
    assert (attacker.name == "Bronze Warden")

    # TEST DEATHRATTLE AND REBORN
    punching_bag = PunchingBag()
    attacker_board.set_minions([
        MicroMummy(taunt=True, deathrattles=[ReplicatingMenaceDeathrattle()]),
        HarvestGolem()
    ])
    defender_board.set_minions([punching_bag])
    initialized_game.start_of_game(0)

    # Mummy Attacks
    initialized_game.single_round()
    # Punching bag kills mummy
    punching_bag.attack = 99
    initialized_game.single_round()
    # Mummy dies, microbots spawn first, then mummy is reborn, bots should attack first
    attacker = attacker_board.select_attacking_minion()

    assert (attacker.name == "Microbot")
    assert (attacker_board.minions[3].name == "Micro Mummy")
    assert (attacker_board.minions[3].reborn_triggered)
示例#3
0
def test_greybough(initialized_game):
    initialized_game.player_board[0] = PlayerBoard(0, HeroType.GREYBOUGH, 1, 1,
                                                   [HarvestGolem()])
    initialized_game.player_board[1] = PlayerBoard(0, None, 1, 1,
                                                   [PunchingBag(attack=10)])

    initialized_game.start_of_game()
    initialized_game.single_round()
    golem_token = initialized_game.player_board[0].minions[0]

    assert golem_token.attack == 3
    assert golem_token.health == 3
    assert golem_token.taunt
示例#4
0
def test_minion_insertion(initialized_game):
    # Test that a newly inserted minion attacks in order correctly
    attacker_board = initialized_game.player_board[0]
    defender_board = initialized_game.player_board[1]

    attacker_board.set_minions(
        [HarvestGolem(), PunchingBag(attack=1),
         WrathWeaver()])
    defender_board.set_minions([PunchingBag(attack=99)])

    initialized_game.start_of_game()
    initialized_game.single_round()

    # If a minion attacks, dies, and creates one or more minions, they should be next in the attack order
    minion = attacker_board.search_for_valid_attacker()
    assert (minion.name == "Damaged Golem")
示例#5
0
def test_illidan_stormrage(initialized_game):
    initialized_game.player_board[0] = PlayerBoard(0,
                                                   HeroType.ILLIDAN_STORMRAGE,
                                                   1, 1, [AcolyteOfCThun()])
    initialized_game.player_board[1] = PlayerBoard(
        0, None, 1, 1,
        [HarvestGolem(), PunchingBag(taunt=True)])
    attacker_board = initialized_game.player_board[0]
    defender_board = initialized_game.player_board[1]

    # NOTE: Illidan player bonus attacks trigger before combat, even though opponent has more minons
    initialized_game.start_of_game()
    acolyte = attacker_board.minions[0]
    punching_bag = defender_board.minions[1]
    assert acolyte.attack == 4
    assert punching_bag.health == 96

    # Deathrattles and pirate attacks should resolve
    punching_bag = PunchingBag(attack=1)
    attacker_board.set_minions([Scallywag(), Alleycat()])
    defender_board.set_minions([punching_bag])
    initialized_game.start_of_game()
    assert punching_bag.health == 92

    # Test windfury and attack order
    scallywag = Scallywag()
    punching_bag = PunchingBag()
    attacker_board.set_minions([scallywag, CracklingCyclone()])
    defender_board.set_minions([punching_bag])
    initialized_game.start_of_game()
    assert punching_bag.health == 84
    first_attacker = attacker_board.select_attacking_minion()
    assert first_attacker == scallywag

    # Single minion only attacks once
    single_minion = PunchingBag()
    attacker_board.set_minions([single_minion])
    defender_board.set_minions([PunchingBag()])
    initialized_game.start_of_game()
    assert single_minion.attack == 2
def test_reborn_mechanic(initialized_game):
    attacker_board = initialized_game.player_board[0]
    defender_board = initialized_game.player_board[1]

    # Deathrattle + reborn order
    reborn_bomb = KaboomBot(reborn=True)
    attacker_board.set_minions([reborn_bomb])
    defender_board.set_minions([KaboomBot()])
    initialized_game.start_of_game()
    initialized_game.single_round()
    assert len(attacker_board.minions) == 1
    assert reborn_bomb.health == 1 and reborn_bomb.reborn_triggered

    # Reborn with golden minions
    gold_acolyte = AcolyteOfCThun(reborn=True, golden=True)
    attacker_board.set_minions([gold_acolyte])
    defender_board.set_minions([PunchingBag(attack=10)])
    assert gold_acolyte.attack == 4
    assert gold_acolyte.health == 4
    initialized_game.start_of_game()
    initialized_game.single_round()
    assert gold_acolyte.attack == 4
    assert gold_acolyte.health == 1

    # Deathrattle + reborn when not enough space for reborn
    attacker_board.set_minions([
        PunchingBag(),
        PunchingBag(),
        PunchingBag(),
        PunchingBag(),
        PunchingBag(),
        PunchingBag(),
        HarvestGolem(reborn=True, taunt=True)
    ])
    defender_board.set_minions([PunchingBag(attack=10)])
    initialized_game.start_of_game(1)
    initialized_game.single_round()
    assert attacker_board.minions[6].name == "Damaged Golem"
示例#7
0
def test_tonytwotusk(initialized_game):
    non_golden_pirate = DreadAdmiralEliza()
    bag = PunchingBag(attack=10)
    initialized_game.player_board[0] = PlayerBoard(
        0, HeroType.GREYBOUGH, 1, 1, [
            ReplicatingMenace(),
            HarvestGolem(), non_golden_pirate,
            TonyTwoTusk()
        ])
    attacker_board = initialized_game.player_board[0]
    defender_board = initialized_game.player_board[1]

    defender_board.set_minions([bag])
    initialized_game.start_of_game()
    for _ in range(5):
        initialized_game.single_round()
    assert non_golden_pirate.golden
    assert non_golden_pirate.health == non_golden_pirate.base_health * 2

    initialized_game.single_round()
    initialized_game.single_round()
    assert non_golden_pirate.attack == 16
    assert non_golden_pirate.health == 6
示例#8
0
def test_monstrous_macaw(initialized_game):
    attacker_board = initialized_game.player_board[0]
    defender_board = initialized_game.player_board[1]

    attacker_board.set_minions(
        [MonstrousMacaw(), RatPack(attack=2),
         PunchingBag()])
    defender_board.set_minions([PunchingBag()])
    initialized_game.start_of_game()
    initialized_game.single_round()
    # Make sure tokens spawn in the right spot
    assert len(attacker_board.minions) == 5
    assert not attacker_board.minions[2].attacked
    assert attacker_board.minions[2].name == "Rat"
    assert attacker_board.minions[3].name == "Rat"

    # Golden macaw
    attacker_board.set_minions(
        [MonstrousMacaw(golden=True),
         RatPack(attack=2),
         PunchingBag()])
    defender_board.set_minions([PunchingBag()])
    initialized_game.start_of_game()
    initialized_game.single_round()
    assert len(attacker_board.minions) == 7
    assert attacker_board.minions[6].name == "PunchingBag"

    # Test with minions with multiple deathrattles
    attacker_board.set_minions([
        MonstrousMacaw(),
        HarvestGolem(deathrattles=[ReplicatingMenaceDeathrattle()])
    ])
    defender_board.set_minions([PunchingBag()])
    initialized_game.start_of_game()
    initialized_game.single_round()
    assert (len(attacker_board.minions) == 6)

    # TODO: Test randomness of deathrattles?

    # Test baron multiplier
    # Regular macaw + Regular baron = 2 triggers
    spawn = SpawnofNZoth()
    attacker_board.set_minions([MonstrousMacaw(), spawn, BaronRivendare()])
    defender_board.set_minions([PunchingBag()])
    initialized_game.start_of_game()
    initialized_game.single_round()
    assert spawn.health == 4

    # Regular macaw + Golden baron = 3 triggers
    spawn = SpawnofNZoth()
    attacker_board.set_minions(
        [MonstrousMacaw(), spawn,
         BaronRivendare(golden=True)])
    defender_board.set_minions([PunchingBag()])
    initialized_game.start_of_game()
    initialized_game.single_round()
    assert spawn.health == 5

    # Golden macaw + Regular baron = 4 triggers
    spawn = SpawnofNZoth()
    attacker_board.set_minions(
        [MonstrousMacaw(golden=True), spawn,
         BaronRivendare()])
    defender_board.set_minions([PunchingBag()])
    initialized_game.start_of_game()
    initialized_game.single_round()
    assert spawn.health == 6

    # Golden macaw + Golden baron = 6 triggers
    spawn = SpawnofNZoth()
    attacker_board.set_minions(
        [MonstrousMacaw(golden=True), spawn,
         BaronRivendare(golden=True)])
    defender_board.set_minions([PunchingBag()])
    initialized_game.start_of_game()
    initialized_game.single_round()
    assert spawn.health == 8

    # TODO: Test order of operations with killing an opposing death rattle

    # Test attack order when spawning minions, ie generating tokens from a minion that has / hasnt attacked yet
    attacker_board.set_minions(
        [RatPack(attack=2),
         MonstrousMacaw(),
         PunchingBag(attack=5)])
    defender_board.set_minions([PunchingBag()])
    initialized_game.start_of_game()
    initialized_game.single_round()
    initialized_game.single_round()
    initialized_game.single_round()
    assert len(attacker_board.minions) == 5
    assert attacker_board.minions[4].name == "PunchingBag"
    initialized_game.single_round()
    initialized_game.single_round()
    assert defender_board.minions[0].health == 88
def test_reborn_position_tracking(initialized_game):
    attacker_board = initialized_game.player_board[0]
    defender_board = initialized_game.player_board[1]

    # Deathrattle + reborn position when adding minions
    attacker_board.add_minion(HarvestGolem(reborn=True))
    defender_board.add_minion(PunchingBag(attack=10))
    initialized_game.start_of_game()
    initialized_game.single_round()
    assert attacker_board.minions[0].name == "Damaged Golem"
    assert attacker_board.minions[1].name == "Harvest Golem"
    assert attacker_board.minions[1].health == 1

    # Death trigger + reborn position when killing minions
    # Mummy attacks imp, imp and mummy die,
    # soul juggler kills punching bag, mummy should be reborn at position 0
    attacker_board.set_minions([PunchingBag(health=1), MicroMummy()])
    defender_board.set_minions([Imprisoner(health=1), SoulJuggler()])
    initialized_game.start_of_game(starting_player=0)
    initialized_game.single_round()
    assert attacker_board.minions[0].position == 0

    # Multiple spawning deathrattles and reborn
    # Harvest Golemn + Replicating menace + reborn
    # Golem should trigger its deathrattle, then the menace, then its own reborn
    # It should be reborn WITHOUT the menace deathrattle
    golemn = HarvestGolem(deathrattles=[ReplicatingMenaceDeathrattle()],
                          reborn=True)
    attacker_board.set_minions([golemn])
    defender_board.set_minions([PunchingBag(attack=10)])
    initialized_game.start_of_game(starting_player=0)
    initialized_game.single_round()
    assert attacker_board.minions[0].name == "Damaged Golem"
    assert attacker_board.minions[1].name == "Microbot"
    assert attacker_board.minions[4].name == "Harvest Golem"
    assert attacker_board.minions[4].reborn_triggered

    attacker_board.set_minions([CaveHydra(attack=10)])
    defender_board.set_minions([
        ReplicatingMenace(),
        MicroMummy(taunt=True),
        HarvestGolem(health=1, reborn=True)
    ])
    initialized_game.start_of_game(starting_player=0)
    initialized_game.single_round()
    assert defender_board.minions[0].name == "Microbot"
    assert defender_board.minions[3].name == "Micro Mummy"
    assert defender_board.minions[3].reborn_triggered
    assert defender_board.minions[4].name == "Damaged Golem"
    assert defender_board.minions[5].name == "Harvest Golem"
    assert defender_board.minions[5].reborn_triggered

    # TODO: Consider a dead, living, dead sequence and ensure order is correct
    # TODO: Do all deathrattles resolve before any reborns?
    attacker_board.set_minions([CaveHydra(attack=10)])
    defender_board.set_minions([
        ReplicatingMenace(reborn=True),
        MicroMummy(taunt=True, health=999),
        ReplicatingMenace()
    ])
    initialized_game.start_of_game(starting_player=0)
    initialized_game.single_round()
    assert True

    # Order of on damage triggers
    attacker_board.set_minions([PunchingBag(health=1), MicroMummy()])
    defender_board.set_minions([Imprisoner(health=1), SoulJuggler()])
    initialized_game.start_of_game(starting_player=0)
    initialized_game.single_round()
    reborn_mummy = attacker_board.minions[0]
    assert reborn_mummy.position == 0
    assert reborn_mummy.reborn