Esempio n. 1
0
async def test_discard_supplies_move():
    gs = GameState()
    gs.players = [PlayerShelter('0'), PlayerShelter('1')]
    gs.active_player = gs.players[0]
    shelter = gs.active_player
    shelter.print = dumper_factory()
    shelter.input = helper_factory(['3'])
    shelter.survivors = [CityCard()]
    shelter.supplies = [Supply.AXE, Supply.BARRICADES, Supply.ALARM]
    turn_end = await gs.discard_supplies_move(False)
    assert turn_end
    assert len(shelter.supplies) == 0

    gs.active_player = shelter
    shelter.input = helper_factory(['1'])
    shelter.supplies = [Supply.AXE, Supply.BARRICADES, Supply.ALARM]
    turn_end = await gs.discard_supplies_move(False)
    assert not turn_end
    assert len(shelter.supplies) == 2
    assert Supply.BARRICADES not in shelter.supplies

    gs.active_player = shelter
    shelter.input = helper_factory(['2'])
    turn_end = await gs.discard_supplies_move(False)
    assert turn_end
    assert len(shelter.supplies) == 2
Esempio n. 2
0
def test_horde_show_up_two_zombies_left_in_city_no_graveyard():
    gs = GameState()
    gs.players = [PlayerShelter(), PlayerShelter(), PlayerShelter()]
    gs.active_player = gs.players[1]
    gs.city_deck = [
        CityCard(ZombieType.HORDE),
        CityCard(ZombieType.ZOMBIE),
        CityCard(ZombieType.ZOMBIE)
    ]
    gs.zombie_show_up()
    assert len(gs.city_deck) == 0
    assert len(gs.players[0].zombies) == 1
    assert len(gs.players[1].zombies) == 0
    assert len(gs.players[2].zombies) == 1
    assert len(gs.active_player.zombies) == 0

    gs = GameState()
    gs.players = [PlayerShelter(), PlayerShelter(), PlayerShelter()]
    gs.active_player = gs.players[2]
    gs.city_deck = [
        CityCard(ZombieType.HORDE),
        CityCard(ZombieType.ZOMBIE),
        CityCard(ZombieType.ZOMBIE)
    ]
    gs.zombie_show_up()
    assert len(gs.city_deck) == 0
    assert len(gs.players[0].zombies) == 1
    assert len(gs.players[1].zombies) == 1
    assert len(gs.players[2].zombies) == 0
    assert len(gs.active_player.zombies) == 0
Esempio n. 3
0
def test_gui_default(fast_zombie, zombie, big_zombie):
    gs = GameState()
    gs.players = [
        PlayerShelter('Name_1'),
        PlayerShelter('Name_2'),
        PlayerShelter('Name_3')
    ]
    gs.players[1].zombies = [
        zombie, fast_zombie, fast_zombie, big_zombie, zombie
    ]
    gs.players[1].obstacles = [Supply.BARRICADES, Supply.ALARM]
    gs.players[1].survivors = [CityCard(), CityCard()]
    gs.players[2].zombies = [big_zombie, big_zombie]
    gs.players[2].obstacles = [Supply.MINE_FILED]
    gs.players[2].survivors = [CityCard(), CityCard(), CityCard()]
    gs.active_player = gs.players[0]
    shelter = gs.active_player
    shelter.print = dumper_factory()
    shelter.zombies = [zombie]
    shelter.supplies = [Supply.AXE, Supply.MINE_FILED, Supply.LURE_OUT]
    shelter.obstacles = [Supply.MINE_FILED, Supply.ALARM]
    shelter.survivors = [CityCard(), CityCard(), CityCard(), CityCard()]
    shelter.gui_default(gs)
    assert len(tests.common.outputs) == 1
    assert len(tests.common.outputs[0]) == 684

    gs.city_deck = [zombie, CityCard()]
    shelter.gui_default(gs)
    assert len(tests.common.outputs) == 2
    assert len(tests.common.outputs[1]) == 706
