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