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


Python Arena.get_location方法代码示例

本文整理汇总了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)
开发者ID:robobario,项目名称:aquatic-hand,代码行数:10,代码来源:test_snapshotToString.py

示例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)
开发者ID:robobario,项目名称:aquatic-hand,代码行数:11,代码来源:test_snapshotToString.py

示例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)
开发者ID:robobario,项目名称:aquatic-hand,代码行数:12,代码来源:test_snapshotToString.py

示例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)
开发者ID:robobario,项目名称:aquatic-hand,代码行数:44,代码来源:test_arena.py


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