本文整理汇总了Python中dungeon.Dungeon.get_content方法的典型用法代码示例。如果您正苦于以下问题:Python Dungeon.get_content方法的具体用法?Python Dungeon.get_content怎么用?Python Dungeon.get_content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dungeon.Dungeon
的用法示例。
在下文中一共展示了Dungeon.get_content方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestDungeon
# 需要导入模块: from dungeon import Dungeon [as 别名]
# 或者: from dungeon.Dungeon import get_content [as 别名]
class TestDungeon(unittest.TestCase):
def setUp(self):
self.content = 'S.##......\n#.##..###.\n#.###.###.\n#.....###.\n###.#####S'
self.filename = "basic_dungeon.txt"
self.file = open(self.filename,'w')
self.file.write(self.content)
self.file.close()
##-------------------------
self.new_map = Dungeon(self.filename)
def tearDown(self):
#pass
os.remove(self.filename)
def test_spawn_true(self):
player1 = Hero("Bron", 100, "DragonSlayer")
player2 = Orc('karakondjul', 100 , 1.5)
self.assertTrue(self.new_map.spawn(player1.name, player1))
self.assertTrue(self.new_map.spawn(player2.name, player2))
#self.new_map.print_map()
def test_spawn_false(self):
player1 = Hero("Bron", 100, "DragonSlayer")
player2 = Orc('karakondjul', 100 , 1.5)
player3 = Hero("Bron1", 100, "DragonSlayer")
self.assertTrue(self.new_map.spawn(player1.name, player1))
self.assertTrue(self.new_map.spawn(player2.name, player2))
self.assertFalse(self.new_map.spawn(player3.name, player3))
#self.new_map.print_map()
def test_print_map(self):
self.assertEqual(self.new_map.get_content(),self.content)
#print(self.content)
#self.new_map.print_map()
def test_move_right_true(self):
player1 = Hero("Bron", 100, "DragonSlayer")
self.new_map.spawn(player1.name, player1)
self.assertTrue(self.new_map.move(player1.name,"right"))
#self.new_map.print_map()
def test_move_right_false(self):
player1 = Hero("Bron", 100, "DragonSlayer")
player2 = Orc('karakondjul', 100 , 1.5)
self.new_map.spawn(player1.name, player1)
self.new_map.spawn(player2.name, player2)
#self.new_map.move(player1.name,"right")
self.assertFalse(self.new_map.move(player2.name,"right"))
#self.new_map.print_map()
def test_move_left_true(self):
player1 = Hero("Bron", 100, "DragonSlayer")
self.new_map.spawn(player1.name, player1)
self.new_map.move(player1.name,"right")
#self.new_map.print_map()
self.assertTrue(self.new_map.move(player1.name,"left"))
#self.new_map.print_map()
def test_move_left_false(self):
player1 = Hero("Bron", 100, "DragonSlayer")
self.new_map.spawn(player1.name, player1)
self.assertFalse(self.new_map.move(player1.name,"left"))
#self.new_map.print_map()
def test_move_up_true(self):
player1 = Hero("Bron", 100, "DragonSlayer")
player2 = Orc('karakondjul', 100 , 1.5)
self.new_map.spawn(player1.name, player1)
self.new_map.spawn(player2.name, player2)
self.assertTrue(self.new_map.move(player2.name,"up"))
#self.new_map.print_map()
def test_move_up_false(self):
player1 = Hero("Bron", 100, "DragonSlayer")
self.new_map.spawn(player1.name, player1)
self.assertFalse(self.new_map.move(player1.name,"up"))
#self.new_map.print_map()
def test_move_down_true(self):
player1 = Hero("Bron", 100, "DragonSlayer")
self.new_map.spawn(player1.name, player1)
self.new_map.move(player1.name,"right")
self.assertTrue(self.new_map.move(player1.name,"down"))
#self.new_map.print_map()
def test_move_down_false(self):
player1 = Hero("Bron", 100, "DragonSlayer")
player2 = Orc('karakondjul', 100 , 1.5)
self.new_map.spawn(player1.name, player1)
self.new_map.spawn(player2.name, player2)
self.assertFalse(self.new_map.move(player2.name,"down"))
#self.new_map.print_map()
#ok
def test_move_right_and_fight(self):
#.........这里部分代码省略.........