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


Python Player.move方法代码示例

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


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

示例1: test_socialize

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import move [as 别名]
 def test_socialize(self):
     player = Player("fritz", "m")
     attic = Location("Attic", "A dark attic.")
     julie = NPC("julie", "f")
     julie.move(attic)
     player.move(attic)
     parsed = player.parse("wave all")
     self.assertEqual("wave", parsed.verb)
     self.assertEqual([julie], parsed.who_order)
     who, playermsg, roommsg, targetmsg = player.soul.process_verb_parsed(player, parsed)
     self.assertEqual({julie}, who)
     self.assertEqual("You wave happily at julie.", playermsg)
     with self.assertRaises(tale.soul.UnknownVerbException):
         player.parse("befrotzificate all and me")
     with self.assertRaises(NonSoulVerb) as x:
         player.parse("befrotzificate all and me", external_verbs={"befrotzificate"})
     parsed = x.exception.parsed
     self.assertEqual("befrotzificate", parsed.verb)
     self.assertEqual([julie, player], parsed.who_order)
     attic.add_exits([Exit("south", "target", "door")])
     try:
         player.parse("push south")
         self.fail("push south should throw a parse error because of the exit that is used")
     except ParseError:
         pass
     with self.assertRaises(NonSoulVerb):
         player.parse("fart south")
     parsed = player.parse("hug julie")
     player.validate_socialize_targets(parsed)
开发者ID:MitsuharuEishi,项目名称:Tale,代码行数:31,代码来源:test_player.py

示例2: test_move_notify

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import move [as 别名]
    def test_move_notify(self):
        class LocationNotify(Location):
            def notify_npc_left(self, npc, target_location):
                self.npc_left = npc
                self.npc_left_target = target_location

            def notify_npc_arrived(self, npc, previous_location):
                self.npc_arrived = npc
                self.npc_arrived_from = previous_location

            def notify_player_left(self, player, target_location):
                self.player_left = player
                self.player_left_target = target_location

            def notify_player_arrived(self, player, previous_location):
                self.player_arrived = player
                self.player_arrived_from = previous_location

        player = Player("julie", "f")
        room1 = LocationNotify("room1")
        room2 = LocationNotify("room2")
        room1.insert(player, player)
        player.move(room2)
        pubsub.sync()
        self.assertEqual(room2, player.location)
        self.assertEqual(player, room1.player_left)
        self.assertEqual(room2, room1.player_left_target)
        self.assertEqual(player, room2.player_arrived)
        self.assertEqual(room1, room2.player_arrived_from)
开发者ID:MitsuharuEishi,项目名称:Tale,代码行数:31,代码来源:test_player.py

示例3: test_wiretap

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import move [as 别名]
 def test_wiretap(self):
     attic = Location("Attic", "A dark attic.")
     player = Player("fritz", "m")
     io = ConsoleIo(None)
     io.supports_smartquotes = False
     pc = PlayerConnection(player, io)
     player.set_screen_sizes(0, 100)
     julie = NPC("julie", "f")
     julie.move(attic)
     player.move(attic)
     julie.tell("message for julie")
     attic.tell("message for room")
     self.assertEqual(["message for room\n"], player.test_get_output_paragraphs())
     with self.assertRaises(ActionRefused):
         player.create_wiretap(julie)
     player.privileges = {"wizard"}
     player.create_wiretap(julie)
     player.create_wiretap(attic)
     julie.tell("message for julie")
     attic.tell("message for room")
     pubsub.sync()
     output = pc.get_output()
     self.assertTrue("[wiretapped from 'Attic': message for room]" in output)
     self.assertTrue("[wiretapped from 'julie': message for julie]" in output)
     self.assertTrue("[wiretapped from 'julie': message for room]" in output)
     self.assertTrue("message for room " in output)
     # test removing the wiretaps
     player.clear_wiretaps()
     import gc
     gc.collect()
     julie.tell("message for julie")
     attic.tell("message for room")
     self.assertEqual(["message for room\n"], player.test_get_output_paragraphs())
