本文整理汇总了Python中dungeon.Dungeon.check_move方法的典型用法代码示例。如果您正苦于以下问题:Python Dungeon.check_move方法的具体用法?Python Dungeon.check_move怎么用?Python Dungeon.check_move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dungeon.Dungeon
的用法示例。
在下文中一共展示了Dungeon.check_move方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DungeonTest
# 需要导入模块: from dungeon import Dungeon [as 别名]
# 或者: from dungeon.Dungeon import check_move [as 别名]
#.........这里部分代码省略.........
".", ".", ".", "#", "C", "#", "Z"],
["Z", ".", ".", "#", "#", "#", "#", "#", "#", "#", "#", "#",
"#", "#", ".", ".", ".", ".", "Z"],
["Z", "Z", "Z", "Z", "Z", "Z", "Z", "Z", "Z", "Z", "Z", "Z",
"Z", "Z", "Z", "Z", "Z", "Z", "Z"]]
result = self.dungeon.convert_map_to_changeable_tiles()
self.assertEqual(result, actual)
def test_map_revert(self):
test = self.dungeon.convert_map_to_changeable_tiles()
result = self.dungeon.revert_map_to_string_state(test)
self.assertEqual(result, self.dungeon.map)
def test_locate_position(self):
result = self.dungeon.get_position_in_map("S")
self.assertEqual(result, [2, 3])
def test_destination_coordinates_down(self):
result = self.dungeon.get_destination_coordinates([4, 4], "down")
self.assertEqual(result, [5, 4])
def test_destination_coordinates_up(self):
result = self.dungeon.get_destination_coordinates([4, 4], "up")
self.assertEqual(result, [3, 4])
def test_destination_coordinates_left(self):
result = self.dungeon.get_destination_coordinates([4, 4], "left")
self.assertEqual(result, [4, 3])
def test_destination_coordinates_right(self):
result = self.dungeon.get_destination_coordinates([4, 4], "right")
self.assertEqual(result, [4, 5])
def test_check_move_with_wrong_direction(self):
result = self.dungeon.check_move(".", "test")
self.assertEqual(result, False)
def test_check_move_with_out_of_bounds_err(self):
result = self.dungeon.check_move("Z", "up")
self.assertEqual(result, False)
def test_check_move_into_wall(self):
result = self.dungeon.check_move("#", "left")
self.assertEqual(result, False)
def test_valid_move_into_free_space(self):
self.dungeon.spawn("1", self.hero)
self.dungeon.move_player("1", "right")
self.assertEqual(self.hero.location, [2, 4])
def test_invalid_hero_move(self):
self.dungeon.map = "ZZZ\nZSZ\nZZZ"
self.dungeon.spawn("Char", self.hero)
result = self.dungeon.move_player("Char", "left")
self.assertEqual(result, "Try again.")
def test_move_npc_into_border(self):
self.dungeon.map = "ZZZ\nZNZ\nZZZ"
self.dungeon.spawn_npcs()
result = self.dungeon.move_npc("NPC1")
self.assertEqual(result, None)
def test_move_npc_into_key(self):
self.dungeon.map = "KKK\nKNK\nKKK"
self.dungeon.spawn_npcs()
result = self.dungeon.move_npc("NPC1")