Example #1
0
 def handle_verb(self, parsed: ParseResult, actor: Living) -> bool:
     pills = self.search_item("pills", include_location=False)
     if parsed.verb in ("bargain", "haggle"):
         if not parsed.args:
             raise ParseError("For how much money do you want to haggle?")
         if not pills:
             raise ActionRefused("It is no longer available for sale.")
         amount = mud_context.driver.moneyfmt.parse(parsed.args)
         price = mud_context.driver.moneyfmt.display(self.pills_price)
         if amount < self.pills_price / 2:
             actor.tell(
                 "%s glares angrily at you and says, \"No way! I want at least half the original price! "
                 "Did't I tell you? They were %s!\"" %
                 (lang.capital(self.title), price))
             raise ActionRefused()
         self.do_buy_pills(actor, pills, amount)
         return True
     if parsed.verb == "buy":
         if not parsed.args:
             raise ParseError("Buy what?")
         if "pills" in parsed.args or "bottle" in parsed.args or "medicine" in parsed.args:
             if not pills:
                 raise ActionRefused("It is no longer available for sale.")
             self.do_buy_pills(actor, pills, self.pills_price)
             return True
         if pills:
             raise ParseError(
                 "There's nothing left to buy in the shop, except for the pills the apothecary is holding."
             )
         else:
             raise ParseError("There's nothing left to buy.")
     return False
Example #2
0
    def handle_verb(self, parsed: ParseResult, actor: Living) -> bool:
        ammo = self.search_item("ammo", include_location=False)

        if parsed.verb == "buy":
            if not parsed.args:
                raise ParseError("Buy what?")
            if "ammo" in parsed.args or "bullets" in parsed.args:
                if not ammo:
                    raise ActionRefused("It is no longer available for sale.")
                self.do_buy_ammo(actor, ammo, self.ammo_price)
                return True
            if ammo:
                raise ParseError("The trader has ammo for your gun.")
            else:
                raise ParseError("There's nothing left to buy.")
        return False
Example #3
0
def go_cvnum(player: Player, parsed: ParseResult, ctx: util.Context) -> None:
    """Go to a specific circlemud room, given by its circle-vnum."""
    if len(parsed.args) != 1:
        raise ParseError("You have to give the rooms' circle-vnum.")
    vnum = int(parsed.args[0])
    try:
        room = make_location(vnum)
    except KeyError:
        raise ActionRefused("No room with that circle-vnum exists.")
    teleport_to(player, room)
Example #4
0
def go_vnum(player, parsed, ctx):
    """Go to a specific circlemud room, given by its vnum."""
    if len(parsed.args) != 1:
        raise ParseError("You have to give the rooms' vnum.")
    vnum = int(parsed.args[0])
    try:
        room = make_location(vnum)
    except KeyError:
        raise ActionRefused("No room with that vnum exists.")
    player.tell("Teleporting to room", room, "...")
    player.tell("\n")
    player.move(room, actor=player)
    player.look()
Example #5
0
 def handle_verb(self, parsed: ParseResult, actor: Living) -> bool:
     if parsed.verb in ("drive", "open", "enter", "sit", "use", "start"):
         if not parsed.args:
             raise ParseError("%s what?" % parsed.verb)
         if "yellow" not in parsed.args and "convertible" not in parsed.args:
             if "car" in parsed.args or "engine" in parsed.args:
                 raise ActionRefused("Most of the cars are locked. You should look for one that isn't.")
             raise ActionRefused("You cannot do that.")
         # check if Peter is with you
         if not self.search_living("Peter"):
             raise ActionRefused("Surely you wouldn't leave the town without your friend Peter! "
                                 "You should find him and get out here together!")
         # player drives the yellow car away from here together with her friend Peter, and thus the story ends!
         actor.tell_text_file(mud_context.resources["messages/completion_success.txt"])  # type: ignore
         raise StoryCompleted
     return False
Example #6
0
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)
Example #7
0
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)
Example #8
0
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.")
Example #9
0
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.")