本文整理汇总了Python中tale.base.Location.vnum方法的典型用法代码示例。如果您正苦于以下问题:Python Location.vnum方法的具体用法?Python Location.vnum怎么用?Python Location.vnum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tale.base.Location
的用法示例。
在下文中一共展示了Location.vnum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_location
# 需要导入模块: from tale.base import Location [as 别名]
# 或者: from tale.base.Location import vnum [as 别名]
def make_location(vnum):
"""
Get a Tale location object for the given circle room vnum.
This performs an on-demand conversion of the circle room data to Tale.
"""
try:
return converted_rooms[vnum] # get cached version if available
except KeyError:
c_room = rooms[vnum]
loc = Location(c_room.name, c_room.desc)
loc.vnum = vnum # keep the circle vnum
for ed in c_room.extradesc:
loc.add_extradesc(ed["keywords"], ed["text"])
converted_rooms[vnum] = loc
for circle_exit in c_room.exits.values():
if circle_exit.roomlink >= 0:
xt = make_exit(circle_exit)
while True:
try:
xt.bind(loc)
break
except LocationIntegrityError as x:
if x.direction in xt.aliases:
# circlemud exit keywords can be duplicated over various exits
# if we have a conflict, just remove the alias from the exit and try again
xt.aliases = xt.aliases - {x.direction}
continue
else:
if loc.exits[x.direction] is xt:
# this can occur, the exit is already bound
break
else:
# in this case a true integrity error occurred
raise
else:
# add the description of the inaccessible exit to the room's own description.
loc.description += " " + circle_exit.desc
return loc