开发者ID:MitsuharuEishi,项目名称:Tale,代码行数:35,代码来源:test_player.py

示例4: test_custom_verbs

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import move [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

示例5: test_look

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import move [as 别名]
 def test_look(self):
     player = Player("fritz", "m")
     attic = Location("Attic", "A dark attic.")
     player.look()
     self.assertEqual(["[Limbo]\n", "The intermediate or transitional place or state. There's only nothingness.\nLiving beings end up here if they're not in a proper location yet.\n"], player.test_get_output_paragraphs())
     player.move(attic, silent=True)
     player.look(short=True)
     self.assertEqual(["[Attic]\n"], player.test_get_output_paragraphs())
     julie = NPC("julie", "f")
     julie.move(attic, silent=True)
     player.look(short=True)
     self.assertEqual(["[Attic]\n", "Present: julie\n"], player.test_get_output_paragraphs())
开发者ID:MitsuharuEishi,项目名称:Tale,代码行数:14,代码来源:test_player.py

示例6: test_others

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import move [as 别名]
 def test_others(self):
     attic = Location("Attic", "A dark attic.")
     player = Player("merlin", "m")
     player.title = "wizard Merlin"
     julie = MsgTraceNPC("julie", "f", "human")
     fritz = MsgTraceNPC("fritz", "m", "human")
     julie.move(attic, silent=True)
     fritz.move(attic, silent=True)
     player.move(attic, silent=True)
     player.tell_others("one", "two", "three")
     self.assertEqual([], player.test_get_output_paragraphs())
     self.assertEqual(["one", "two", "three"], fritz.messages)
     self.assertEqual(["one", "two", "three"], julie.messages)
     fritz.clearmessages()
     julie.clearmessages()
     player.tell_others("{title} and {Title}")
     self.assertEqual(["wizard Merlin and Wizard Merlin"], fritz.messages)
开发者ID:MitsuharuEishi,项目名称:Tale,代码行数:19,代码来源:test_player.py

示例7: test_look_brief

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import move [as 别名]
 def test_look_brief(self):
     player = Player("fritz", "m")
     attic = Location("Attic", "A dark attic.")
     cellar = Location("Cellar", "A gloomy cellar.")
     julie = NPC("julie", "f")
     julie.move(attic, silent=True)
     player.move(attic, silent=True)
     player.brief = 0  # default setting: always long descriptions
     player.look()
     self.assertEqual(["[Attic]\n", "A dark attic.\n", "Julie is here.\n"], player.test_get_output_paragraphs())
     player.look()
     self.assertEqual(["[Attic]\n", "A dark attic.\n", "Julie is here.\n"], player.test_get_output_paragraphs())
     player.look(short=True)   # override
     self.assertEqual(["[Attic]\n", "Present: julie\n"], player.test_get_output_paragraphs())
     player.brief = 1  # short for known, long for new locations
     player.look()
     self.assertEqual(["[Attic]\n", "Present: julie\n"], player.test_get_output_paragraphs())
     player.move(cellar, silent=True)
     player.look()
     self.assertEqual(["[Cellar]\n", "A gloomy cellar.\n"], player.test_get_output_paragraphs())
     player.look()
     self.assertEqual(["[Cellar]\n"], player.test_get_output_paragraphs())
     player.brief = 2  # short always
     player.known_locations.clear()
     player.look()
     self.assertEqual(["[Cellar]\n"], player.test_get_output_paragraphs())
     player.move(attic, silent=True)
     player.look()
     self.assertEqual(["[Attic]\n", "Present: julie\n"], player.test_get_output_paragraphs())
     player.look(short=True)   # override
     self.assertEqual(["[Attic]\n", "Present: julie\n"], player.test_get_output_paragraphs())
     player.look(short=False)  # override
     self.assertEqual(["[Attic]\n", "A dark attic.\n", "Julie is here.\n"], player.test_get_output_paragraphs())
开发者ID:MitsuharuEishi,项目名称:Tale,代码行数:35,代码来源:test_player.py


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