Exemple #1
0
    def return_appearance(self, looker):
        if not looker:
            return
        equipment = [eq for eq in self.contents if eq != looker and eq.access(looker, "view")]

        message = []

        message.append("|w_|n" * 78)
        title = ansi.ANSIString("|[002|w|u{}-{}-{}|n".format(self.key, self.db.clone, self.db.sector))
        message.append(title.ljust(78, '^').replace('^', "|[002|w_|n"))
        message.append("")
        message.append("{} has {} hair, {} eyes and {} skin.  They stand at {} tall and weighs {}.  "
                       "They wear a jumpsuit with a {} stripe.".format(self.key, HAIR.get(self.db.hair) or "no",
                        EYES.get(self.db.eyes) or "nondescript", SKIN.get(self.db.skin) or "pale", self.db.height
                        or "indeterminate", self.db.weight or "indeterminate", CLEARANCE.get(self.db.clearance)))
        message.append("|{}_|n".format(clearance_color(CLEARANCE.get(self.db.clearance))) * 78)
        role = self.db.role
        role_str = "Assigned Role: |320{}|n".format(role)
        if role:
            # message.append("Assigned Role: |320{}|n".format(role))
            message.append(role_str)
        if equipment:
            message.append("\n|wEquipment:|n")
        for eq in equipment:
            message.append(eq.key)

        message2 = []
        for line in message:
            message2.append(line)

        return "\n".join(str(m) for m in message2)
Exemple #2
0
    def styled_divider(self, text=None, width=None):
        width = width or self.client_width() or 80
        pattern = "|h|x-|h|b-|n"
        border = self.style_border_repeats(pattern, width)

        if text:
            text = ansi.ANSIString(f"|x|h|| |n{text} |x|h|||n")
            border = self.insert_text_centered(border, text)

        return border
Exemple #3
0
    def styled_footer(self, text=None, width=None):
        width = width or self.client_width() or 80
        pattern = "|h|b=|h|x=|n"
        border = self.style_border_repeats(pattern, width)

        if text:
            text = ansi.ANSIString(f"|n|h< {text} >|n")
            border = self.insert_text_right_just(border, text, 4)

        return border
Exemple #4
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")
Exemple #5
0
    def return_appearance(self, looker):
        message = []
        message.append("|w_|n" * 78)
        name = ansi.ANSIString("|[002|w|u{}|n".format(self.key))
        message.append(name.ljust(78, '^').replace('^', "|[002|w_|n"))
        message.append("|wSize:|n {}".format(self.db.size))
        message.append("|wLevel:|n {}".format(self.db.level))
        if self.db.uses > -1:
            message.append("|wUses:|n {}/{}".format(self.db.uses,
                                                    self.db.max_uses))
        message.append("|wConsumable:|n {}".format(self.db.consumable))
        message.append("|wAction Order:|n {} +{}".format(
            self.db.action_order[0], self.db.action_order[1]))
        message.append(self.db.desc)
        message.append("|w_|n" * 78)

        message2 = []
        for line in message:
            message2.append(line)

        return "\n".join(str(m) for m in message2)
def get_numbered_name(self, count, looker, **kwargs):
    """
    Return the numbered (singular / plural) forms of this object's key.
    This is by default called by return appearance and is used for 
    grouping multiple same-named of this object. Note that this will 
    be called on *every* member of a group even though the plural name
    will be only shown once. Also the singular display version, such as
    'an apple', 'a tree' is determined from this method.

    Args:
        count (int): Number of objects of this type
        looker (Object): onlooker. Not used by default
    Kwargs:
        key (str): optional key to pluralize, if given, use this instead
        of the object's key
    Returns:
        singular (str): the singular form to display
        plural (str): the determined plural form of the key, including count.
    """
    key = kwargs.get("key", self.key)
    key = ansi.ANSIString(key)  # Needed to allow inflection of colored names
    if self.db.formae:
        plural = self.db.formae['nom_pl'][0]
    else:
        plural = self.key

    plural = f"{count} {plural}"

    singular = self.key

    if not self.aliases.get(plural, category="plural_key"):
        # We need to wipe any old plurals/an/a in case key changed in the interim
        self.aliases.clear(category="plural_key")
        self.aliases.add(plural, category="plural_key")

        # save teh singular form as an aliases here too so we can display "an egg"
        # and also look at "an egg"
        self.aliases.add(singular, category="plural_key")

    return singular, plural
Exemple #7
0
    def styled_header(self, text=None, width=None):
        """
        Args:
            self: command calling the header
            text: text, if any, to show
            width: A certain width passed, or None

        Returns:
            a pretty header

        This is harder than it seems, because Python's center() doesn't allow for multi-character strings,
        so we get to build our own.
        """
        width = width or self.client_width() or 80
        pattern = "|h|x=|h|b=|n"
        border = self.style_border_repeats(pattern, width)

        if text:
            text = ansi.ANSIString(f"|n|h< {text} >|n")
            border = self.insert_text_centered(border, text)

        return border
