def show_vnum(player, parsed, ctx): """Show the vnum of a location (.) or an object/living, or when you provide a vnum as arg, show the object(s) with that vnum.""" if not parsed.args: raise ParseError("From what should I show the vnum?") name = parsed.args[0] if name == ".": obj = player.location elif parsed.who_order: obj = parsed.who_order[0] else: try: vnum = int(parsed.args[0]) except ValueError as x: raise ActionRefused(str(x)) objects = [] try: objects.append(make_item(vnum)) except KeyError: pass try: objects.append(make_location(vnum)) except KeyError: pass try: objects.append(make_mob(vnum)) except KeyError: pass player.tell("Objects with vnum %d:" % vnum, lang.join(str(o) for o in objects)) return try: vnum = obj.vnum player.tell("Vnum of %s = %d." % (obj, vnum)) except AttributeError: player.tell(obj, "has no vnum.")
def spawn_vnum(player, parsed, ctx): """Spawn an item or monster with the given vnum""" if len(parsed.args) != 1: raise ParseError("You have to give the rooms' vnum.") vnum = int(parsed.args[0]) spawned = [] try: spawned.append(make_item(vnum)) except KeyError: pass try: spawned.append(make_mob(vnum)) except KeyError: pass for obj in spawned: player.tell("Spawned", obj) obj.move(player.location, actor=player)
def spawn_cvnum(player: Player, parsed: ParseResult, ctx: util.Context) -> None: """Spawn an item or monster with the given circle-vnum (or both if the circle-vnum is the same).""" if len(parsed.args) != 1: raise ParseError("You have to give the item or monster's circle-vnum.") vnum = int(parsed.args[0]) try: item = make_item(vnum) except KeyError: player.tell("There's no item with that circle-vnum.") else: player.tell("Spawned " + repr(item) + " (into your inventory)") item.move(player, actor=player) try: mob = make_mob(vnum) except KeyError: player.tell("There's no monster with that circle-vnum.") else: player.tell("Spawned " + repr(mob) + " (into your current location)") mob.move(player.location, actor=player)
def show_cvnum(player: Player, parsed: ParseResult, ctx: util.Context) -> None: """Show the circle-vnum of a location (.) or an object/living, or when you provide a circle-vnum as arg, show the object(s) with that circle-vnum.""" if not parsed.args: raise ParseError("From what should I show the circle-vnum?") name = parsed.args[0] obj = None # type: Union[Location, Living, Item, Exit] if name == ".": obj = player.location elif parsed.who_info: obj = parsed.who_1 else: try: vnum = int(parsed.args[0]) except ValueError as x: raise ActionRefused(str(x)) objects = [] # type: List[Union[Location, Living, Item, Exit]] try: objects.append(make_item(vnum)) except KeyError: pass try: objects.append(make_location(vnum)) except KeyError: pass try: objects.append(make_mob(vnum)) except KeyError: pass player.tell("Objects with circle-vnum %d:" % vnum + " " + (lang.join(str(o) for o in objects) or "none")) return try: vnum = obj.circle_vnum player.tell("Circle-Vnum of %s = %d." % (obj, vnum)) except AttributeError: player.tell(str(obj) + " has no circle-vnum.")