def __init__(self, name): Locatable.__init__(self) HealthPoints.__init__(self, 100) self.description = name self.name = "player" self.display = "@" self.display_priority = 1 self.inside = False
def __init__(self, name, description, health_pts): Locatable.__init__(self) HealthPoints.__init__(self, health_pts) self.name = name self.description = description self.target = Locatable() self.move_ai = True self.is_dead = False
def __init__(self, name): Locatable.__init__(self) HealthPoints.__init__(self, 100) self.description = name self.name = "player" self.display = "@" self.display_priority = 1 self.inside = False
def test_can_move_northeast(): start = (1, 1) target = Locatable((3, 3)) step_one = next_tile(start, target) step_two = next_tile(step_one, target) step_three = next_tile(step_two, target) step_four = next_tile(step_three, target) assert step_one == (1, 2) assert step_two == (2, 2) assert step_three == (2, 3) assert step_four == target.coords
def test_can_move_southwest(): start = (3, 3) target = Locatable((1, 1)) step_one = next_tile(start, target) step_two = next_tile(step_one, target) step_three = next_tile(step_two, target) step_four = next_tile(step_three, target) assert step_one == (3, 2) assert step_two == (2, 2) assert step_three == (2, 1) assert step_four == target.coords
def test_knows_to_take_first_step_toward_target_two_squares_west(): x, y = next_tile((2, 2), Locatable((0, 2))) assert x == 1 assert y == 2
def test_knows_to_take_first_step_toward_target_two_squares_north(): x, y = next_tile((2, 2), Locatable((2, 4))) assert x == 2 assert y == 3
def test_knows_to_move_west_to_target_tile(): x, y = next_tile((1, 1), Locatable((0, 1))) assert x == 0 assert y == 1
def test_knows_to_move_east_to_target_tile(): x, y = next_tile((1, 1), Locatable((2, 1))) assert x == 2 assert y == 1
def test_knows_to_move_south_to_target_tile(): x, y = next_tile((1, 1), Locatable((1, 0))) assert x == 1 assert y == 0
def locatable(): return Locatable()
def test_knowing_location_and_target_will_determine_direction(): assert "n" == next_direction((0, 1), Locatable((0, 5))) assert "s" == next_direction((0, 5), Locatable((0, 1))) assert "e" == next_direction((1, 0), Locatable((5, 0))) assert "w" == next_direction((5, 0), Locatable((1, 0)))
def __init__(self, name=None, description=None): Locatable.__init__(self) self.name = name self.description = description
def test_move_will_update_the_roach_location(roach): roach.set_target(Locatable((0, 3))) roach.move() assert (1, 3) == roach.locate()
def test_roach_will_move_towards_target(roach): roach.set_target(Locatable((0, 3))) assert "w" == roach.move()
def test_knows_it_does_not_need_to_move_to_get_where_it_is(): x, y = next_tile((1, 1), Locatable((1, 1))) assert x == 1 assert y == 1
def __init__(self, name=None, description=None): Locatable.__init__(self) self.name = name self.description = description
def test_locatable_has_unique_id(locatable): another = Locatable() third = Locatable() assert locatable.uid != another.uid assert locatable.uid != third.uid assert another.uid != third.uid