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


Python Dungeon.get_entity_indicator方法代码示例

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


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

示例1: DungeonTest

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

#.........这里部分代码省略.........
        self.dungeon.spawn_npcs()
        result = self.dungeon.move_npc("NPC1")
        self.assertEqual(result, None)

    def test_move_npc_into_chest(self):
        self.dungeon.map = "CCC\nCNC\nCCC"
        self.dungeon.spawn_npcs()
        result = self.dungeon.move_npc("NPC1")
        self.assertEqual(result, None)

    def test_move_npc_into_wall(self):
        self.dungeon.map = "###\n#N#\n###"
        self.dungeon.spawn_npcs()
        result = self.dungeon.move_npc("NPC1")
        self.assertEqual(result, None)

    def test_move_npc_into_orc(self):
        self.dungeon.map = "OOO\nONO\nOOO"
        self.dungeon.spawn_npcs()
        result = self.dungeon.move_npc("NPC1")
        self.assertEqual(result, None)

    def test_move_hero_into_battle(self):
        mod = "ZZZZ\nZSNZ\nZZZZ"
        self.dungeon.map = mod
        self.dungeon.spawn("1", self.hero)
        self.dungeon.spawn_npcs()
        self.hero.weapon = Weapon("Frostmourne", 40, 0.9)
        result = self.dungeon.move_player("1", "right")
        self.assertIn(result, ["1 wins!", "NPC1 wins!"])

    def test_move_npc_into_battle(self):
        mod = "ZZSZ\nZSNS\nZZSZ"
        self.dungeon.map = mod
        self.dungeon.spawn("1", self.hero)
        self.dungeon.spawn("2", Hero("Tirion", 1, "Fondring"))
        self.dungeon.spawn("3", Hero("Lich", 1, "King"))
        self.dungeon.spawn("4", Hero("Bat", 1, "Svetlio"))
        self.dungeon.spawn_npcs()

        result = self.dungeon.move_npc("NPC1")
        self.assertIn(result, ["1 wins!", "NPC1 wins!"])

    def test_spawn_npcs(self):
        mod = "ZZZZ\nZN.Z\nZ.NZ\nZZZZ"
        self.dungeon.map = mod
        self.dungeon.spawn_npcs()
        actual = "ZZZZ\nZO.Z\nZ.OZ\nZZZZ"
        self.assertEqual(self.dungeon.map, actual)

    def test_obtain_key(self):
        mod = "ZZZZ\nZS.Z\nZK.Z\nZZZZ"
        self.dungeon.map = mod
        self.dungeon.spawn("1", self.hero)
        result = self.dungeon.move_player("1", "down")
        self.assertEqual(result, "Key Obtained.")

    def test_unlock_chest_when_key_is_obtained(self):
        mod = "ZZZZ\nZSKZ\nZ.CZ\nZZZZ"
        self.dungeon.map = mod
        self.dungeon.spawn("1", self.hero)
        self.dungeon.move_player("1", "right")
        result = self.dungeon.move_player("1", "down")
        self.assertEqual(result, "Chest Unlocked.")

    def test_unlock_chest_when_key_not_present(self):
        mod = "ZZZZ\nZS.Z\nZC.Z\nZZZZ"
        self.dungeon.map = mod
        self.dungeon.spawn("1", self.hero)
        result = self.dungeon.move_player("1", "down")
        self.assertEqual(result, "You must get the key first.")

    def test_get_random_npc(self):
        mod = "ZZZZ\nZNNZ\nZCNZ\nZZZZ"
        self.dungeon.map = mod
        self.dungeon.spawn_npcs()
        result = self.dungeon.get_random_npc()
        self.assertIn(result, self.dungeon.npcs)

    def test_move_npc_to_empty_spot(self):
        mod = "ZZZZZZZ\nZ.....Z\nZ..N..Z\nZ.....Z\nZZZZZZZ"
        self.dungeon.map = mod
        self.dungeon.spawn_npcs()
        self.dungeon.move_npc(self.dungeon.get_random_npc())
        self.assertIn(self.dungeon.map, [
            "ZZZZZZZ\nZ..O..Z\nZ.....Z\nZ.....Z\nZZZZZZZ",
            "ZZZZZZZ\nZ.....Z\nZ.O...Z\nZ.....Z\nZZZZZZZ",
            "ZZZZZZZ\nZ.....Z\nZ...O.Z\nZ.....Z\nZZZZZZZ",
            "ZZZZZZZ\nZ.....Z\nZ.....Z\nZ..O..Z\nZZZZZZZ"])

    def test_move_to_invalid_spot(self):
        mod = "ZZZZZZZ\nZ..K..Z\nZ.#NC.Z\nZ..O..Z\nZZZZZZZ"
        self.dungeon.map = mod
        self.dungeon.spawn_npcs()
        self.dungeon.move_npc(self.dungeon.get_random_npc())
        self.assertEqual(self.dungeon.map, mod.replace("N", "O"))

    def test_get_invalid_indicator(self):
        self.invalid = Entity("Name", 20)
        self.assertEqual(self.dungeon.get_entity_indicator(self.invalid), "")
开发者ID:sslavov93,项目名称:TreasureDungeon,代码行数:104,代码来源:test_all.py


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