本文整理汇总了Python中arena.Arena.in_grid方法的典型用法代码示例。如果您正苦于以下问题:Python Arena.in_grid方法的具体用法?Python Arena.in_grid怎么用?Python Arena.in_grid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arena.Arena
的用法示例。
在下文中一共展示了Arena.in_grid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestArena
# 需要导入模块: from arena import Arena [as 别名]
# 或者: from arena.Arena import in_grid [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)