Пример #1
0
 def disp_rumors(self, caller, rumors, add_heard=True):
     table = evtable.EvTable("{w#{n", "{wTopic{n", "{w%s{n" % self.key.capitalize(),
                             border="cells", width=78, align="l", justify=True)
     x = 0
     week = get_week()
     heard_rumors = caller.ndb.heard_rumors or []
     for rumor in rumors:
         x += 1
         player = rumor.db_receivers_players.all()
         if not player:
             continue
         player = player[0].key.capitalize()[:12]
         table.add_row(x, player, rumor.db_message)
         if add_heard and rumor not in heard_rumors:
             heard_rumors.append(rumor)
     table.reformat_column(0, width=5)
     table.reformat_column(1, width=12)
     table.reformat_column(2, width=61)
     if add_heard:
         caller.ndb.heard_rumors = heard_rumors
     msg = "{w%s{n" % self.key.capitalize().center(78)
     msg += "\n"
     msg += str(table)
     stories = AssignedTask.objects.filter(finished=True, week__gte=week-3, observer_text__isnull=False)
     if stories:
         msg += "\n"
         msg += "{wOther Rumors{n".center(78)
         msg += "\n"
         table = evtable.EvTable("{wRumored Story #{n", "{wWeek{n", border="cells", width=78)
         for story in stories:
             table.add_row(story.id, story.week)
         msg += str(table)
     return arx_more.msg(caller, msg, justify_kwargs=False)
Пример #2
0
 def disp_rumors(self, caller, rumors, add_heard=True):
     table = evtable.EvTable("{w#{n", "{w%s{n" % self.key.capitalize(),
                             border="cells", width=78, align="l", justify=True)
     x = 0
     heard_rumors = caller.ndb.heard_rumors or []
     week = get_week()
     for rumor in rumors:
         now = time_now()
         if (now - rumor.db_date_created).days > RUMOR_LIFETIME:
             continue
         x += 1
         table.add_row(x, rumor.db_message)
         if add_heard and rumor not in heard_rumors:
             heard_rumors.append(rumor)
     if add_heard:
         caller.ndb.heard_rumors = heard_rumors
     msg = "{w%s{n" % self.key.capitalize().center(78)
     msg += "\n"
     msg += str(table)
     stories = AssignedTask.objects.filter(finished=True, week__gte=week-3, observer_text__isnull=False)
     if stories:
         msg += "\n"
         msg += "{wOther Rumors{n".center(78)
         msg += "\n"
         table = evtable.EvTable("{wRumored Story #{n", "{wWeek{n", border="cells", width=78)
         for story in stories:
             table.add_row(story.id, story.week)
         msg += str(table)
     return arx_more.msg(caller, msg, justify_kwargs=False)
Пример #3
0
    def func(self):
        """
        check inventory, listing carried and worn items,
        and optionally, their weight.
        """
        you = self.character
        items = you.contents
        items_not_worn = []

        wear_table = evtable.EvTable(border="header")
        for item in items:
            if item.db.worn:
                wear_table.add_row("|C%s|n" % item.name, item.db.desc or "")
            else:
                items_not_worn.append(item)
        mass = you.traits.mass.actual if you.traits.mass else 0
        table = evtable.EvTable(border='header')
        for item in items_not_worn:
            i_mass = mass_unit(item.get_mass()) if hasattr(item,
                                                           'get_mass') else 0
            second = '(|y%s|n) ' % i_mass if 'weight' in self.switches else ''
            second += item.db.desc_brief or item.db.desc or ''
            table.add_row(
                '%s' % item.get_display_name(you.sessions,
                                             mxp=('sense %s' % item.key)),
                second or '')
        my_mass, my_total_mass = [
            mass, you.get_mass() if hasattr(you, 'get_mass') else 0
        ]
        string = "|wYou (%s) and your possessions (%s) total |y%s|n:\n%s" %\
                 (mass_unit(mass), mass_unit(my_total_mass - my_mass),
                  mass_unit(my_total_mass), table)
        if not wear_table.nrows == 0:
            string += "|/|wYou are wearing:\n%s" % wear_table
        you.msg(string)
Пример #4
0
def list_settings(keys):
    """
    Display the server settings. We only display the Evennia specific
    settings here. The result will be printed to the terminal.

    Args:
        keys (str or list): Setting key or keys to inspect.

    """
    from importlib import import_module
    from evennia.utils import evtable

    evsettings = import_module(SETTINGS_DOTPATH)
    if len(keys) == 1 and keys[0].upper() == "ALL":
        # show a list of all keys
        # a specific key
        table = evtable.EvTable()
        confs = [key for key in sorted(evsettings.__dict__) if key.isupper()]
        for i in range(0, len(confs), 4):
            table.add_row(*confs[i:i + 4])
    else:
        # a specific key
        table = evtable.EvTable(width=131)
        keys = [key.upper() for key in keys]
        confs = dict((key, var) for key, var in evsettings.__dict__.items()
                     if key in keys)
        for key, val in confs.items():
            table.add_row(key, str(val))
    print(table)
