def test_is_action_possible_with_next_action(): """ Tests is_action_possible and constructor parameter next_action """ players = [Player(id, 0) for id in [9, 0, 3]] turns = Turns(players=players, next_action=PlayerAction(players[2], PlayerAction.MOVE_ACTION)) assert not turns.is_action_possible(players[0], PlayerAction.SHIFT_ACTION) assert not turns.is_action_possible(players[1], PlayerAction.SHIFT_ACTION) assert turns.is_action_possible(players[2], PlayerAction.MOVE_ACTION) turns.perform_action(players[2], PlayerAction.MOVE_ACTION) assert turns.is_action_possible(players[0], PlayerAction.SHIFT_ACTION) assert not turns.is_action_possible(players[1], PlayerAction.SHIFT_ACTION) turns.perform_action(players[0], PlayerAction.SHIFT_ACTION) turns.perform_action(players[0], PlayerAction.MOVE_ACTION) assert not turns.is_action_possible(players[0], PlayerAction.SHIFT_ACTION) assert turns.is_action_possible(players[1], PlayerAction.SHIFT_ACTION)
def test_is_action_possible_with_complete_cycle(): """ Tests is_action_possible """ players = [Player(id, 0) for id in [2, 1]] turns = Turns(players=players) assert turns.is_action_possible(players[0], PlayerAction.SHIFT_ACTION) assert not turns.is_action_possible(players[0], PlayerAction.MOVE_ACTION) assert not turns.is_action_possible(players[1], PlayerAction.SHIFT_ACTION) assert not turns.is_action_possible(players[1], PlayerAction.MOVE_ACTION) turns.perform_action(players[0], PlayerAction.SHIFT_ACTION) turns.perform_action(players[0], PlayerAction.MOVE_ACTION) turns.perform_action(players[1], PlayerAction.SHIFT_ACTION) assert not turns.is_action_possible(players[0], PlayerAction.SHIFT_ACTION) assert not turns.is_action_possible(players[0], PlayerAction.MOVE_ACTION) assert not turns.is_action_possible(players[1], PlayerAction.SHIFT_ACTION) assert turns.is_action_possible(players[1], PlayerAction.MOVE_ACTION) turns.perform_action(players[1], PlayerAction.MOVE_ACTION) assert turns.is_action_possible(players[0], PlayerAction.SHIFT_ACTION) assert not turns.is_action_possible(players[0], PlayerAction.MOVE_ACTION) assert not turns.is_action_possible(players[1], PlayerAction.SHIFT_ACTION) assert not turns.is_action_possible(players[1], PlayerAction.MOVE_ACTION) turns.perform_action(players[0], PlayerAction.SHIFT_ACTION)