Esempio n. 4
0
async def test_end_active_player_turn_game_finished(fast_zombie, zombie):
    gs = GameState()
    gs.players = [
        PlayerShelter(),
        PlayerShelter(),
        PlayerShelter(),
        PlayerShelter()
    ]
    gs.players[1].defeated = True
    gs.players[2].zombies = [fast_zombie]
    gs.players[2].survivors = [CityCard()]
    gs.players[3].survivors = [CityCard()]
    gs.active_player = gs.players[0]
    shelter = gs.active_player
    shelter.survivors = [CityCard()]
    shelter.zombies = [zombie]
    assert not shelter.defeated
    assert not gs.players[2].defeated
    assert not gs.players[3].defeated
    assert not gs.finished

    await gs.end_active_player_turn()
    assert shelter.defeated
    assert not gs.players[2].defeated
    assert not gs.players[3].defeated
    assert not gs.finished

    await gs.end_active_player_turn()
    assert shelter.defeated
    assert gs.players[2].defeated
    assert not gs.players[3].defeated
    assert gs.finished
Esempio n. 5
0
async def test_play_round_end_round_one_shelter_destroyed(zombie):
    gs = GameState()
    gs.players = [PlayerShelter('0'), PlayerShelter('1'), PlayerShelter('2')]
    gs.supply_deck = [
        Supply.AXE, Supply.AXE, Supply.AXE, Supply.AXE, Supply.AXE, Supply.AXE
    ]
    for player in gs.players:
        player.survivors = [CityCard()]
    gs.players[0].zombies = [zombie]
    gs.active_player = gs.players[0]
    shelter = gs.active_player
    shelter.print = dumper_factory()
    shelter.input = helper_factory(['3', '3'])
    shelter.survivors = [CityCard()]
    shelter.supplies = [Supply.AXE, Supply.BARRICADES, Supply.ALARM]
    await gs.play_round()
    assert len(shelter.supplies) == 0
    assert shelter.defeated
    assert gs.active_player != shelter

    shelter = gs.active_player
    shelter.print = dumper_factory()
    shelter.input = helper_factory(['3', '3'])
    await gs.play_round()
    assert len(shelter.supplies) == 3
    assert not shelter.defeated
    assert gs.active_player != shelter

    shelter = gs.active_player
    shelter.print = dumper_factory()
    shelter.input = helper_factory(['3', '3'])
    await gs.play_round()
    assert len(shelter.supplies) == 3
    assert not shelter.defeated
    assert gs.active_player != shelter
Esempio n. 6
0
def test_get_supplies():
    gs = GameState()
    gs.active_player = PlayerShelter()
    gs.supply_deck = [Supply.AXE, Supply.ALARM, Supply.AXE, Supply.GUN]
    gs.get_supplies()
    assert len(gs.supply_deck) == 1
    assert gs.supply_deck[0] == Supply.GUN
    assert len(gs.active_player.supplies) == 3

    gs = GameState()
    gs.active_player = PlayerShelter()
    gs.supply_deck = [Supply.AXE, Supply.ALARM, Supply.AXE, Supply.GUN]
    gs.active_player.supplies = [Supply.RADIO, Supply.DRONE]
    gs.get_supplies()
    assert len(gs.supply_deck) == 3
    assert gs.supply_deck[0] == Supply.ALARM
    assert len(gs.active_player.supplies) == 3
Esempio n. 7
0
def test_fast_zombie_show_up():
    gs = GameState()
    gs.active_player = PlayerShelter()
    gs.city_deck = [CityCard(ZombieType.FAST)]
    gs.zombie_show_up()
    assert len(gs.active_player.zombies) == 1
    assert gs.active_player.zombies[0].top == ZombieType.FAST
    assert len(gs.city_deck) == 0