Пример #5
0
    def func(self):
        """check inventory"""
        if not self.caller.contents:
            # JI (12/7/19) Adapted to Latin
            self.caller.msg("Tū rēs neque habēs neque geris.")
            return

        items = self.caller.contents

        carry_table = evtable.EvTable(border="header")
        wear_table = evtable.EvTable(border="header")
        for item in items:
            if not item.db.geritur:
                if item.db.is_burning:
                    glowing = f"|y(ard{'ēns' if item.db.sexus == 'neutrum' else 'entem'})|n |C{item.db.formae['acc_sg'][0]}|n"
                    carry_table.add_row(
                        f"{ardēns} {'(dextrā)' if item.db.tenētur == 'dextrā' else '(sinistrā)'} {item.db.desc or ''}"
                    )
                else:
                    carry_table.add_row(
                        "|C%s|n" % item.db.formae['acc_sg'][0], '(dextrā)'
                        if item.db.tenētur == 'dextrā' else '(sinistrā)',
                        item.db.desc or "")
        if carry_table.nrows == 0:
            carry_table.add_row("|CNihil.|n", "")
        string = "|wTenēs:\n%s" % carry_table
        for item in items:
            if item.db.geritur:
                wear_table.add_row("|C%s|n" % item.db.formae['acc_sg'][0],
                                   item.db.desc or "")
        if wear_table.nrows == 0:
            wear_table.add_row("|CNihil.|n", "")
        string += "|/|wGeris:\n%s" % wear_table
        self.caller.msg(string)
Пример #6
0
def card_detail(card):
    keys = list(card.keys())
    keys.sort()
    cardrarity = cardsystem.RARITIES[card['Rarity']]
    color = cardsystem.ELEMENTS[card['Element']]['Color']
    cardstats = [evtable.EvColumn(align='r'),evtable.EvColumn(align='l')]
    for key in keys:
        if key not in ['Effect', 'Detail', 'Name', 'Inherits', 'AI', 'CardString', 'Loot', 'Create', 'AttackMultiplier', 'DefenseMultiplier']:
            cardstats[0].add_rows(key)
            cardstats[1].add_rows(card[key])

    cardstatsdisplay = evtable.EvTable(table=cardstats, border='incols', header=False, width=23)
    effect = card.get('Detail', card.get('Effect', ''))
    cardeffect = evtable.EvTable(table=[[f"|hEffect: |n{effect}"]],
                                border=None,
                                header=False,
                                 width=24,
                                )
    cardinterior = evtable.EvTable(header=False, table=[[cardstatsdisplay],[cardeffect]], border='incols')
    cardfmt = evtable.EvTable(card['Name'],
                              table=[[cardinterior]],
                              width=55,
                              pad_width=0,
                              border='cells',
                              corner_char=f'|{color}+|n',
                              border_left_char=f"|{color}{cardrarity['left_border']}|n",
                              border_right_char=f"|{color}{cardrarity['right_border']}|n",
                              border_top_char=f"|{color}{cardrarity['top_border']}|n",
                              border_bottom_char=f"|{color}{cardrarity['bottom_border']}|n",
                              align='c'
                              )
    return cardfmt
Пример #7
0
    def func(self):
        """check inventory"""
        if not self.caller.contents:
            # JI (12/7/19) Adapted to Latin
            self.caller.msg("Res neque habes neque geris.")
            return

        items = self.caller.contents

        carry_table = evtable.EvTable(border="header")
        wear_table = evtable.EvTable(border="header")
        for item in items:
            if not item.db.worn:
                if item.db.is_glowing:
                    glowing = f"|y(arden{'s' if item.db.gender == 3 else 'tem'})|n |C{item.db.acc_sg[0]}|n"
                    carry_table.add_row(
                        f"{glowing} {'(dextra)' if item.db.held == 'right' else '(sinistra)'} {item.db.desc or ''}"
                    )
                else:
                    carry_table.add_row(
                        "|C%s|n" % item.db.acc_sg[0], '(dextra)'
                        if item.db.held == 'right' else '(sinistra)',
                        item.db.desc or "")
        if carry_table.nrows == 0:
            carry_table.add_row("|CNihil.|n", "")
        string = "|wTenes:\n%s" % carry_table
        for item in items:
            if item.db.worn:
                wear_table.add_row("|C%s|n" % item.db.acc_sg[0], item.db.desc
                                   or "")
        if wear_table.nrows == 0:
            wear_table.add_row("|CNihil.|n", "")
        string += "|/|wGeris:\n%s" % wear_table
        self.caller.msg(string)
