예제 #1
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
def test_can_move_northwest():
    start = (1, 3)
    target = Locatable((3, 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 == (1, 2)
    assert step_two == (2, 2)
    assert step_three == (2, 1)
    assert step_four == target.coords
예제 #3
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
def test_can_move_southeast():
    start = (3, 1)
    target = Locatable((1, 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 == (3, 2)
    assert step_two == (2, 2)
    assert step_three == (2, 3)
    assert step_four == target.coords
예제 #5
0
    def move(self):
        """Move uses the Movement class to move a square towards it's target"""
        target_tile = next_tile(self.coords, self.target)
        direction = what_direction(self.coords, target_tile)

        self.place(target_tile)
        return direction
    def move_creatures(self):
        """Moves the creatures in the room"""
        creatures = self.level.get_move_ai()

        for creature in creatures:
            target_tile = next_tile(creature.coords, creature.target)
            if target_tile == self.player.coords:
                dmg = creature.weapon.damage
                self.interface.display("You were attacked by the " + creature.name + " for " + str(dmg) + " damage!")
                response = self.player.take_damage(dmg)
                if response:
                    self.interface.display(response)
                    return False
            else:
                creature.move()
        return True
예제 #7
0
 def move_creatures(self):
     """Moves the creatures in the room"""
     creatures = self.level.get_move_ai()
     for creature in creatures:
         target_tile = next_tile(creature.coords, creature.target)
         if target_tile == self.player.coords:
             dmg = creature.weapon.damage
             dev = creature.deviation
             dmgdev = randint(dmg - dev, dmg + dev)
             self.interface.display("你被 " + creature.name + " 攻击,受到了 " +
                                    str(dmgdev) + " 点伤害!")
             response = self.player.take_damage(dmg)
             if response:
                 self.interface.display(response)
                 return False
         else:
             creature.move()
     return True
예제 #8
0
    def move_creatures(self):
        """Moves the creatures in the room"""
        creatures = self.level.get_move_ai()

        for creature in creatures:
            target_tile = next_tile(creature.coords, creature.target)
            if target_tile == self.player.coords:
                dmg = creature.weapon.damage
                self.interface.display("You were attacked by the " +
                                       creature.name + " for " + str(dmg) +
                                       " damage!")
                response = self.player.take_damage(dmg)
                if response:
                    self.interface.display(response)
                    return False
            else:
                creature.move()
        return True
예제 #9
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
예제 #10
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
예제 #11
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
예제 #12
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
예제 #13
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
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_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 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
예제 #19
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
def test_knows_to_move_south_to_target_tile():
    x, y = next_tile((1,1),Locatable((1,0)))
    assert x == 1
    assert y == 0