Пример #1
0
    def func(self):
        ch = self.caller
        ch.msg(self.args)
        args = self.args.strip()
        objdb = dict(GLOBAL_SCRIPTS.objdb.vnum)

        if not objdb:
            ch.msg("There are no objects within the game")
            return

        if not args:
            table = self.styled_table("VNum",
                                      "Description",
                                      "Type",
                                      border='incols')
            objs = search_objdb('all')

            for vnum, obj in objs.items():
                data = objdb[vnum]
                vnum = raw_ansi(f"[|G{vnum:<4}|n]")
                sdesc = crop(raw_ansi(data['sdesc']), width=50) or ''
                table.add_row(vnum, sdesc, f"{data['type']}")

            msg = str(table)
            ch.msg(msg)
            return

        args = args.split(' ')
        if len(args) < 2:
            ch.msg("Supply either type or name to search for")
            return
        table = self.styled_table("VNum",
                                  "Description",
                                  "Type",
                                  border='incols')
        type_ = args[0]
        if type_ not in ('type', 'name'):
            ch.msg("Please supply either (type or name) to searchby")
            return

        criteria = args[1]

        try:
            extra_field, extra_criteria = args[2], args[3]
        except IndexError:
            extra_field = extra_criteria = None
        if extra_field and extra_criteria:
            objs = search_objdb(criteria, **{extra_field: extra_criteria})
        else:
            objs = search_objdb(criteria)
        for vnum, obj in objs.items():
            vnum = raw_ansi(f"[|G{vnum:<4}|n]")
            sdesc = crop(raw_ansi(obj['sdesc']), width=50) or ''
            table.add_row(vnum, sdesc, f"{obj['type']}")
        msg = str(table)
        ch.msg(msg)
        return
Пример #2
0
    def func(self):
        ch = self.caller
        ch.msg(self.args)
        args = self.args.strip()
        zonedb = dict(GLOBAL_SCRIPTS.zonedb.vnum)
        if not zonedb:
            ch.msg("There are no zones within the game")
            return

        vnum_zonedb = zonedb.keys()
        min_ = min(vnum_zonedb)
        max_ = max(vnum_zonedb)

        legend = ["VNum", "Name", "Builders"]
        try:
            _ = zonedb[1]
        except KeyError:
            ch.msg("No zones are saved to database, try creating one first")
            return

        if not args:
            table = self.styled_table(*legend, border='incols')

            for vnum in range(min_, max_ + 1):
                data = zonedb[vnum]
                vnum = raw_ansi(f"[|G{vnum:<4}|n]")
                table.add_row(vnum, data['name'],
                              list_to_string(data['builders']))

            msg = str(table)
            ch.msg(msg)
            return

        args = args.split(' ')
        if len(args) < 2:
            ch.msg("Supply name to search for")
            return
        table = self.styled_table(*legend, border='incols')
        type_ = args[0]
        if type_ not in ('name'):
            ch.msg("Please supply name to search by")
            return

        criteria = args[1]
        for vnum in range(min_, max_ + 1):
            # for vnum, data in GLOBAL_SCRIPTS.objdb.vnum.items():
            data = zonedb[vnum]
            if type_ == 'name':
                if match_string(criteria, data['name'].split()):
                    vnum = raw_ansi(f"[|G{vnum:<4}|n]")
                    table.add_row(vnum, data['name'],
                                  list_to_string(data['builders']))
                    continue
        msg = str(table)
        ch.msg(msg)
        return
Пример #3
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.")
Пример #4
0
 def func(self):
     """check inventory"""
     items = self.caller.contents
     if not items:
         string = "You are not carrying anything."
     else:
         from evennia.utils.ansi import raw as raw_ansi
         table = self.styled_table(border="header")
         for item in items:
             table.add_row(
                 f"|C{item.name}|n", "{}|n".format(
                     utils.crop(raw_ansi(item.db.desc), width=50) or ""))
         string = f"|wYou are carrying:\n{table}"
     self.caller.msg(string)
