Example #1
0
async def test_play_game_cpu(number_of_cpus):
    names = [f'CPU{index}' for index in range(number_of_cpus)]
    for index in range(10):
        gs = GameState()
        gs.setup_game(names, 2)
        for player in gs.players:
            player.print = dumper_factory()
        await gs.play_game()
Example #2
0
async def test_play_game(zombie):
    gs = GameState()
    gs.setup_game(['First', 'Second'], 1)
    gs.players[0].print = dumper_factory()
    gs.players[0].input = helper_factory(['3', '3'])
    gs.players[0].zombies = [zombie]
    gs.players[1].print = dumper_factory()
    winners = await gs.play_game()
    assert len(winners) == 1
    assert winners[0] == 'Second'
Example #3
0
def test_setup_game():
    gs = GameState()
    gs.setup_game(['First', 'Second', 'Third'], 3)
    assert gs.active_player == gs.players[0]
    for shelter in gs.players:
        assert len(shelter.survivors) == 3
        assert len(shelter.supplies) == 3

    gs.setup_game(['First', 'Second', 'Third'], 1)
    assert gs.active_player == gs.players[0]
    for shelter in gs.players:
        assert len(shelter.survivors) == 1
        assert len(shelter.supplies) == 3
def game():
    gs = GameState()
    gs.setup_game(['CPU', '1', '2', '3'])
    gs.players[0] = CPUPlayerShelter('CPU')
    gs.active_player = gs.players[0]
    return gs