Esempio n. 8
0
def test_horde_show_up_second_time():
    gs = GameState()
    gs.players = [PlayerShelter(), PlayerShelter(), PlayerShelter()]
    gs.active_player = gs.players[1]
    horde = ZombieType.HORDE
    zombie = ZombieType.ZOMBIE
    gs.city_deck = [
        CityCard(horde),
        CityCard(zombie),
        CityCard(horde),
        CityCard(zombie),
        CityCard(zombie),
        CityCard(zombie),
        CityCard(zombie),
        CityCard(zombie)
    ]
    gs.zombie_show_up()
    assert len(gs.city_deck) == 0
    assert len(gs.city_graveyard) == 2
    assert len(gs.players[0].zombies) == 2
    assert len(gs.players[1].zombies) == 1
    assert len(gs.players[2].zombies) == 2
    assert len(gs.active_player.zombies) == 1

    gs = GameState()
    gs.players = [PlayerShelter(), PlayerShelter(), PlayerShelter()]
    gs.active_player = gs.players[2]
    gs.city_deck = [
        CityCard(horde),
        CityCard(horde),
        CityCard(zombie),
        CityCard(zombie),
        CityCard(zombie),
        CityCard(zombie),
        CityCard(zombie),
        CityCard(zombie)
    ]
    gs.zombie_show_up()
    assert len(gs.city_deck) == 0
    assert len(gs.city_graveyard) == 2
    assert len(gs.players[0].zombies) == 2
    assert len(gs.players[1].zombies) == 2
    assert len(gs.players[2].zombies) == 1
    assert len(gs.active_player.zombies) == 1
Esempio n. 9
0
async def test_end_active_player_turn_no_zombies():
    gs = GameState()
    gs.players = [PlayerShelter(), PlayerShelter(), PlayerShelter()]
    survivor_card = CityCard(ZombieType.ZOMBIE)
    survivor_card.flip()
    for player in gs.players:
        player.survivors.append(survivor_card)
    gs.active_player = gs.players[2]
    gs.supply_deck = [Supply.AXE, Supply.ALARM, Supply.AXE, Supply.GUN]
    await gs.end_active_player_turn()
    assert gs.active_player == gs.players[0]
    assert len(gs.players[2].supplies) == 3
Esempio n. 10
0
async def test_play_round_end_round():
    gs = GameState()
    gs.players = [PlayerShelter('0'), PlayerShelter('1')]
    gs.players[1].survivors = [CityCard()]
    gs.active_player = gs.players[0]
    shelter = gs.active_player
    shelter.print = dumper_factory()
    shelter.input = helper_factory(['3', '3'])
    shelter.survivors = [CityCard()]
    shelter.supplies = [Supply.AXE, Supply.BARRICADES, Supply.ALARM]
    await gs.play_round()
    assert len(shelter.supplies) == 3
    assert gs.active_player != shelter
Esempio n. 11
0
async def test_play_round_win_by_takeover(zombie):
    gs = GameState()
    gs.players = [PlayerShelter('0'), PlayerShelter('1')]
    gs.players[1].survivors = [CityCard()]
    gs.active_player = gs.players[0]
    shelter = gs.active_player
    shelter.print = dumper_factory()
    shelter.input = helper_factory(['0'])
    shelter.zombies = [zombie]
    shelter.survivors = [CityCard()]
    shelter.supplies = [Supply.TAKEOVER, Supply.BARRICADES, Supply.ALARM]
    await gs.play_round()
    assert not shelter.defeated
    assert gs.players[1].defeated
    assert gs.finished
Esempio n. 12
0
async def test_play_round_use_loud_tool(zombie):
    gs = GameState()
    gs.players = [PlayerShelter('0'), PlayerShelter('1')]
    gs.players[1].survivors = [CityCard()]
    gs.players[1].zombies = [zombie]
    gs.active_player = gs.players[0]
    gs.city_deck = [CityCard()]
    shelter = gs.active_player
    shelter.print = dumper_factory()
    shelter.input = helper_factory(['0', '2'])
    shelter.survivors = [CityCard()]
    shelter.supplies = [Supply.GUN, Supply.BARRICADES, Supply.ALARM]
    await gs.play_round()
    assert len(shelter.supplies) == 3
    assert gs.city_deck[0].top == ZombieType.ZOMBIE
    assert gs.active_player != shelter
