当前位置: 首页>>代码示例>>Python>>正文


Python Dungeon.get_position_in_map方法代码示例

本文整理汇总了Python中dungeon.Dungeon.get_position_in_map方法的典型用法代码示例。如果您正苦于以下问题:Python Dungeon.get_position_in_map方法的具体用法?Python Dungeon.get_position_in_map怎么用?Python Dungeon.get_position_in_map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dungeon.Dungeon的用法示例。


在下文中一共展示了Dungeon.get_position_in_map方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DungeonTest

# 需要导入模块: from dungeon import Dungeon [as 别名]
# 或者: from dungeon.Dungeon import get_position_in_map [as 别名]

#.........这里部分代码省略.........
        result = self.dungeon.spawn("Player 3", testchar)
        self.assertEqual(result, "No free spawn slot.")

    def test_map_conversion(self):
        actual = [["Z", "Z", "Z", "Z", "Z", "Z", "Z", "Z", "Z", "Z", "Z", "Z",
                   "Z", "Z", "Z", "Z", "Z", "Z", "Z"],
                  ["Z", "#", ".", ".", ".", "#", ".", "#", "#", ".", "#", "#",
                   "#", "#", "#", "#", "#", "#", "Z"],
                  ["Z", "#", ".", "S", ".", "#", ".", ".", ".", ".", ".", "N",
                   ".", ".", ".", ".", "K", ".", "Z"],
                  ["Z", "#", ".", ".", ".", "#", ".", ".", "#", ".", ".", ".",
                   ".", ".", "#", "#", "#", "#", "Z"],
                  ["Z", "#", ".", ".", ".", "#", ".", ".", "#", ".", ".", ".",
                   ".", ".", "N", ".", ".", "#", "Z"],
                  ["Z", ".", ".", ".", ".", "#", ".", ".", "#", ".", ".", ".",
                  ".", ".", ".", "#", ".", "#", "Z"],
                  ["Z", "#", ".", ".", ".", ".", ".", ".", "#", ".", ".", "N",
                   ".", ".", ".", "#", ".", "#", "Z"],
                  ["Z", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".",
                   ".", ".", ".", "#", "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)
开发者ID:sslavov93,项目名称:TreasureDungeon,代码行数:70,代码来源:test_all.py


注:本文中的dungeon.Dungeon.get_position_in_map方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。