Пример #8
0
    def func(self):
        """
        Get all connected players by polling session.
        """

        player = self.player
        session_list = SESSIONS.get_sessions()

        session_list = sorted(session_list, key=lambda o: o.player.key)

        if self.cmdstring == "doing":
            show_session_data = False
        else:
            show_session_data = player.check_permstring(
                "Immortals") or player.check_permstring("Wizards")

        nplayers = (SESSIONS.player_count())
        if show_session_data:
            # privileged info
            table = evtable.EvTable("|wPlayer Name", "|wOn for", "|wIdle",
                                    "|wPuppeting", "|wRoom", "|wCmds",
                                    "|wProtocol", "|wHost")
            for session in session_list:
                if not session.logged_in:
                    continue
                delta_cmd = time.time() - session.cmd_last_visible
                delta_conn = time.time() - session.conn_time
                player = session.get_player()
                puppet = session.get_puppet()
                location = puppet.location.key if puppet and puppet.location else "None"
                table.add_row(
                    utils.crop(player.name, width=25),
                    utils.time_format(delta_conn, 0),
                    utils.time_format(delta_cmd, 1),
                    utils.crop(puppet.key if puppet else "None", width=25),
                    utils.crop(location, width=25), session.cmd_total,
                    session.protocol_key,
                    isinstance(session.address, tuple) and session.address[0]
                    or session.address)
        else:
            # unprivileged
            table = evtable.EvTable("|wCharacter name", "|wOn for", "|wIdle")
            for session in session_list:
                if not session.logged_in:
                    continue
                delta_cmd = time.time() - session.cmd_last_visible
                delta_conn = time.time() - session.conn_time
                player = session.get_player()
                puppet = session.get_puppet(
                )  # Gonna use this instead of the first one.
                if puppet:
                    table.add_row(
                        utils.crop(puppet.key,
                                   width=25),  #player.key.was player.name
                        utils.time_format(delta_conn, 0),
                        utils.time_format(delta_cmd, 1))
        is_one = nplayers == 1
        self.msg("|wPlayers:|n\n%s\n%s unique account%s logged in." %
                 (table, "One" if is_one else nplayers, "" if is_one else "s"))
Пример #9
0
def carduser_desc(obj, looker=None):
    if obj.db.desc:
        desc = obj.db.desc
    else:
        desc = ""
    desctable = evtable.EvTable(table=[[desc]], border=None, header=False, width=50)
    stats = combat_stats(obj, looker)
    combined = evtable.EvTable(table=[[stats], [desctable]], border=None, header=False, valign="t")
    return combined
Пример #10
0
    def func(self):
        """
        Get all connected accounts by polling session.
        """

        account = self.account
        session_list = SESSIONS.get_sessions()

        session_list = sorted(session_list, key=lambda o: o.account.key)

        if self.cmdstring == "doing":
            show_session_data = False
        else:
            show_session_data = account.check_permstring(
                "Developer") or account.check_permstring("Admins")

        naccounts = (SESSIONS.account_count())
        if show_session_data:
            # privileged info
            table = evtable.EvTable("|wAccount Name", "|wOn for", "|wIdle",
                                    "|wPuppeting", "|wRoom", "|wCmds",
                                    "|wProtocol", "|wHost")
            for session in session_list:
                if not session.logged_in:
                    continue
                delta_cmd = time.time() - session.cmd_last_visible
                delta_conn = time.time() - session.conn_time
                account = session.get_account()
                puppet = session.get_puppet()
                location = puppet.location.key if puppet and puppet.location else "None"
                table.add_row(
                    utils.crop(account.get_display_name(account), width=25),
                    utils.time_format(delta_conn, 0),
                    utils.time_format(delta_cmd, 1),
                    utils.crop(
                        puppet.get_display_name(account) if puppet else "None",
                        width=25), utils.crop(location, width=25),
                    session.cmd_total, session.protocol_key,
                    isinstance(session.address, tuple) and session.address[0]
                    or session.address)
        else:
            # unprivileged
            table = evtable.EvTable("|wAccount name", "|wOn for", "|wIdle")
            for session in session_list:
                if not session.logged_in:
                    continue
                delta_cmd = time.time() - session.cmd_last_visible
                delta_conn = time.time() - session.conn_time
                account = session.get_account()
                table.add_row(
                    utils.crop(account.get_display_name(account), width=25),
                    utils.time_format(delta_conn, 0),
                    utils.time_format(delta_cmd, 1))
        is_one = naccounts == 1
        self.msg(
            "|wAccounts:|n\n%s\n%s unique account%s logged in." %
            (table, "One" if is_one else naccounts, "" if is_one else "s"))