Exemple #8
0
    def style_border_repeats(self, pattern, width):
        """
        Take some text and return it exactly to width.
        e.g.,
            -=-=-=-=-=-=-=-=-=-=-=-=-=
        Args:
            pattern: the pattern that's going to be repeated
            width: width, usually of the client screen

        Returns:
            a border line that is exactly 'width' wide
        """

        style_pattern = ansi.ANSIString(pattern)
        style_width = len(style_pattern)
        # +1 to assure that substring always shortens.
        # See Issue #2030: https://github.com/evennia/evennia/issues/2030
        # Remove the +1 when issue is resolved.
        border = style_pattern * (math.ceil(width / style_width) + 1)

        # clip pattern to 'width'
        return border[0:width]
Exemple #9
0
def upgrade_clearance(caller):
    text = "The Peter Principle: People tend to be promoted to their own level of incompetence.\n\nWith enough time, " \
           "patience and luck, clones like you can rise through the ranks of security clearances.  Legend has it " \
           "that TOM-92 (who doesn't exist) was once an Infrared.  See the list of security clearances below along " \
           "with the associated XP Point costs.  And remember those costs are cumulative.\n\nExample: To go from " \
           "Infrared to Red costs 500 XP Points.  Likewise to go from Red to Orange costs 1000 XP Points.  Therefore " \
           "to go from Infrared to Orange costs a total of 1500 XP Points.\n\n|wCurrent Clearance:|n {}" \
        .format(CLEARANCE.get(caller.db.clearance))

    red = ansi.ANSIString("|rRed:|n")
    red_cost = ansi.ANSIString("500")
    orange = ansi.ANSIString("|520Orange:|n")
    orange_cost = ansi.ANSIString("1000")
    yellow = ansi.ANSIString("|yYellow:|n")
    yellow_cost = ansi.ANSIString("2000")
    green = ansi.ANSIString("|gGreen:|n")
    green_cost = ansi.ANSIString("4000")
    blue = ansi.ANSIString("|bBlue:|n")
    blue_cost = ansi.ANSIString("8000")
    indigo = ansi.ANSIString("|MIndigo:|n")
    indigo_cost = ansi.ANSIString("16000")
    violet = ansi.ANSIString("|mViolet:|n")
    violet_cost = ansi.ANSIString("32000")
    ultraviolet = ansi.ANSIString("|[W|XUltraviolet:|n")
    ultraviolet_cost = ansi.ANSIString("|y<ERROR>|n")

    table = evtable.EvTable("", "", "", "", "", "", header=None, border=None)

    table.reformat_column(0, width=16, align="l")
    table.reformat_column(1, width=10, align="r")
    table.reformat_column(2, width=16, align="l")
    table.reformat_column(3, width=10, align="r")
    table.reformat_column(4, width=16, align="l")
    table.reformat_column(5, width=10, align="r")

    table.add_row(red, red_cost, orange, orange_cost, yellow, yellow_cost)
    table.add_row(green, green_cost, blue, blue_cost, indigo, indigo_cost)
    table.add_row(violet, violet_cost, ultraviolet, ultraviolet_cost, "", "")

    text += str(table)

    options = ()

    if caller.db.clearance == 1:
        options += ({
            "desc": "Upgrade to Red",
            "exec": exec_clearance_upgrade,
            "goto": "upgrade_clearance"
        }, )
    elif caller.db.clearance == 2:
        options += ({
            "desc": "Upgrade to Orange",
            "exec": exec_clearance_upgrade,
            "goto": "upgrade_clearance"
        }, )
    elif caller.db.clearance == 3:
        options += ({
            "desc": "Upgrade to Yellow",
            "exec": exec_clearance_upgrade,
            "goto": "upgrade_clearance"
        }, )
    elif caller.db.clearance == 4:
        options += ({
            "desc": "Upgrade to Green",
            "exec": exec_clearance_upgrade,
            "goto": "upgrade_clearance"
        }, )
    elif caller.db.clearance == 5:
        options += ({
            "desc": "Upgrade to Blue",
            "exec": exec_clearance_upgrade,
            "goto": "upgrade_clearance"
        }, )
    elif caller.db.clearance == 6:
        options += ({
            "desc": "Upgrade to Indigo",
            "exec": exec_clearance_upgrade,
            "goto": "upgrade_clearance"
        }, )
    elif caller.db.clearance == 7:
        options += ({
            "desc": "Upgrade to Violet",
            "exec": exec_clearance_upgrade,
            "goto": "upgrade_clearance"
        }, )
    elif caller.db.clearance == 8:
        options += ({
            "desc": "Upgrade to Ultraviolet",
            "exec": exec_clearance_upgrade,
            "goto": "upgrade_clearance"
        }, )

    options += ({
        "key": ("back", "b"),
        "desc": "Go Back",
        "goto": "menu_start_node"
    }, )

    return text, options