Esempio n. 13
0
async def test_play_round_play_axe_barricades_and_end_round(
        zombie, fast_zombie):
    gs = GameState()
    gs.players = [PlayerShelter('0'), PlayerShelter('1')]
    gs.players[1].survivors = [CityCard()]
    gs.active_player = gs.players[0]
    shelter = gs.active_player
    shelter.print = dumper_factory()
    shelter.input = helper_factory(['0', '0', '1', 'y'])
    shelter.zombies = [zombie, fast_zombie]
    shelter.survivors = [CityCard()]
    shelter.supplies = [Supply.AXE, Supply.BARRICADES, Supply.ALARM]
    await gs.play_round()
    assert len(shelter.supplies) == 3
    assert len(shelter.zombies) == 1
    assert len(shelter.survivors) == 1
    assert gs.active_player != shelter
Esempio n. 14
0
async def test_play_round_last_supplies(zombie):
    gs = GameState()
    gs.players = [PlayerShelter('0'), PlayerShelter('1')]
    gs.supply_deck = [Supply.SACRIFICE, Supply.DRONE, Supply.GUN]
    gs.city_deck = [CityCard()]
    gs.players[1].survivors = [CityCard()]
    gs.active_player = gs.players[0]
    shelter = gs.active_player
    shelter.print = dumper_factory()
    shelter.input = helper_factory(['0', '0', '0', 'y'])
    shelter.survivors = [CityCard()]
    shelter.zombies = [zombie]
    shelter.supplies = [Supply.RADIO, Supply.BARRICADES, Supply.ALARM]
    await gs.play_round()
    assert len(shelter.supplies) == 3
    assert gs.final_attack
    assert gs.last_supplies_taken
    assert gs.active_player != shelter
Esempio n. 15
0
async def test_end_active_player_turn_zombies_no_obstacles():
    gs = GameState()
    gs.players = [PlayerShelter(), PlayerShelter(), PlayerShelter()]
    survivor_card = CityCard(ZombieType.ZOMBIE)
    survivor_card.flip()
    for player in gs.players:
        player.survivors.append(survivor_card)
    gs.active_player = gs.players[2]
    gs.active_player.print = dumper_factory()
    gs.active_player.supplies = [Supply.AXE, Supply.ALARM]
    zombie_card = CityCard(ZombieType.ZOMBIE)
    zombie_card.flip()
    gs.active_player.zombies = [zombie_card]
    gs.supply_deck = [Supply.AXE, Supply.ALARM, Supply.AXE, Supply.GUN]
    await gs.end_active_player_turn()
    assert gs.active_player == gs.players[0]
    assert len(gs.players[2].supplies) == 0
    assert len(tests.common.outputs) == 2
Esempio n. 16
0
async def test_play_round_play_sacrifice_wit_last_survivor(
        zombie, fast_zombie):
    gs = GameState()
    gs.players = [PlayerShelter('0'), PlayerShelter('1'), PlayerShelter('2')]
    gs.players[1].survivors = [CityCard()]
    gs.players[2].survivors = [CityCard()]
    gs.active_player = gs.players[0]
    shelter = gs.active_player
    shelter.print = dumper_factory()
    shelter.input = helper_factory(['0', '1', '0'])
    shelter.zombies = [zombie, fast_zombie]
    shelter.survivors = [CityCard()]
    shelter.supplies = [Supply.SACRIFICE, Supply.BARRICADES, Supply.ALARM]
    await gs.play_round()
    assert len(shelter.supplies) == 0
    assert len(shelter.zombies) == 0
    assert len(shelter.survivors) == 0
    assert shelter.defeated
    assert len(gs.city_graveyard) == 1
    assert len(gs.supply_graveyard) == 3
    assert gs.active_player != shelter