Пример #11
0
    def func(self):
        """Implement function"""

        caller = self.caller

        # all channels we have available to listen to
        channels = [chan for chan in ChannelDB.objects.get_all_channels()
                    if chan.access(caller, 'listen')]
        if not channels:
            self.msg("No channels available.")
            return
        # all channel we are already subscribed to
        subs = ChannelDB.objects.get_subscriptions(caller)

        if self.cmdstring == "comlist":
            # just display the subscribed channels with no extra info
            comtable = evtable.EvTable("|wchannel|n", "|wmy aliases|n",
                                       "|wdescription|n", align="l", maxwidth=_DEFAULT_WIDTH)
            for chan in subs:
                clower = chan.key.lower()
                nicks = caller.nicks.get(category="channel", return_obj=True)
                comtable.add_row(*["%s%s" % (chan.key, chan.aliases.all() and
                                             "(%s)" % ",".join(chan.aliases.all()) or ""),
                                   "%s" % ",".join(nick.db_key for nick in make_iter(nicks)
                                                   if nick and nick.value[3].lower() == clower),
                                   chan.db.desc])
            self.msg("\n|wChannel subscriptions|n (use |w@channels|n to list all,"
                     " |waddcom|n/|wdelcom|n to sub/unsub):|n\n%s" % comtable)
        else:
            # full listing (of channels caller is able to listen to)
            comtable = evtable.EvTable("|wsub|n", "|wchannel|n", "|wmy aliases|n",
                                       "|wlocks|n", "|wdescription|n", maxwidth=_DEFAULT_WIDTH)
            for chan in channels:
                clower = chan.key.lower()
                nicks = caller.nicks.get(category="channel", return_obj=True)
                nicks = nicks or []
                if chan not in subs:
                    substatus = "|rNo|n"
                elif caller in chan.mutelist:
                    substatus = "|rMuted|n"
                else:
                    substatus = "|gYes|n"
                comtable.add_row(*[substatus,
                                   "%s%s" % (chan.key, chan.aliases.all() and
                                             "(%s)" % ",".join(chan.aliases.all()) or ""),
                                   "%s" % ",".join(nick.db_key for nick in make_iter(nicks)
                                                   if nick.value[3].lower() == clower),
                                   str(chan.locks),
                                   chan.db.desc])
            comtable.reformat_column(0, width=9)
            comtable.reformat_column(3, width=14)
            self.msg("\n|wAvailable channels|n (use |wcomlist|n,|waddcom|n and |wdelcom|n"
                     " to manage subscriptions):\n%s" % comtable)
Пример #12
0
    def func(self):
        session_list = SESSIONS.get_sessions()

        table = evtable.EvTable(" |w|uName:|n",
                                "|w|uIdle:|n",
                                "|w|uConn:|n",
                                "|w|uClearance:|n",
                                table=None,
                                border=None,
                                width=78)

        for session in session_list:
            player = session.get_account()
            idle = time.time() - session.cmd_last_visible
            conn = time.time() - session.conn_time
            clearance = session.get_puppet().db.clearance
            flag = None
            if player.locks.check_lockstring(player, "dummy:perm(Admin)"):
                flag = "|y!|n"
            elif player.locks.check_lockstring(player, "dummy:perm(Builder)"):
                flag = "|g&|n"
            elif player.locks.check_lockstring(player, "dummy:perm(Helper)"):
                flag = "|r$|n"
            else:
                flag = " "
            table.add_row(
                flag + utils.crop(player.name), utils.time_format(idle, 0),
                utils.time_format(conn, 0),
                "|{}{}|n".format(clearance_color(CLEARANCE.get(clearance)),
                                 CLEARANCE.get(clearance)))

        table.reformat_column(0, width=24)
        table.reformat_column(1, width=12)
        table.reformat_column(2, width=12)
        table.reformat_column(3, width=30)

        self.caller.msg("|w_|n" * 78)
        title = ansi.ANSIString("|[002|w|u{}|n".format(settings.SERVERNAME))
        self.caller.msg(title.center(78, '^').replace('^', "|[002|w_|n"))

        self.caller.msg(table)
        self.caller.msg("|w_|n" * 78)
        self.caller.msg("Total Connected: %s" % SESSIONS.account_count())
        whotable = evtable.EvTable("", "", "", header=False, border=None)
        whotable.reformat_column(0, width=26)
        whotable.reformat_column(1, width=26)
        whotable.reformat_column(2, width=26)
        whotable.add_row("|y!|n - Administrators", "|g&|n - Storytellers",
                         "|r$|n - Player Helpers")
        self.caller.msg(whotable)
        self.caller.msg("|w_|n" * 78 + "\n")
