Exemple #1
0
def test_cleanup(player, deck, action_factory, ui):
    player.draw_cards(1)
    alive_player = Player("Alive Player", deck, action_factory, ui)
    alive_player.draw_cards(1)
    dead_player = Player("Dead Player", deck, action_factory, ui)

    game = Game([player, alive_player, dead_player], ui)
    game.play = MagicMock()
    game.active_player = game.turn_queue.popleft()
    game.cleanup()

    assert player in game.turn_queue
    assert alive_player in game.turn_queue
    assert dead_player not in game.turn_queue
    game.play.assert_called_once()
Exemple #2
0
def create_players(num_players, deck, action_factory, ui):
    import random
    names = ["Shinji", "Rei", "Asuka", "Misato", "Gendo", "Kaworu"]
    random.shuffle(names)

    players = []
    for name in names[:num_players]:
        p = Player(name, deck=deck, action_factory=action_factory, ui=ui)
        players.append(p)
    return players
Exemple #3
0
def test_choose_target(player, deck, ui, action_factory):
    target_obs = MagicMock()
    player.add_target_observer(target_obs)
    ui.set_state = MagicMock()

    filler = Player("Target1", deck, action_factory, ui)
    filler.draw_cards(1)
    target = Player("Target2", deck, action_factory, ui)
    target.draw_cards(1)
    expected = [Option("Target1", filler), Option("Target2", target)]

    player.player_list = [filler, player, target]
    player.choose_target()

    optionlist = ui.set_state.call_args[0][0]
    assert expected == optionlist.options

    player.handle(target)
    target_obs.receive_target.assert_called_once_with(target)
Exemple #4
0
def player(deck, action_factory, ui):
    p = Player("Test Player", deck, action_factory, ui)
    return p
Exemple #5
0
def player(deck, action_factory, ui):
    p = Player("Test Name", deck, action_factory, ui)
    p.add_card(Card.LORD)
    p.add_card(Card.BANDIT)
    p.coins = 2
    return p
Exemple #6
0
def target(deck, action_factory, ui):
    p = Player("Test Target", deck, action_factory, ui)
    p.coins = 3
    p.add_card(Card.BANDIT)
    p.add_card(Card.MEDIC)
    return p
Exemple #7
0
def player(deck, action_factory, ui):
    p = Player("Test Player", deck, action_factory, ui)
    p.coins = 2
    p.add_card(Card.MEDIC)
    p.add_card(Card.MERCENARY)
    return p