示例#1
0
    def func(self):
        ch = self.caller
        if not self.args:
            ch.msg("What do you want to remove?")
            return

        obj_name = self.args.strip()

        success_remove = False
        for obj in ch.contents:
            if is_equippable(obj) and is_worn(obj) and not is_cursed(obj):
                # equipment
                if obj_name == 'all':
                    ch.equipment.remove(obj)
                    success_remove = True
                elif match_name(obj_name, obj):
                    ch.equipment.remove(obj)
                    return

            elif is_wieldable(obj) and is_wielded(obj) and not is_cursed(obj):
                # weapon
                if obj_name == 'all':
                    ch.equipment.unwield(obj)
                    success_remove = True

                elif match_name(obj_name, obj):
                    ch.equipment.unwield(obj)
                    return

        if not success_remove:
            ch.msg("You can't remove that")
示例#2
0
    def func(self):
        ch = self.caller
        args = self.args.strip()
        table = self.styled_table("Contents")

        if not args:
            ch.msg("You peek at yourself")
            for obj in ch.contents:
                table.add_row(obj.db.sdesc)

            ch.msg(table)
            return
        for obj in ch.location.contents:
            if is_pc_npc(obj) and match_name(args, obj):
                items = list(obj.contents)
                items.sort(key=lambda x: x.db.sdesc.lower())

                for item in items:
                    if is_worn(item) or is_wielded(item):
                        continue

                    if not can_see_obj(ch, item):
                        continue

                    table.add_row(raw_ansi(item.obj_desc()))
                ch.msg(f"You peek into {get_name(obj)}'s inventory")
                ch.msg(table)
                return
        ch.msg("You couldn't find anyone like that.")
示例#3
0
    def __init__(self, caller):
        self.caller = caller
        self.location = {}
        self.loc_help_msg = {}

        for loc in self._valid_wear_loc:
            self.location[loc.name] = None  # obj

        # now try to find objects in caller.location
        # that are 1) is_equippable and 2)is_worn
        for obj in self.caller.contents:
            if is_equippable(obj) and is_worn(obj):
                self.location[obj.db.wear_loc] = obj
示例#4
0
    def func(self):
        ch = self.caller

        if not self.args:
            ch.msg("What do you want to wear?")
            return

        args = self.args.strip()
        if args == 'all':
            for obj in ch.contents:
                if is_equippable(
                        obj) and not is_worn(obj) and not is_weapon(obj):
                    ch.equipment.add(obj)
            return
        for obj in ch.contents:
            if is_equippable(obj) and not is_worn(obj) and not is_weapon(obj):
                # this object is a potential candidate
                if match_name(args, obj):
                    # we have a match!
                    ch.equipment.add(obj)
                    return
        ch.msg("You couldn't find anything like that to wear")
示例#5
0
    def func(self):
        """check inventory"""
        ch = self.caller
        items = list(ch.contents)
        if not items:
            string = "You are not carrying anything."
        else:

            items.sort(key=lambda x: x.db.sdesc.lower())
            table = self.styled_table(border="header")
            for item in items:
                if is_worn(item) or is_wielded(item):
                    continue

                if not can_see_obj(ch, item):
                    sdesc = "<something>"
                else:
                    sdesc = f"{item.obj_desc()}"
                table.add_row("{}|n".format(raw_ansi(sdesc)))
            string = f"|wYou are carrying:\n{table}"
        ch.msg(string)