本文整理汇总了Python中arena.Arena.get_location方法的典型用法代码示例。如果您正苦于以下问题:Python Arena.get_location方法的具体用法?Python Arena.get_location怎么用?Python Arena.get_location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arena.Arena
的用法示例。
在下文中一共展示了Arena.get_location方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_snapshot_with_dude
# 需要导入模块: from arena import Arena [as 别名]
# 或者: from arena.Arena import get_location [as 别名]
def test_snapshot_with_dude(self):
pc = Pc()
arena = Arena(1, 1)
arena.get_location(Point(0, 0)).additem(pc)
snapshot = Snapshot(WorldSnapshot(arena), pc.id, [])
stringed = snapshot_to_string(snapshot)
expected = "###\n#\u263A#\n###\nHP: 100, Strength: 10"
self.assertEqual(expected, stringed)
示例2: test_snapshot_with_cat
# 需要导入模块: from arena import Arena [as 别名]
# 或者: from arena.Arena import get_location [as 别名]
def test_snapshot_with_cat(self):
arena = Arena(1, 1)
location = arena.get_location(Point(0, 0))
cat = Cat()
location.additem(cat)
snapshot = Snapshot(WorldSnapshot(arena), cat.id, [])
stringed = snapshot_to_string(snapshot)
expected = "###\n#x#\n###\nHP: 10, Strength: 2"
self.assertEqual(expected, stringed)
示例3: test_snapshot_with_log
# 需要导入模块: from arena import Arena [as 别名]
# 或者: from arena.Arena import get_location [as 别名]
def test_snapshot_with_log(self):
arena = Arena(1, 1)
location = arena.get_location(Point(0, 0))
cat = Cat()
location.additem(cat)
log = ["loglog", "log2"]
snapshot = Snapshot(WorldSnapshot(arena), cat.id, log)
stringed = snapshot_to_string(snapshot)
expected = "###\n#x#\n###\n" + "\n".join(log) + "\nHP: 10, Strength: 2"
self.assertEqual(expected, stringed)
示例4: TestArena
# 需要导入模块: from arena import Arena [as 别名]
# 或者: from arena.Arena import get_location [as 别名]
class TestArena(TestCase):
def setUp(self):
self.arena = Arena(12, 12)
def test_get_location(self):
self.arena.get_location(Point(1, 1)).additem('asdf')
self.arena.get_location(Point(1, 1)).removeitem('asdf')
def test_find_character(self):
self.arena.get_location(Point(1, 2)).additem('asdf')
self.assert_character_location(self.arena, 1, 2)
def test_move_item(self):
self.arena.get_location(Point(1, 2)).additem('asdf')
self.arena.move_item('asdf', Point(3, 5))
self.assert_character_location(self.arena, 3, 5)
def test_width_and_height(self):
arena = Arena(10, 4)
self.assertEqual(10, arena.width)
self.assertEqual(4, arena.height)
def test_copy(self):
self.arena.get_location(Point(1, 2)).additem('asdf')
copy = self.arena.copy()
copy.move_item('asdf', Point(3, 5))
self.assert_character_location(copy, 3, 5)
self.assert_character_location(self.arena, 1, 2)
def test_ingrid(self):
self.assertEqual(self.arena.in_grid(Point(-1, 0)), False)
self.assertEqual(self.arena.in_grid(Point(0, -1)), False)
self.assertEqual(self.arena.in_grid(Point(1, 0)), True)
self.assertEqual(self.arena.in_grid(Point(0, 4)), True)
self.assertEqual(self.arena.in_grid(Point(0, 5)), True)
self.assertEqual(self.arena.in_grid(Point(1, 12)), False)
self.assertEqual(self.arena.in_grid(Point(12, 1)), False)
def assert_character_location(self, arena, x, y):
found = arena.find_character('asdf')
self.assertEqual(found.x, x)
self.assertEqual(found.y, y)