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


Python Dungeon.spown方法代码示例

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


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

示例1: Dungeon_Test

# 需要导入模块: from dungeon import Dungeon [as 别名]
# 或者: from dungeon.Dungeon import spown [as 别名]
class Dungeon_Test(unittest.TestCase):

    def setUp(self):
        self.sniper = Weaphon("Gun", 85, 0.10)
        self.hammer = Weaphon("One-Hand", 30, 0)

        self.bron_orc = Orc("Pesho", 100, 1.50)
        self.bron_hero = Hero("Ivan", 100, "Magician")

        self.bron_orc.equip_weapon(self.hammer)
        self.bron_hero.equip_weapon(self.sniper)
        self.magura = Dungeon("/home/biser/TDD/simple_dungeon.txt")

    def tearDown(self):
        f1 = open("/home/biser/TDD/simple_dungeon.txt", 'w+')
        a = "S.##......\n#.##..###.\n#.###.###.\n#.....###.\n###.#####S\n"
        self.magura.lst = []
        f1.write(a)

    def test_constructor(self):
        self.assertEqual(
            "/home/biser/TDD/simple_dungeon.txt", self.magura.path)

    def test_print_map(self):
        a = "S.##......\n#.##..###.\n#.###.###.\n#.....###.\n###.#####S\n"
        self.assertEqual(a, self.magura.print_map())

    def test_spawn_first_entity(self):
        self.magura.spown("Ivan", self.bron_hero)
        f1 = open("/home/biser/TDD/simple_dungeon.txt", 'r')
        first_spowning_point = f1.readline()[0]
        f1.close()
        self.assertEqual(first_spowning_point, "H")

    def test_spawn_wrong_object_as_argument(self):
        self.magura.spown("Ivan", self.sniper)
        self.assertEqual(
            "wrong instance given", self.magura.spown("Ivan", self.sniper))

    def test_spawn_second_entity(self):
        temp = ""
        self.magura.spown("Ivan", self.bron_hero)
        self.magura.spown("Ivan", self.bron_orc)
        f1 = open("/home/biser/TDD/simple_dungeon.txt", 'r')
        print
        for line in f1:
            temp = line
        temp = temp[len(temp)-2:]
        self.assertEqual("O\n", temp)

    def test_spawn_one_more_than_the_map_can_handle(self):
        self.magura.spown("Ivan", self.bron_hero)
        self.magura.spown("Gosho", self.bron_orc)
        self.assertEqual("currently there is no free spowning point", self.magura.spown("Pesho", self.bron_orc))

    def test_entity_move(self):
        self.magura.spown("Ivan", self.bron_hero)
        self.magura.move("Ivan", "right")
        f1 = open("/home/biser/TDD/simple_dungeon.txt", 'r')
        first_spowning_point = f1.readline()[1]
        f1.close()
        self.assertEqual(first_spowning_point, "H")

    def test_entity_move_through_wall(self):
        pass
        self.magura.spown("Ivan", self.bron_hero)
        self.magura.move("Ivan", "right")
        self.assertFalse(self.magura.move("Ivan", "right"))

    def test_move_outside_the_map(self):
        pass
        self.magura.spown("Ivan", self.bron_hero)
        self.assertFalse(self.magura.move("Ivan", "left"))
开发者ID:golfdman,项目名称:HackBulgaria,代码行数:75,代码来源:test_hero.py


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