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


Python Player.remove方法代码示例

本文整理汇总了Python中tale.player.Player.remove方法的典型用法代码示例。如果您正苦于以下问题:Python Player.remove方法的具体用法?Python Player.remove怎么用?Python Player.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tale.player.Player的用法示例。


在下文中一共展示了Player.remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_with_key

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import remove [as 别名]
 def test_with_key(self):
     player = Player("julie", "f")
     key = Key("key", "door key")
     key.key_for(code=12345)
     hall = Location("hall")
     door = Door("north", hall, "a locked door", locked=True, opened=False)
     door2 = Door("south", hall, "another locked door", locked=True, opened=False)
     with self.assertRaises(ActionRefused):
         door.unlock(player)
     with self.assertRaises(ActionRefused):
         door.unlock(player, key)
     door.key_code = 12345
     door2.key_code = 9999
     key.key_for(door)
     self.assertTrue(door.locked)
     door.unlock(player, key)
     self.assertFalse(door.locked)
     with self.assertRaises(ActionRefused):
         door2.unlock(key)
     door.locked = True
     with self.assertRaises(ActionRefused):
         door.unlock(player)
     key.move(player, player)
     door.unlock(player)
     self.assertFalse(door.locked)
     door.lock(player)
     self.assertTrue(door.locked)
     door.unlock(player)
     player.remove(key, player)
     with self.assertRaises(ActionRefused):
         door.lock(player)
     door.key_code = None
     with self.assertRaises(LocationIntegrityError):
         key.key_for(door)
开发者ID:MitsuharuEishi,项目名称:Tale,代码行数:36,代码来源:test_mudobjects.py

示例2: test_custom_verbs

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import remove [as 别名]
    def test_custom_verbs(self):
        player = Player("julie", "f")
        player.verbs["xywobble"] = "p1"
        room = Location("room")
        chair1 = Item("chair1")
        chair1.verbs["frobnitz"] = "c1"
        chair2 = Item("chair2")
        chair2.verbs["frobnitz"] = "c2"
        chair_in_inventory = Item("chair3")
        chair_in_inventory.verbs["kowabooga"] = "c3"
        room.init_inventory([chair1, player, chair2])

        # check inventory NOT affecting player custom verbs, but DOES affect location verbs
        self.assertEqual({"xywobble": "p1"}, player.verbs)
        self.assertEqual({"frobnitz": "c2", "xywobble": "p1"}, room.verbs)
        player.insert(chair_in_inventory, player)
        self.assertEqual({"xywobble": "p1"}, player.verbs)
        self.assertEqual({"frobnitz": "c2", "xywobble": "p1", "kowabooga": "c3"}, room.verbs)
        player.remove(chair_in_inventory, player)
        self.assertEqual({"frobnitz": "c2", "xywobble": "p1"}, room.verbs)

        player.insert(chair_in_inventory, player)
        self.assertEqual({"frobnitz": "c2", "xywobble": "p1", "kowabooga": "c3" }, room.verbs)
        room2 = Location("room2")
        self.assertEqual({}, room2.verbs)
        chair1.move(room2, player)
        self.assertEqual({"xywobble": "p1", "kowabooga": "c3" }, room.verbs)
        self.assertEqual({"frobnitz": "c1"}, room2.verbs)
        chair2.move(room2, player)
        self.assertEqual({"xywobble": "p1", "kowabooga": "c3"}, room.verbs)
        self.assertEqual({"frobnitz": "c2"}, room2.verbs)
        player.move(room2)
        self.assertEqual({}, room.verbs)
        self.assertEqual({"frobnitz": "c2", "xywobble": "p1", "kowabooga": "c3"}, room2.verbs)
开发者ID:jordanaycamara,项目名称:Tale,代码行数:36,代码来源:test_mudobjects.py

示例3: test_clone

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import remove [as 别名]
 def test_clone(self):
     item = Item("thing", "description")
     item.aliases = ["a1", "a2"]
     item2 = clone(item)
     self.assertNotEqual(item, item2)
     item2.aliases.append("a3")
     self.assertNotEqual(item.aliases, item2.aliases)
     player = Player("julie", "f")
     player.insert(item, player)
     with self.assertRaises(ValueError):
         clone(player)   # can't clone something with stuff in it
     player.remove(item, player)
     player2 = clone(player)
     player2.insert(item2, player2)
     self.assertNotEqual(player.inventory_size, player2.inventory_size)
     self.assertNotEqual(player.inventory, player2.inventory)
     self.assertFalse(item in player)
     self.assertFalse(item in player2)
开发者ID:MitsuharuEishi,项目名称:Tale,代码行数:20,代码来源:test_mudobjects.py


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