Пример #13
0
def combat_stats(combatant, looker=None):
    if not looker:
        looker = combatant
    deck = len(combatant.deck)
    hand = len(combatant.hand)
    discard = len(combatant.discardpile)
    played = combatant.played
    statstrings = []
    for stat in sorted(list(combatant.db.stats.keys())):
        statcur, statmax = combatant.get_stat(stat)
        statpct = statcur/statmax
        color = 'c'
        if statpct < .25:
            color = 'r'
        elif statpct < .5:
            color = 'y'
        elif statpct > 1:
            color = 'G'
        statstrings.append(f'{stat}: |{color}{statcur}|n|h/{statmax}|n')
    table = statstrings + [f"Deck Size: {deck}", f"Hand Size: {hand}", f"Discard Size: {discard}"]
    for card in played:
        cardinfo = get_card_data(card)
        table.append(card_brief(cardinfo))
    display = evtable.EvTable(f"|c{combatant.get_display_name(looker)}|n", border='table', table=[table], width=25, align='c')
    return display
Пример #14
0
 def build_nick_table(self, nicklist=None):
     if nicklist:
         table = evtable.EvTable("#", "Type", "Nick match", "Replacement")
         for inum, nickobj in enumerate(nicklist):
             _, _, nickvalue, replacement = nickobj.value
             table.add_row(str(inum + 1), nickobj.db_category, nickvalue, replacement)
         return table
Пример #15
0
 def _check_table(self, bucket):
     """build the table for the _check and return it"""
     ret = evtable.EvTable("Buckets %s has access to:" % self.character, "Actions available to: %s" % self.character,
                           header=True,
                           border="table",
                           header_line_char="-",
                           width=95,
                           corner_top_left_char=CORNER_TOP_LEFT_CHAR,
                           corner_top_right_char=CORNER_TOP_RIGHT_CHAR,
                           corner_bottom_left_char=CORNER_BOTTOM_LEFT_CHAR,
                           corner_bottom_right_char=CORNER_BOTTOM_RIGHT_CHAR,
                           border_left_char=BORDER_LEFT_CHAR,
                           border_right_char=BORDER_RIGHT_CHAR,
                           border_top_char=BORDER_TOP_CHAR,
                           border_bottom_char=BORDER_BOTTOM_CHAR, )
     # layout the column widths
     ret.reformat_column(0, width=40, align="l")   # Buckets target can access
     ret.reformat_column(1, width=55, align="c")   # Actions available to target
     # fix header corners
     ret.table[0][0].reformat(corner_bottom_left_char=HEADER_BOTTOM_LEFT_CHAR)
     ret.table[1][0].reformat(corner_bottom_right_char=HEADER_BOTTOM_RIGHT_CHAR)
     # populate the table.
     if isinstance(bucket, list):
         for buck in bucket:
             ret.add_row(buck.key, ', '.join(str(x) for x in buck.db.per_player_actions[self.character]))
     else:
         ret.add_row(', '.join(str(x) for x in bucket.info()))
     return ret
Пример #16
0
def scorelist():

    from typeclasses.objects import Bones
    bones = Bones.objects.all()
    scores = {}
    for bone in bones:
        if bone.db.buried:
            scores.update({
                bone.locks.get("control"):
                scores.get(bone.locks.get("control"), 0) + bone.db.value
            })

    players = []
    bones = []

    l = list(scores.items())
    l.sort(reverse=True)

    for k, v in l[:10]:
        import re
        from evennia import ObjectDB
        match = re.search(r"control:pid\((#\d*)\)", k)
        players.append(dbref_to_obj(match[1], ObjectDB).key)
        bones.append(v)

    heading = "|/$pad($alt(Top Dogs,|401|132|540|054)|n,106,c,!)|/"
    table = evtable.EvTable("|401Player|n",
                            "|401Score|n",
                            table=[players, bones],
                            border="cells")
    table.reformat_column(0, width=60)
    table.reformat_column(1, width=10)
    return heading + str(table)
Пример #17
0
def get_cg_info(race, template, data, target):
    if race in list(template.keys()):
        infolist = template[race]
    else:
        infolist = template['Default']
    leftcolumn = ['Name: %30.30s' % (target.name, )]
    rightcolumn = ['Race: %29.29s' % (data['Race'], )]
    for infoentry in infolist['Left']:
        if infoentry in list(data.keys()):
            w = 36 - len('%s: ' % infoentry)
            try:
                leftline = '%s: %s' % (
                    infoentry, justify(data[infoentry], width=w, align='r'))
            except TypeError as e:
                leftline = e
            leftcolumn.append(leftline)
    for infoentry in infolist['Right']:
        if infoentry in list(data.keys()):
            w = 35 - len('%s: ' % infoentry)
            try:
                rightline = '%s: %s' % (
                    infoentry, justify(data[infoentry], width=w, align='r'))
            except TypeError as e:
                rightline = e
            rightcolumn.append(rightline)
    table = evtable.EvTable(table=[leftcolumn, rightcolumn], border='incols')
    table.reformat(width=78)
    return table