Пример #5
0
    def func(self):
        """check inventory"""
        items = self.caller.contents
        if not items:
            string = "Non stai trasportando nulla."
        else:
            from evennia.utils.ansi import raw as raw_ansi

            table = self.styled_table(border="header")
            for item in items:
                table.add_row(
                    f"|C{item.name}|n",
                    "{}|n".format(
                        utils.crop(raw_ansi(item.db.desc), width=50) or ""),
                )
            string = f"|wStai trasportando:\n{table}"
        self.caller.msg(string)
Пример #6
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)
Пример #7
0
    def func(self):
        ch = self.caller
        location = ch.location
        if not self.args:
            if not self:
                ch.msg("You have no location to look at!")
                return

            room_msg = ""

            # get room title
            room_msg += f"|c{location.db.name}|n\n"

            #get room_desc
            room_msg += f"|G{location.db.desc}|n\n\n"

            # get room exits
            room_msg += "|C[ Exits: "
            for direction, dvnum in location.db.exits.items():
                if dvnum < 0:
                    continue  # not set

                room_msg += f"|lc{direction}|lt{direction}|le "
            room_msg += "]|n\n\n"

            # get room contents
            # get objects
            for obj in sorted(location.contents,
                              key=lambda x: x.db.look_index):
                if is_pc(obj):
                    if obj.id == ch.id:
                        continue
                    room_msg += f"{obj.name.capitalize()}{obj.attrs.title.value} is {obj.attrs.position.value.name.lower()} here\n"

                elif is_npc(obj) and can_see_obj(ch, obj):
                    room_msg += f"{obj.db.ldesc}\n"

                elif is_obj(obj):
                    if is_invis(obj) and not can_see_obj(ch, obj):
                        ch.msg("Couldn't see")
                        continue
                    else:
                        room_msg += f"{obj.obj_desc(ldesc=True)}\n"
            ch.msg(room_msg)
            return

        args = self.args.strip().split()
        # attempt to look at something specific in the room

        # try looking for obj in room based on name or aliases

        if len(args) == 1:
            obj_name = args[0]

            # attempt to look for edesc in room itself
            edesc = location.db.edesc
            if obj_name in edesc.keys():
                msg = f"\n\n{rplanguage_parse_string(ch, edesc[obj_name])}"
                evmore.EvMore(ch, msg)
                return
            # look for obj in room
            for obj in ch.location.contents:
                if is_obj(obj):
                    if obj_name in obj.db.name:
                        edesc = rplanguage_parse_string(ch, obj.db.edesc)
                        ch.msg(f"You look at {obj.db.sdesc}\n{edesc}")
                        return
                elif is_npc(obj):
                    if obj_name in obj.db.key:
                        edesc = rplanguage_parse_string(ch, obj.db.edesc)
                        ch.msg(f"You look at {obj.db.sdesc}\n{edesc}")
                        return

                elif is_pc(obj):
                    if obj_name in obj.name:
                        edesc = rplanguage_parse_string(ch, obj.db.desc)
                        ch.msg(f"You look at {obj.full_title()}\n{edesc}")
                        return
            # try looking for an obj in your inventory, if found send back edesc
            for obj in ch.contents:
                if is_equipped(obj):
                    continue
                if match_name(obj_name, obj):
                    edesc = obj.db.edesc
                    if not edesc:
                        ch.msg("You see nothing interesting.")
                    else:
                        edesc = rplanguage_parse_string(ch, edesc)
                        ch.msg(edesc)
                    return
            ch.msg("You don't see anything like that.")
            return

        if len(args) == 2:
            _filler, con_name = args
            if _filler != 'in':
                ch.msg("Supply `in` when looking in a container")
                return
            pos, con_name = parse_dot_notation(con_name)

            cntr = 1
            locs = [ch, ch.location]
            for loc in locs:
                for obj in loc.contents:
                    if not is_container(obj):
                        continue
                    if match_name(con_name, obj) and (cntr == pos or not pos):
                        # found container; display contents, sorted
                        objs = list(obj.contents)
                        objs.sort(key=lambda x: x.db.sdesc.lower())
                        table = self.styled_table(border="header")
                        for item in objs:
                            if not can_see_obj(ch, item):
                                sdesc = "<something>"
                            else:
                                sdesc = f"{item.obj_desc()}"
                            table.add_row("{}|n".format(raw_ansi(sdesc)))
                        extra = "" if not is_pc_npc(
                            loc) else ", that you are holding,"
                        string = f"|w{obj.db.sdesc}{extra} has:\n{table}"
                        ch.msg(string)
                        return
                    cntr += 1
            ch.msg("You couldn't find anything like that.")
