本文整理汇总了Python中dungeon.Dungeon._give_me_random_coordinates方法的典型用法代码示例。如果您正苦于以下问题:Python Dungeon._give_me_random_coordinates方法的具体用法?Python Dungeon._give_me_random_coordinates怎么用?Python Dungeon._give_me_random_coordinates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dungeon.Dungeon
的用法示例。
在下文中一共展示了Dungeon._give_me_random_coordinates方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DungeonTests
# 需要导入模块: from dungeon import Dungeon [as 别名]
# 或者: from dungeon.Dungeon import _give_me_random_coordinates [as 别名]
#.........这里部分代码省略.........
tmp_arr = self.single_loc_map.entities_dic["player_1"]
x = tmp_arr[0]
y = tmp_arr[1]
self.assertEqual(x, 1)
self.assertEqual(y, 0)
def test_move_up_down(self):
self.assertFalse(self.single_loc_map._move_up_down("player_1", "down"))
self.assertFalse(self.single_loc_map._move_up_down("player_1", "up"))
expected_arr = [['.', '.', '#', '#', '.', '.', '.', '.', '.', '.'],
['#', 'H', '#', '#', '.', '.', '#', '#', '#', '.'],
['#', '.', '#', '#', '#', 'S', '#', '#', '#', '.'],
['#', '.', '.', '.', '.', '.', '#', '#', '#', '.'],
['#', '#', '#', '.', '#', '#', '#', '#', '#', '#']]
self.single_loc_map._move_left_right("player_1", "right")
self.single_loc_map._move_up_down("player_1", "down")
self.assertEqual(self.single_loc_map.map_array, expected_arr)
tmp_arr = self.single_loc_map.entities_dic["player_1"]
x = tmp_arr[1]
y = tmp_arr[1]
self.assertEqual(x, 1)
self.assertEqual(y, 1)
def test_check_for_equal_player_coordinates(self):
blademaster = Orc("Yurnero", 120, 1.2)
self.single_loc_map.spawn("player_2", blademaster)
answer1 = self.single_loc_map._check_for_equal_player_coordinates("player_1")
self.assertFalse(answer1)
self.single_loc_map.move("player_1", "right")
self.single_loc_map.move("player_2", "down")
self.single_loc_map.move("player_1", "down")
self.single_loc_map.move("player_2", "left")
self.single_loc_map.move("player_1", "down")
self.single_loc_map.move("player_2", "left")
self.single_loc_map.move("player_1", "down")
self.single_loc_map.move("player_2", "left")
self.single_loc_map.move("player_2", "left")
answer2 = self.single_loc_map._check_for_equal_player_coordinates("player_1")
answer3 = self.single_loc_map._check_for_equal_player_coordinates("player_2")
self.assertEqual(answer2, "player_2")
self.assertEqual(answer3, "player_1")
def test_give_me_random_coordinates(self):
matrix = self.single_loc_map.map_array
a, b = self.single_loc_map._give_me_random_coordinates(matrix)
self.assertIn(a, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
self.assertIn(b, [0, 1, 2, 3, 4])
def test_check_for_equal_weapon_coordinates_false1(self):
answer = self.single_loc_map._check_for_equal_player_coordinates("player_1")
self.assertFalse(answer)
def test_check_for_equal_weapon_coordinates_false2(self):
axe = Weapon("axe", 10, 0.5)
self.paladin.equip_weapon(axe)
answer = self.single_loc_map._check_for_equal_player_coordinates("player_1")
self.assertFalse(answer)
def test_start_fight_both_alive(self):
fight_map = Dungeon("fight_map.txt")
blademaster = Orc("Yurnero", 120, 1.2)
fight_map.spawn("player_1", self.paladin)
fight_map.spawn("player_2", blademaster)
fight_map.move("player_1", "right")
fight_map.move("player_2", "left")
fight_map.move("player_1", "right")
self.assertTrue(self.paladin.is_alive())
self.assertTrue(blademaster.is_alive())
def test_start_fight_blademaster_dead(self):
axe = Weapon("axe", 10, 0.5)
blademaster = Orc("Yurnero", 120, 1.2)
self.paladin.equip_weapon(axe)
fight_map = Dungeon("fight_map.txt")
fight_map.spawn("player_1", self.paladin)
fight_map.spawn("player_2", blademaster)
fight_map.move("player_1", "right")
fight_map.move("player_2", "left")
fight_map.move("player_1", "right")
expected_arr = [['.', '.', 'H', '.']]
self.assertTrue(self.paladin.is_alive())
self.assertFalse(blademaster.is_alive())
#testing _make_changes_after_fight
self.assertEqual(fight_map.map_array, expected_arr)
def test_start_fight_paladin_dead(self):
axe = Weapon("axe", 10, 0.5)
blademaster = Orc("Yurnero", 120, 1.2)
blademaster.equip_weapon(axe)
fight_map = Dungeon("fight_map.txt")
fight_map.spawn("player_1", self.paladin)
fight_map.spawn("player_2", blademaster)
fight_map.move("player_1", "right")
fight_map.move("player_2", "left")
fight_map.move("player_1", "right")
expected_arr = [['.', '.', 'O', '.']]
self.assertFalse(self.paladin.is_alive())
self.assertTrue(blademaster.is_alive())
#testing _make_changes_after_fight
self.assertEqual(fight_map.map_array, expected_arr)