Пример #18
0
 def func(self):
     arglist = self.arglist
     args = self.args
     rhs = self.rhs
     lhs = self.lhs
     switches = self.switches
     if not args:
         self.caller.msg(evtable.EvTable("Downtime",table=self.caller.db.timelog))
         return
     elif self.IsInt(lhs):
         if rhs != "":
             if int(lhs) <= self.caller.db.downtime:
                 self.caller.db.timelog.append(self.TimeLog(int(lhs),self.caller.location.name,rhs))
                 self.caller.msg("Spending "+lhs+" hours of downtime for "+rhs)
                 self.caller.db.downtime -= int(lhs)
                 return
             else:
                 self.caller.msg("You don't have that much downtime left!")
                 return
         else:
             self.caller.msg("You must provide a reason for your downtime expenditure in order to spend it!")
     elif len(switches) > 0:
         if switches[0].lower() == "peek" and self.caller.IsAdmin():
             timelog = []
             if inherits_from(search.objects(arglist[0])[0],DefaultCharacter):
                 try:
                     for item in search.objects(arglist[0])[0].db.timelog:
                         timelog.append(item)
                     timebox = StatBlock(str(search.objects(arglist[0])[0])+"'s time log",False,timelog)
                     timebox.SetColumns(1)
                     self.caller.msg(timebox.Show()+timebox.Footer())
                 except AttributeError:
                     self.caller.msg("Character not found!")
Пример #19
0
    def func(self):
        caller = self.caller
        if self.args:
            target = self.args
        elif self.args:
            return caller.msg("I can't find a player by that name.")
        else:
            target = caller

        if target.cg:
            target = target.cg
            mode = "chargen"
        else:
            mode = "normal"

        tag = "|Rsr5 > |n"

        if not target.db.karma:
            caller.msg(tag + "That target doesn't seem to have a nuyen log.")

        if not self.switches:
            caller.msg(target.db.nuyen)
        elif "log" in self.switches:
            table = evtable.EvTable("Date", "Transaction", "Origin")
            log_list = target.db.nuyen.log()
            for date, owner, value, currency, reason, origin in log_list:
                # Origin comes in as a dbref and we need it to be a name.
                origin = evennia.search_object(searchdata=origin)[0].name
                table.add_row(date.strftime("%c"),
                              "{} {}: {}".format(value, currency,
                                                 reason), origin)

            caller.msg(table)
        else:
            return False
Пример #20
0
    def func(self):
        caller = self.caller
        charclass = caller.db.charclass
        defense = round(caller.db.defense)
        health = round(caller.db.health)
        intel = round(caller.db.intel)
        luck = round(caller.db.luck)
        magic = round(caller.db.magic)
        strength = round(caller.db.strength)
        dex = round(caller.db.dex)
        attr_points = caller.db.attr_points

        table = evtable.EvTable("Attribute",
                                "Value",
                                table=[[
                                    "charclass", "defense", "health", "intel",
                                    "luck", "magic", "dex", "strength",
                                    "upgrade points"
                                ],
                                       [
                                           charclass, defense, health, intel,
                                           luck, magic, dex, strength,
                                           attr_points
                                       ]])
        caller.msg(table)
Пример #21
0
 def func(self):
     """returns the list of online characters"""
     count_accounts = (SESSIONS.account_count())
     self.caller.msg('[%s] Through the fog you see:' % self.key)
     session_list = SESSIONS.get_sessions()
     table = evtable.EvTable(border='none')
     table.add_row('Character', 'On for', 'Idle',  'Location')
     for session in session_list:
         puppet = session.get_puppet()
         if not session.logged_in or not puppet:
             continue
         delta_cmd = time.time() - session.cmd_last_visible
         delta_conn = time.time() - session.conn_time
         location = puppet.location.key if puppet and puppet.location else 'Nothingness'
         table.add_row(puppet.key if puppet else 'None', utils.time_format(delta_conn, 0),
                       utils.time_format(delta_cmd, 1), location)
     table.reformat_column(0, width=25, align='l')
     table.reformat_column(1, width=12, align='l')
     table.reformat_column(2, width=7, align='l')
     table.reformat_column(3, width=25, align='l')
     is_one = count_accounts == 1
     string = '%s' % 'A' if is_one else str(count_accounts)
     string += ' single ' if is_one else ' unique '
     plural = ' is' if is_one else 's are'
     string += 'account%s logged in.' % plural
     self.caller.msg(table)
     self.caller.msg(string)
Пример #22
0
 def get_debt_table(debts):
     x = 0
     table = evtable.EvTable("{w#{n", "{wReceiver{n", "{wAmount{n", "{wTime Remaining{n", width=60)
     for debt in debts:
         x += 1
         time = "Permanent" if debt.repetitions_left == -1 else debt.repetitions_left
         table.add_row(debt.id, debt.receiver, debt.weekly_amount, time)
     return table