Пример #8
0
    def func(self):
        ch = self.caller
        ch.msg(self.args)
        args = self.args.strip()
        roomdb = dict(GLOBAL_SCRIPTS.roomdb.vnum)
        if not roomdb:
            ch.msg("There are no rooms within the game")
            return

        vnum_roomdb = roomdb.keys()
        min_ = min(vnum_roomdb)
        max_ = max(vnum_roomdb)

        legend = ["VNum", "Name", "Exits", "Zone"]
        try:
            _ = roomdb[1]
        except KeyError:
            ch.msg("No rooms are saved to database, try creating one first")
            return

        if not args:
            table = self.styled_table(*legend, border='incols')
            ch_zone = has_zone(ch)

            if ch_zone:
                for vnum in range(min_, max_ + 1):
                    data = roomdb[vnum]
                    if match_string(ch_zone, make_iter(data['zone'])):
                        exits = {
                            k: v
                            for k, v in data['exits'].items() if v > 0
                        }
                        vnum = raw_ansi(f"[|G{vnum:<4}|n]")
                        sdesc = crop(raw_ansi(data['name']), width=50) or ''
                        table.add_row(vnum, sdesc, f"{exits}", data['zone'])
            else:
                for vnum in range(min_, max_ + 1):
                    data = roomdb[vnum]
                    exits = {k: v for k, v in data['exits'].items() if v > 0}
                    vnum = raw_ansi(f"[|G{vnum:<4}|n]")
                    sdesc = crop(raw_ansi(data['name']), width=50) or ''
                    table.add_row(vnum, sdesc, f"{exits}", data['zone'])

            msg = str(table)
            ch.msg(msg)
            return

        args = args.split(' ')
        if len(args) < 2:
            ch.msg("Supply either type or name to search for")
            return
        table = self.styled_table(*legend, border='incols')
        type_ = args[0]
        if type_ not in ('zone', 'name'):
            ch.msg("Please supply either (type or name) to searchby")
            return

        criteria = args[1]
        for vnum in range(min_, max_ + 1):
            # for vnum, data in GLOBAL_SCRIPTS.objdb.vnum.items():
            data = roomdb[vnum]
            if type_ == 'zone':
                if match_string(criteria, make_iter(data['zone'])):
                    exits = {k: v for k, v in data['exits'].items() if v > 0}

                    vnum = raw_ansi(f"[|G{vnum:<4}|n]")
                    sdesc = crop(raw_ansi(data['name']), width=50) or ''
                    table.add_row(vnum, sdesc, f"{exits}", data['zone'])
                    continue

            if type_ == 'name':
                if match_string(criteria, data['name'].split()):
                    exits = {k: v for k, v in data['exits'].items() if v > 0}

                    vnum = raw_ansi(f"[|G{vnum:<4}|n]")
                    sdesc = crop(raw_ansi(data['name']), width=50) or ''
                    table.add_row(vnum, sdesc, f"{exits}", data['zone'])
                    continue
        msg = str(table)
        ch.msg(msg)
        return