Esempio n. 17
0
async def test_ask_player_what_move(zombie):
    gs = GameState()
    gs.active_player = PlayerShelter()
    shelter = gs.active_player
    shelter.print = dumper_factory()
    shelter.input = helper_factory(['1'])
    shelter.zombies = [zombie]
    shelter.supplies = [Supply.AXE, Supply.BARRICADES, Supply.ALARM]
    action, possible_actions = await gs.ask_player_what_move()
    assert len(possible_actions) == 4
    assert action == '1'

    shelter.input = helper_factory(['0'])
    action, possible_actions = await gs.ask_player_what_move()
    assert len(possible_actions) == 4
    assert action == '0'

    shelter.input = helper_factory(['9', 'dgadgagadg', '3'])
    action, possible_actions = await gs.ask_player_what_move()
    assert len(possible_actions) == 4
    assert action == '3'
Esempio n. 18
0
def test_zombie_show_up():
    gs = GameState()
    gs.active_player = PlayerShelter()
    gs.city_deck = [CityCard(ZombieType.ZOMBIE)]
    gs.zombie_show_up()
    assert gs.city_deck[0].top == ZombieType.ZOMBIE
    assert gs.city_deck[0].bottom == ZombieType.SURVIVOR
    assert len(gs.city_deck) == 1
    gs.zombie_show_up()
    assert len(gs.active_player.zombies) == 1
    assert gs.active_player.zombies[0].top == ZombieType.ZOMBIE
    assert len(gs.city_deck) == 0

    gs.city_deck = [CityCard(ZombieType.BIG)]
    gs.zombie_show_up()
    assert gs.city_deck[0].top == ZombieType.BIG
    assert gs.city_deck[0].bottom == ZombieType.SURVIVOR
    assert len(gs.city_deck) == 1
    gs.zombie_show_up()
    assert len(gs.active_player.zombies) == 2
    assert gs.active_player.zombies[1].top == ZombieType.BIG
    assert len(gs.city_deck) == 0
Esempio n. 19
0
async def test_end_active_player_turn_zombies_and_alarm(
        fast_zombie, zombie, big_zombie):
    gs = GameState()
    gs.players = [PlayerShelter(), PlayerShelter(), PlayerShelter()]
    survivor_card = CityCard(ZombieType.ZOMBIE)
    for player in gs.players:
        player.survivors.append(survivor_card)
    survivor_card.flip()
    gs.city_deck.append(survivor_card)
    gs.supply_deck = [Supply.AXE, Supply.ALARM, Supply.AXE, Supply.GUN]
    gs.active_player = gs.players[2]
    shelter = gs.active_player
    shelter.obstacles = [Supply.ALARM, Supply.ALARM]
    shelter.zombies = [fast_zombie, zombie, big_zombie]
    shelter.print = dumper_factory()
    shelter.input = helper_factory(['y'])
    await gs.end_active_player_turn()
    assert len(shelter.survivors) == 1
    assert len(shelter.zombies) == 4
    assert len(gs.city_deck) == 0
    assert len(shelter.obstacles) == 1
    assert len(gs.supply_graveyard) == 1
    assert len(shelter.supplies) == 3
    assert len(tests.common.outputs) == 7
Esempio n. 20
0
def test_zombie_show_up_empty_city():
    gs = GameState()
    gs.active_player = PlayerShelter()
    gs.city_deck = []
    gs.zombie_show_up()
    assert len(gs.active_player.zombies) == 0
Esempio n. 21
0
def game():
    gs = GameState()
    gs.setup_game(['CPU', '1', '2', '3'])
    gs.players[0] = CPUPlayerShelter('CPU')
    gs.active_player = gs.players[0]
    return gs
Esempio n. 22
0
def gs():
    gs = GameState()
    gs.active_player = PlayerShelter(print_foo=dumper_factory())
    return gs