Ejemplo n.º 1
0
def test_robot_is_not_repaired(damages, tile, current_game_round):
    """
    When robot is on RepairTile but the game round is not 5, he is not yet repaired. His damage count doesn't change.
    """
    robot = Robot(None, None, None, (0, 0))
    state = State({(0, 0): [tile]}, [robot], 1)
    robot.damages = damages
    state.game_round = current_game_round
    apply_tile_effects(state)
    assert robot.damages == damages
Ejemplo n.º 2
0
def test_robot_is_repaired_after_5th_round(damages_before, tile, damages_after):
    """
    When robot is on RepairTile he is supposed to be repaired after the 5th game round.
    If he doesn't have any damages, the count remains the same as previous.
    """
    robot = Robot(None, None, None, (0, 0))
    state = State({(0, 0): [tile]}, [robot], 1)
    robot.damages = damages_before
    state.game_round = 5
    apply_tile_effects(state)
    assert robot.damages == damages_after
Ejemplo n.º 3
0
def test_robot_is_pushed_to_the_correct_direction(tile, output_coordinates):
    """
    When robot is standing on a PusherTile, he should be pushed in the direction of pusher's force.
    Eg. pusher on the North tile side forces the robot's movement to the South.
    Robot's direction doesn't change, just the coordinates.
    The test asserts the coordinates change to a correct ones (in a correct direction).
    """
    robot = Robot(Direction.S, None, None, (1, 1))
    state = State({(1, 0): [Tile(None, None, None)], (0, 1): [Tile(None, None, None)], (2, 1): [Tile(None, None, None)], (1, 2): [Tile(None, None, None)], (1, 1): [tile]}, [robot], 5)
    state.game_round = 1
    apply_tile_effects(state)
    assert robot.direction == Direction.S
    assert robot.coordinates == output_coordinates
Ejemplo n.º 4
0
def test_robot_is_pushed_out_of_the_board(tile):
    """
    When robot is standing on a PusherTile, he should be pushed in the direction of pusher's force.
    Eg. pusher on the North tile side forces the robot's movement to the South.
    If he is pushed out of a board game, he should be killed.
    The test asserts the attributes: coordinates, lives and inactive change.
    """
    robot = Robot(Direction.S, None, None, (0, 0))
    state = State({(0, 0): [tile]}, [robot], 1)
    state.game_round = 1
    apply_tile_effects(state)
    assert robot.lives == 2
    assert robot.inactive is True
    assert robot.coordinates == (-1, -1)
Ejemplo n.º 5
0
def test_robot_is_pushed_at_the_correct_round(game_round, tile, output_coordinates):
    """
    When robot is standing on a PusherTile, he should be pushed in the direction of pusher's force.
    Eg. pusher on the North tile side forces the robot's movement to the South.
    Robot's direction doesn't change, just the coordinates.
    The push is performed only at the certain game round (1-3-5 or 2-4) according
    to the value on the tile.
    """
    robot = Robot(Direction.W, None, None, (1, 1))
    state = State({(1, 0): [Tile(None, None, None)], (1, 1): [tile]}, [robot], 2)
    state.game_round = game_round
    apply_tile_effects(state)
    assert robot.direction == Direction.W
    assert robot.coordinates == output_coordinates