Пример #23
0
    def func(self):
        "Implement function"

        caller = self.caller

        # all channels we have available to listen to
        channels = [chan for chan in ChannelDB.objects.get_all_channels()
                    if chan.access(caller, 'listen')]
        #print channels
        if not channels:
            self.msg("No channels available.")
            return
        # all channel we are already subscribed to
        subs = ChannelDB.objects.get_subscriptions(caller)
        #print subs

        if self.cmdstring == "comlist":
            # just display the subscribed channels with no extra info
            comtable = evtable.EvTable("{wchannel{n", "{wmy aliases{n", "{wdescription{n", align="l", maxwidth=_DEFAULT_WIDTH)
            #comtable = prettytable.PrettyTable(["{wchannel", "{wmy aliases", "{wdescription"])
            for chan in subs:
                clower = chan.key.lower()
                nicks = caller.nicks.get(category="channel")
                comtable.add_row(*["%s%s" % (chan.key, chan.aliases.all() and
                                  "(%s)" % ",".join(chan.aliases.all()) or ""),
                                  "%s".join(nick for nick in make_iter(nicks)
                                  if nick and nick.lower() == clower),
                                  chan.db.desc])
            caller.msg("\n{wChannel subscriptions{n (use {w@channels{n to list all, {waddcom{n/{wdelcom{n to sub/unsub):{n\n%s" % comtable)
        else:
            # full listing (of channels caller is able to listen to)
            comtable = evtable.EvTable("{wsub{n", "{wchannel{n", "{wmy aliases{n", "{wlocks{n", "{wdescription{n", maxwidth=_DEFAULT_WIDTH)
            #comtable = prettytable.PrettyTable(["{wsub", "{wchannel", "{wmy aliases", "{wlocks", "{wdescription"])
            for chan in channels:
                clower = chan.key.lower()
                nicks = caller.nicks.get(category="channel")
                nicks = nicks or []
                comtable.add_row(*[chan in subs and "{gYes{n" or "{rNo{n",
                                  "%s%s" % (chan.key, chan.aliases.all() and
                                  "(%s)" % ",".join(chan.aliases.all()) or ""),
                                  "%s".join(nick for nick in make_iter(nicks)
                                  if nick.lower() == clower),
                                  str(chan.locks),
                                  chan.db.desc])
            caller.msg("\n{wAvailable channels{n (use {wcomlist{n,{waddcom{n and {wdelcom{n to manage subscriptions):\n%s" % comtable)
Пример #24
0
    def func(self):
        table = evtable.EvTable(OOCLOOK_HEADING,
                                self.player,
                                table=[[1, 2, 3], [4, 5, 6], [7, 8, 9]],
                                border="cells")

        table.add_column("This is long data", "This is even longer data")
        table.add_row("This is a single row")
        self.msg(table)
Пример #25
0
    def func(self):

        if self.args == []: target = self.caller  # Assume they mean themselves
        else:
            target = self.caller.search(self.args, quiet=True)
            try:
                target = target[0]
            except IndexError:
                target = False  # No targets

        if not target or target.location != self.caller.location:  # If they aren't here, you can't see their stats
            self.caller.msg("|yYou don't see them here|n")
            return

        if target.db.race == None:  # There has to be a better way to do this
            self.caller.msg("|yThat's not a player|n")
            return

        text = f"\n\n|gStatistics of {target.key}:|n\n"
        text += f"Race: {target.db.race.name}, {target.db.gender.name.title()}\n"
        text += f"Class: {target.db.pclass.name}\n"
        text += f"Level: {target.db.level}, Xp: {target.db.xp}\n"
        text += f"Gold: |y{target.db.gold}|n\n"

        table = evtable.EvTable(
            "Stat",
            "Value",
            "Stat",
            "Value",
            table=[
                [  # Headings
                    "HP",
                    "Armor",
                    "Magic"  # Column 1
                ],
                [
                    str(target.db.hp) + "/" +
                    str(target.db.max_hp),  # Column 2
                    target.db.armor,
                    f"{target.db.magic}/{target.db.max_magic}",
                ],
                [
                    "Str",
                    "Dex",
                    "Int"  # Column 3
                ],
                [
                    target.db.strength,
                    target.db.dexterity,
                    target.db.intelligence  # Column 4
                ]
            ])

        text += "\n" + "\n".join(table.get()) + "\n\n"
        self.caller.msg(text)
