コード例 #1
0
 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
コード例 #2
0
 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
コード例 #3
0
 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
コード例 #4
0
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
コード例 #5
0
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
コード例 #6
0
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
コード例 #7
0
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
コード例 #8
0
def test_knows_to_move_west_to_target_tile():
    x, y = next_tile((1, 1), Locatable((0, 1)))
    assert x == 0
    assert y == 1
コード例 #9
0
def test_knows_to_move_east_to_target_tile():
    x, y = next_tile((1, 1), Locatable((2, 1)))
    assert x == 2
    assert y == 1
コード例 #10
0
def test_knows_to_move_south_to_target_tile():
    x, y = next_tile((1, 1), Locatable((1, 0)))
    assert x == 1
    assert y == 0
コード例 #11
0
def locatable():
    return Locatable()
コード例 #12
0
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)))
コード例 #13
0
 def __init__(self, name=None, description=None):
     Locatable.__init__(self)
     self.name = name
     self.description = description
コード例 #14
0
def test_move_will_update_the_roach_location(roach):
    roach.set_target(Locatable((0, 3)))
    roach.move()
    assert (1, 3) == roach.locate()
コード例 #15
0
def test_roach_will_move_towards_target(roach):
    roach.set_target(Locatable((0, 3)))
    assert "w" == roach.move()
コード例 #16
0
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
コード例 #17
0
 def __init__(self, name=None, description=None):
     Locatable.__init__(self)
     self.name = name
     self.description = description
コード例 #18
0
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