Пример #26
0
    def table(self, head=False, body=False, layout=False):
        """
        Builds a table with header from data
        :param header: tuple(string1, string2, ... )
        :param data: iterable
        :return: formatted table
        """
        # Todo: Finish building table

        dt = self.default_table()
        # Create the table
        if head:
            pass
        else:
            head = dt.head

        if body:
            pass
        else:
            from job import Job
            jobs = Job.objects.all()
            # Todo: munge jobs to test for access
            body = jobs

        # Create the table
        table = evtable.EvTable()

        # Add columns
        for i in head:
            table.add_column(i)

        # Add rows
        for i in body:
            info = job.info()
            table.addrow(*info)

        if layout:
            pass
        else:
            import jobs_settings as jset
            table.header = True
            table.border = "table"
            table.header_line_char = jset.HEADER_LINE_CHAR
            table.width = jset.TABLE_WIDTH
            table.corner_top_left_char = jset.CORNER_TOP_LEFT_CHAR
            table.corner_top_right_char = jset.CORNER_TOP_RIGHT_CHAR
            table.corner_bottom_left_char = jset.CORNER_BOTTOM_LEFT_CHAR
            table.corner_bottom_right_char = jset.CORNER_BOTTOM_RIGHT_CHAR
            table.border_left_char = jset.BORDER_LEFT_CHAR
            table.border_right_char = jset.BORDER_RIGHT_CHAR
            table.border_top_char = jset.BORDER_TOP_CHAR
            table. border_bottom_char = jset.BORDER_BOTTOM_CHAR

        return table
Пример #27
0
def combat_stats_multiple(characters, width=79, title="Combat Stats"):
    colcount = int(width/27)
    rows = []
    for i in range(0,colcount):
        rows.append([])
    for i in range(0, len(characters)):
        row = int(math.fmod(i, colcount))
        stats = combat_stats(characters[i])
        rows[row].append(stats)
    statmultiple = evtable.EvTable("", f'{title}', "", border=None, table=rows, align="c", valign="t")
    return statmultiple
Пример #28
0
def card_small(card):
    cardrarity = cardsystem.RARITIES[card['Rarity']]
    color = cardsystem.ELEMENTS[card['Element']]['Color']
    cardstats = evtable.EvTable(table=[[card['Effect']]],
                                border=None,
                                header=False,

                                )
    cardfmt = evtable.EvTable(card['Name'],
                              table=[[cardstats]],
                              width=24,
                              border='table',
                              corner_char=f'|{color}+|n',
                              border_left_char=f"|{color}{cardrarity['left_border']}|n",
                              border_right_char=f"|{color}{cardrarity['right_border']}|n",
                              border_top_char=f"|{color}{cardrarity['top_border']}|n",
                              border_bottom_char=f"|{color}{cardrarity['bottom_border']}|n",
                              align="c",
                              )
    return cardfmt
Пример #29
0
 def func(self):
     """check inventory"""
     items = self.caller.contents
     if not items:
         string = "You are not carrying anything."
     else:
         table = evtable.EvTable(border="header")
         for item in items:
             table.add_row("|C%s|n" % item.name, item.db.desc or "")
         string = "|wYou are carrying:\n%s" % table
     self.caller.msg(string)
Пример #30
0
def menunode_inspect_and_select_race(caller, raw_string):
    "Sets up the race selection menu screen."

    irace = int(raw_string) - 1
    race = playerraces.races[irace]
    text = "You inspect %s:\n\n%s" % (race().name, race().desc)

    # gather statistics and create table

    r = race()
    stat_table = evtable.EvTable(
        "Stat",
        "Bonus",
        table=[["int", "str", "dex", "mag", "hp", "armor", "size", "PR req"],
               [
                   r.base_int_mod, r.base_str_mod, r.base_dex_mod,
                   r.base_max_magic_mod, r.base_hp, r.base_armor, r.size,
                   r.prestige_required
               ]])
    text += "\n" + "\n".join(stat_table.get()) + "\n\n"
    if len(r.base_proficiencies) != 0:
        text += "Proficiencies: " + str(r.base_proficiencies) + "\n"
    if len(r.base_spells) != 0: text += "Spells: " + str(r.base_spells) + "\n"
    if len(r.base_tags) != 0: text += "Tags: " + str(r.base_tags) + "\n"
    if len(r.base_resistances) != 0:
        text += "Resistances: " + str(r.base_resistances) + "\n"
    if len(r.base_immunities) != 0:
        text += "Proficiencies: " + str(r.base_immunities) + "\n"

    def select_race_result(caller):
        "This will be executed first when selected"
        if caller.account.db.prestige >= race().prestige_required:
            caller.msg("You selected %s" % (race().name))
            caller.db.race = race()
            return "menunode_classlist"
        else:
            caller.msg(
                "|yYou do not have high enough prestige to choose this race.|n"
            )
            caller.msg(
                f"|y(Have {caller.account.db.prestige} need {race().prestige_required})"
            )
            return "menunode_racelist"



    options = ({"desc": "Select race %s" % \
                        (race().name),
                "goto": select_race_result},

               {"desc": "Choose a different race",
                "goto": "menunode_racelist"})

    return text, options