Exemplo n.º 1
0
    def format_help_list(hdict_cmds, hdict_db):
        """
        Output a category-ordered list. The input are the
        pre-loaded help files for commands and database-helpfiles
        respectively.  You can override this method to return a
        custom display of the list of commands and topics.
        """
        header = f"\n{_SEP}\n   |C Liste des commandes existantes|n\n{_SEP}"
        category_content = "\n  |w{}|n:\n|G{}|n"
        other_commands_title = f"\n\n{_SEP}\n\r  |CAutres manuels|n\n{_SEP}"
        other_category_content = "\n\r  |w{}|n:\n|G{}|n"

        chunks = list()
        if hdict_cmds and any(hdict_cmds.values()):
            chunks.append(header)
            for category in sorted(hdict_cmds.keys()):
                chunks.append(
                    category_content.format(
                        str(category).title(),
                        fill("|C, |G".join(sorted(hdict_cmds[category])))))
        if hdict_db and any(hdict_db.values()):
            chunks.append(other_commands_title)
            for category in sorted(hdict_db.keys()):
                chunks.append(
                    other_category_content.format(
                        str(category).title(),
                        fill(", ".join(
                            sorted([
                                str(topic) for topic in hdict_db[category]
                            ])))))
        return "".join(chunks)
Exemplo n.º 2
0
def menunode_chargen_desc_confirm(caller, raw_input):
    string_input = raw_input.strip()
    if not string_input:
        text = "You have chosen not to set a long description at this time. "
        text += "If you change your mind later, type |mhelp @desc|n.\n\n"
        text += "Press |gC|n to continue."
        help = fill(
            "The |wdesc|n commands can be confusing!  |y@sdesc|n sets your "
            "short description at a glance.  |y@desc|n sets your longer, "
            "more detailed description when people look at you directly.  "
            "|y+desc|n is a different command that lets you store and use "
            "multiple different descriptions for different situations -- "
            "very useful for roleplayers!  Use |mhelp <command>|n after "
            "creating your character, to see more about each one.")
        options = ({"key": "_default", "goto": "menunode_chargen_mask_recog"})
    else:
        caller.new_char.attributes.add("desc", string_input)
        text = dedent("""\
            When people |wlook|n at your character directly, they will see:\n\n|c%s|n
            \n\nYou can change this later with the |mdesc|n command.\n\nPress |gC|n to continue.
        """) % caller.new_char.attributes.get("desc")
        help = fill(
            "The |wdesc|n commands can be confusing!  |y@sdesc|n sets your "
            "short description at a glance.  |y@desc|n sets your longer, "
            "more detailed description when people look at you directly.  "
            "|y+desc|n is a different command that lets you store and use "
            "multiple different descriptions for different situations -- "
            "very useful for roleplayers!  Use |mhelp <command>|n after "
            "creating your character, to see more about each one.")
        options = ({"key": "_default", "goto": "menunode_chargen_mask_recog"})
    return (text, help), options
Exemplo n.º 3
0
    def desc(self):
        """Returns a formatted description of the Focus.

        Note:
            The setter for this property only modifies the content
            of the first paragraph of what is returned.
        """
        desc = "|b{}|n\n".format(self.name)
        desc += fill(self._desc)
        desc += "\n\n"
        desc += fill("Adventurers with the |b{}|n focus gain {}.".format(
            self.name, _format_bonuses(self.bonuses)))
        desc += "\n\n"
        return desc
Exemplo n.º 4
0
def menunode_race_and_focuses(caller, raw_string):
    """Race detail and focus listing menu node."""
    raw_string = raw_string.strip()
    if raw_string.isdigit() and int(raw_string) <= len(races.ALL_RACES):
        race = races.ALL_RACES[int(raw_string) - 1]
        race = races.load_race(race)
        caller.ndb._menutree.race = race

    race = caller.ndb._menutree.race

    text = race.desc + "Select a focus below to continue:"
    help = fill("After selecting a focus, you will be prompted "
                "to save your race/focus combination.")

    options = [{
        "desc": f.name,
        "goto": "menunode_select_race_focus"
    } for f in race.foci]
    options.append({
        "key": ("Back", "_default"),
        "desc": "Return to Race selection",
        "goto": "menunode_races"
    })

    return (text, help), options
Exemplo n.º 5
0
def menunode_chargen_gender_speed(caller, raw_string):
    """Gender confirmation; set speed"""
    char = caller.new_char
    text = dedent("""\
        Your gender has been set to |y%s|n.  You can change this later
        using the |w@gender|n command in-game.
		
        Now set your default |wspeed|n.  This is the rate at which you
        move from one area to another.
    """) % char.attributes.get("gender")
    help = fill("Movement takes time.  Any time you travel from one area "
                "to another, there is a small delay to account for this. "
                "You can change this in-game at any time using |m@setspeed|n.")
    options = (
     {"desc": "Stroll (slowest)",
         "exec": lambda caller: \
                 char.attributes.add("move_speed","stroll"),
         "goto": "menunode_chargen_speed_sdesc"},
         {"desc": "Walk",
          "exec": lambda caller: \
                  char.attributes.add("move_speed","walk"),
          "goto": "menunode_chargen_speed_sdesc"},
         {"desc": "Run",
          "exec": lambda caller: \
                  char.attributes.add("move_speed","run"),
          "goto": "menunode_chargen_speed_sdesc"},
         {"desc": "Sprint (fastest)",
          "exec": lambda caller: \
                  char.attributes.add("move_speed","sprint"),
          "goto": "menunode_chargen_speed_sdesc"})
    return (text, help), options
Exemplo n.º 6
0
    def desc(self):
        """Returns a formatted description of the Focus.

        Note:
            The setter for this property only modifies the content
            of the first paragraph of what is returned.
        """
        desc = "|b{}|n\n".format(self.name)
        desc += fill(self._desc)
        desc += "\n\n"
        desc += fill("Adventurers with the |b{}|n focus gain {}.".format(
                    self.name,
                    _format_bonuses(self.bonuses)
                ))
        desc += "\n\n"
        return desc
Exemplo n.º 7
0
def menunode_chargen_welcome(caller):
    char = caller.new_char
    """Starting page and gender listing."""
    text = dedent("""\
        |wWelcome to |cModern Gods|w, an |yEvennia|w-based RP MUSH.|n

        You are currently creating character |m%s|n.

        Select a gender below by number, or type |whelp|n
        at any time for more info.
    """ % char.key)
    help = fill(
        "The gender of a character determines which pronouns are "
        "used in certain styles of emotes.  It has no other effect "
        "on the character, and does not limit any commands, abilities, "
        "or descriptive options.  You can change your gender at "
        "any time with the |m@gender|n command.")
    options = (
        {"desc": "Male (he, him, his)",
         "exec": lambda caller: \
                 char.attributes.add("gender","male"),
         "goto": "menunode_chargen_gender_speed"},
        {"desc": "Female (she, her, hers)",
         "exec": lambda caller: \
                 char.attributes.add("gender","female"),
         "goto": "menunode_chargen_gender_speed"},
        {"desc": "Neutral (it, its)",
         "exec": lambda caller: \
                 char.attributes.add("gender","neutral"),
         "goto": "menunode_chargen_gender_speed"},
        {"desc": "Ambiguous (they, them, their, theirs)",
         "exec": lambda caller: \
                 char.attributes.add("gender","ambiguous"),
         "goto": "menunode_chargen_gender_speed"})
    return (text, help), options
Exemplo n.º 8
0
def menunode_character_desc(caller, raw_string):
    """Enter a character description."""
    text = "Enter a description for your character."
    help = fill("")
    options = [{"key": "_default",
                "goto": "menunode_confirm"}]
    return (text, help), options
Exemplo n.º 9
0
def menunode_equipment_cats(caller, raw_string):
    """Initial equipment "shopping" - choose a category"""
    text = raw_string if raw_string and raw_string[0] == 'F' else ""
    text += "\n\nNext, purchase your starting equipment.\n"
    text += "You have |w{coins}|n.\n"
    text += "Select a category of equipment to view:"
    text = text.format(coins=as_price(caller.new_char.db.wallet))

    help = fill("Equipment is grouped into categories. Select one to view"
                "the items in that category.")
    help += "\n\n"
    help += fill("Money in Ainneve is represented as Copper Coins (CC),"
                 "Silver Coins (SC), and Gold Coins (GC), with a conversion"
                 "rate of 100 CC = 1 SC and 100 SC = 1 GC")

    def show_inventory(session):
        """display the character's inventory

        We achieve this by "monkey patching" the session's `msg` method
        onto the new char to catch the output of the 'inventory' command.
        """
        session.msg('\n')
        old_msg = session.new_char.msg
        session.new_char.msg = session.msg
        session.new_char.execute_cmd('inventory')
        session.new_char.msg = old_msg

    options = [{
        "desc": cat,
        "goto": "menunode_equipment_list"
    } for cat in _CATEGORY_LIST]

    options.append({
        "key": ("Inventory", "inv", "i"),
        "desc": "Show your current inventory",
        "exec": show_inventory,
        "goto": "menunode_equipment_cats"
    })

    options.append({
        "key": "Done",
        "desc": "Continue to character description",
        "goto": "menunode_character_sdesc"
    })

    return (text, help), options
Exemplo n.º 10
0
def menunode_chargen_sdesc_pose(caller, raw_input):
    string_input = raw_input.strip()
    if not string_input:
        text = "You have chosen not to set a short description yet.\n"
        text += "If you change your mind later, type |mhelp @sdesc|n.\n"
        text += dedent("""
            A |wpose|n is a short phrase that describes what your character is doing
            at a glance when someone enters the room. For example, if your pose 
            reads '|cis nursing a drink at the bar|n'.  When someone enters the room, 
            they will see |w'A young Chinese man is nursing a drink at the bar'|n\n
            Please type a pose for your character.  You can change it later.
        """)
        help = fill(
            "You can only have one pose at a time, which you can change "
            "with the |m@pose|n command.  A pose is similar to an emote, but "
            "more static: it is more a 'description' of what you are doing, "
            "instead of an 'action'."
            " "
            "A pose might be '|wis drinking at the bar|n' "
            "while an emote might be '|wemote chugs down the shot of tequila and "
            "slams the shot glass down|n'.")
        options = ({"key": "_default", "goto": "menunode_chargen_desc"})
    else:
        caller.new_char.sdesc.add(string_input)
        text = "Your short description has been set to:\n\n"
        text += "|y%s|n\n\n" % caller.new_char.sdesc.get()
        text += "You can change this later using the |m@sdesc|n command.\n\n"
        text += dedent("""
            A |wpose|n is a short phrase that describes what your character is doing
            at a glance when someone enters the room.  For example, if your pose
            reads '|cis nursing a drink at the bar|n'.  When someone enters the room, 
            they will see |w'A young Chinese man is nursing a drink at the bar'|n\n
            Please type a pose for your character.  You can change it later.
        """)
        help = fill(
            "You can only have one pose at a time, which you can change "
            "with the |m@pose|n command.  A pose is similar to an emote, but "
            "more static: it is more a 'description' of what you are doing, "
            "instead of an 'action'."
            " "
            "A pose might be '|wis drinking at the bar|n' "
            "while an emote might be '|wemote chugs down the shot of tequila and "
            "slams the shot glass down|n'.")
        options = ({"key": "_default", "goto": "menunode_chargen_desc"})
    return (text, help), options
Exemplo n.º 11
0
def menunode_character_sdesc(caller, raw_string):
    """Enter a character description."""
    text = "First, enter a short description for your character. It will be\n" \
           "shown in place of your name to those who don't know you, so it should\n" \
           "be general, like, 'a tall man', 'a hardened warrior', or 'a crazy old coot'."
    help = fill("After character creation, the short description can be modified using "
                "the '@desc' command. Also, see 'help recog' for information on using the "
                "recog command to set recognition descriptions in place of other characters' "
                "short descriptions.")
    options = [{"key": "_default",
                "goto": "menunode_character_desc"}]
    return (text, help), options
Exemplo n.º 12
0
def menunode_character_sdesc(caller, raw_string):
    """Enter a character description."""
    text = "First, enter a short description for your character. It will be\n" \
           "shown in place of your name to those who don't know you, so it should\n" \
           "be general, like, 'a tall man', 'a hardened warrior', or 'a crazy old coot'."
    help = fill(
        "After character creation, the short description can be modified using "
        "the '@desc' command. Also, see 'help recog' for information on using the "
        "recog command to set recognition descriptions in place of other characters' "
        "short descriptions.")
    options = [{"key": "_default", "goto": "menunode_character_desc"}]
    return (text, help), options
Exemplo n.º 13
0
    def desc(self):
        """Returns a formatted description of the Race.

        Note:
            The setter for this property only modifies the content
            of the first paragraph of what is returned.
        """
        desc = "|g{}|n\n".format(self.name)
        desc += fill(self._desc)
        desc += '\n\n'
        desc += fill("{} have a ".format(self.plural) +
                     "|y{}|n body type and can ".format(self.size) +
                     "select a |wfocus|n from among {}".format(
                         self._format_focus_list(self.foci)))
        if len(self.bonuses) > 0:
            desc += '\n\n'
            desc += fill("{} also gain {} of {}".format(
                self.plural, 'bonuses' if len(self.bonuses) > 1 else 'a bonus',
                _format_bonuses(self.bonuses)))
        desc += '\n\n'
        return desc
Exemplo n.º 14
0
def menunode_chargen_desc(caller, raw_input):
    string_input = raw_input.strip()
    char = caller.new_char.sdesc.get() if hasattr(
        caller.new_char, "sdesc") else caller.new_char.key
    if not string_input:
        text = "You have chosen not to set a pose at this time. If you\n"
        text += "change your mind later, type |mhelp @pose|n.\n\n"
        text += "Enter a more detailed description of your character's appearance. This will be\n"
        text += "displayed when others look at your character explicitly."
        help = fill(
            "After character creation, your character's long description can be modified "
            "using the |m@desc|n command.")
        options = ({
            "key": "_default",
            "goto": "menunode_chargen_desc_confirm"
        })
    elif len(char) + len(string_input) > 60:
        text = "Your pose is too long.  Please try again.\n\n"
        text += "The combined length of your short description\n"
        text += "and your pose cannot be more than 60 characters."
        help = fill(
            "After character creation, your character's long description can be modified"
            "using the |m@desc|n command.")
        options = ({"key": "_default", "goto": "menunode_chargen_desc"})
    else:
        caller.new_char.attributes.add("pose", string_input)
        text = "Your pose will display as:\n\n"
        text += "|y%s %s|n\n\n" % (char,
                                   caller.new_char.attributes.get("pose"))
        text += "You can change this later using the |m@sdesc|n and |m@pose|n commands.\n\n"
        text += "Enter a more detailed description of your character's appearance. This will be\n"
        text += "displayed when others look at your character explicitly."
        help = fill(
            "After character creation, your character's long description can be modified "
            "using the |m@desc|n command.")
        options = ({
            "key": "_default",
            "goto": "menunode_chargen_desc_confirm"
        })
    return (text, help), options
Exemplo n.º 15
0
def menunode_equipment_cats(caller, raw_string):
    """Initial equipment "shopping" - choose a category"""
    text = raw_string if raw_string and raw_string[0] == 'F' else ""
    text += "\n\nNext, purchase your starting equipment.\n"
    text += "You have |w{coins}|n.\n"
    text += "Select a category of equipment to view:"
    text = text.format(coins=as_price(caller.new_char.db.wallet))

    help = fill("Equipment is grouped into categories. Select one to view"
                "the items in that category.")
    help += "\n\n"
    help += fill("Money in Ainneve is represented as Copper Coins (CC),"
                 "Silver Coins (SC), and Gold Coins (GC), with a conversion"
                 "rate of 100 CC = 1 SC and 100 SC = 1 GC")

    def show_inventory(session):
        """display the character's inventory

        We achieve this by "monkey patching" the session's `msg` method
        onto the new char to catch the output of the 'inventory' command.
        """
        session.msg('\n')
        old_msg = session.new_char.msg
        session.new_char.msg = session.msg
        session.new_char.execute_cmd('inventory')
        session.new_char.msg = old_msg

    options = [{"desc": cat, "goto": "menunode_equipment_list"}
               for cat in _CATEGORY_LIST]

    options.append({"key": ("Inventory", "inv", "i"),
                    "desc": "Show your current inventory",
                    "exec": show_inventory,
                    "goto": "menunode_equipment_cats"})

    options.append({"key": "Done",
                    "desc": "Continue to character description",
                    "goto": "menunode_character_sdesc"})

    return (text, help), options
Exemplo n.º 16
0
def _format_item_details(item):
    print(item)
    # The hackiest solution in the world
    # Todo: Evaluate replacing this method
    value = [i for i in item['attrs'] if i[0] == 'value'][0][1]
    weight = [i for i in item['attrs'] if i[0] == 'weight'][0][1]
    """Returns a piece of equipment's details and description."""
    stats = [[
        "          |CPrice|n: {}".format(as_price(value)),
        "         |CWeight|n: |w{}|n".format(weight)
    ], []]
    col1, col2 = stats
    # this is somewhat awkward because we're using prototype dicts instead
    # of instances of these classes.
    if item['typeclass'] in ("typeclasses.weapons.Weapon",
                             "typeclasses.weapons.TwoHandedWeapon",
                             "typeclasses.weapons.RangedWeapon",
                             "typeclasses.weapons.TwoHandedRanged",
                             "typeclasses.armors.Shield"):
        col2.append("     |CHandedness|n: |c{}H|n".format(
            2 if 'TwoHanded' in item['typeclass'] else 1))

    if item['typeclass'] in ("typeclasses.weapons.Weapon",
                             "typeclasses.weapons.TwoHandedWeapon",
                             "typeclasses.weapons.RangedWeapon",
                             "typeclasses.weapons.TwoHandedRanged"):
        col2.append("         |CDamage|n: |r{}|n".format(item['damage']))

    if item['typeclass'] in ("typeclasses.weapons.RangedWeapon",
                             "typeclasses.weapons.TwoHandedRanged"):
        col2.append("          |CRange|n: |G{}|n".format(", ".join(
            [r.capitalize() for r in item['range']])))

    if item['typeclass'] in ("typeclasses.armors.Armor",
                             "typeclasses.armors.Shield"):
        col2.append("      |CToughness|n: |y{}|n".format(item['toughness']))

    if 'quantity' in item:
        col2.append("       |CQuantity|n: |w{}|n".format(item['quantity']))

    table = EvTable(header=False, table=stats, border=None)

    text = "|Y{name}|n\n"
    text += "{desc}\n"
    text += "{stats}\n"
    if 'ammunition' in item:
        text += "  This weapon requires ammunition: |w{ammo}|n\n"

    return text.format(name=item['key'].title(),
                       desc=fill(item['desc']),
                       stats=table,
                       ammo=item.get('ammunition', ''))
Exemplo n.º 17
0
def _format_item_details(item):
    print(item)
    # The hackiest solution in the world
    # Todo: Evaluate replacing this method
    value = [i for i in item['attrs'] if i[0] == 'value'][0][1]
    weight = [i for i in item['attrs'] if i[0] == 'weight'][0][1]
    """Returns a piece of equipment's details and description."""
    stats = [["          |CPrice|n: {}".format(as_price(value)),
              "         |CWeight|n: |w{}|n".format(weight)],
             []]
    col1, col2 = stats
    # this is somewhat awkward because we're using prototype dicts instead
    # of instances of these classes.
    if item['typeclass'] in ("typeclasses.weapons.Weapon",
                             "typeclasses.weapons.TwoHandedWeapon",
                             "typeclasses.weapons.RangedWeapon",
                             "typeclasses.weapons.TwoHandedRanged",
                             "typeclasses.armors.Shield"):
        col2.append("     |CHandedness|n: |c{}H|n".format(
            2 if 'TwoHanded' in item['typeclass'] else 1
        ))

    if item['typeclass'] in ("typeclasses.weapons.Weapon",
                             "typeclasses.weapons.TwoHandedWeapon",
                             "typeclasses.weapons.RangedWeapon",
                             "typeclasses.weapons.TwoHandedRanged"):
        col2.append("         |CDamage|n: |r{}|n".format(item['damage']))

    if item['typeclass'] in ("typeclasses.weapons.RangedWeapon",
                             "typeclasses.weapons.TwoHandedRanged"):
        col2.append("          |CRange|n: |G{}|n".format(
            ", ".join([r.capitalize() for r in item['range']])))

    if item['typeclass'] in ("typeclasses.armors.Armor",
                             "typeclasses.armors.Shield"):
        col2.append("      |CToughness|n: |y{}|n".format(item['toughness']))

    if 'quantity' in item:
        col2.append("       |CQuantity|n: |w{}|n".format(item['quantity']))

    table = EvTable(header=False, table=stats, border=None)

    text = "|Y{name}|n\n"
    text += "{desc}\n"
    text += "{stats}\n"
    if 'ammunition' in item:
        text += "  This weapon requires ammunition: |w{ammo}|n\n"

    return text.format(name=item['key'].title(),
                       desc=fill(item['desc']),
                       stats=table,
                       ammo=item.get('ammunition', ''))
Exemplo n.º 18
0
def menunode_character_desc(caller, raw_string):
    """Enter a character description."""
    # add the previously entered description to the sdesc handler
    char = caller.new_char
    char.sdesc.add(raw_string)
    # prompt for desc property
    text = "Enter a more detailed description of your character's appearance. This will be\n" \
           "displayed when others look at your character explicitly."
    help = fill(
        "After character creation, your character's long description can be modified"
        "using the '@desc' command.")
    options = [{"key": "_default", "goto": "menunode_confirm"}]
    return (text, help), options
Exemplo n.º 19
0
def menunode_character_desc(caller, raw_string):
    """Enter a character description."""
    # add the previously entered description to the sdesc handler
    char = caller.new_char
    char.sdesc.add(raw_string)
    # prompt for desc property
    text = "Enter a more detailed description of your character's appearance. This will be\n" \
           "displayed when others look at your character explicitly."
    help = fill("After character creation, your character's long description can be modified"
                "using the '@desc' command.")
    options = [{"key": "_default",
                "goto": "menunode_confirm"}]
    return (text, help), options
Exemplo n.º 20
0
def menunode_chargen_ic_ooc(caller):
    """Explaining IC and OOC"""
    text = dedent("""\
        After you log in to your account, you must use the |y@ic <CharName>|n command to
        log in to a specific character.  'IC' stands for 'in character'.  You can use
        |y@ooc|n to drop back out to 'OOC' (out of character), and then switch to a
        different character.  There is also an |yooc|n command (without the @) which
        will send a message to the server-wide OOC chat channel.\n
        Enter any key to continue.
    """)
    help = fill(
        "After you exit character generation, type |mhelp @ic|n or |mhelp @ooc|n "
        "for more information.")
    options = ({"key": "_default", "goto": "menunode_chargen_end"})
    return (text, help), options
Exemplo n.º 21
0
    def __init__(self):
        super(Bard, self).__init__()
        self.name = 'Bard'
        self.desc = fill(
            "|cBards|n use their natural charm and ability to influence "
            "others to be useful to theri allies, and a detriment to those "
            "who would oppose them.")

        # set starting trait values
        self.traits['PER']['base'] = 4
        self.traits['INT']['base'] = 4
        self.traits['CHA']['base'] = 6
        self.traits['MAG']['base'] = 4

        self.health_roll = '1d8+6'
Exemplo n.º 22
0
    def __init__(self):
        super(Crusader, self).__init__()
        self.name = 'Crusader'
        self.desc = fill(
            "|cCrusaders|n are divine warriors seeking to enact their god/goddesses "
            "will wherever they may go. They often must deal with infidels and "
            "vermin who would otherwise oppose their righteous quest. ")

        # set starting trait values
        self.traits['STR']['base'] = 6
        self.traits['CHA']['base'] = 6
        self.traits['VIT']['base'] = 4
        self.traits['DEX']['base'] = 4

        self.health_roll = '1d10+10'
Exemplo n.º 23
0
    def desc(self):
        """Returns a formatted description of the Race.

        Note:
            The setter for this property only modifies the content
            of the first paragraph of what is returned.
        """
        desc = "|g{}|n\n".format(self.name)
        desc += fill(self._desc)
        desc += '\n\n'
        desc += fill("{} have a ".format(self.plural) +
                     "|y{}|n body type and can ".format(self.size) +
                     "select a |wfocus|n from among {}".format(
                         self._format_focus_list(self.foci)
                     ))
        if len(self.bonuses) > 0:
            desc += '\n\n'
            desc += fill("{} also gain {} of {}".format(
                        self.plural,
                        'bonuses' if len(self.bonuses) > 1 else 'a bonus',
                        _format_bonuses(self.bonuses))
                    )
        desc += '\n\n'
        return desc
Exemplo n.º 24
0
    def __init__(self):
        super(Battlemage, self).__init__()
        self.name = 'Battlemage'
        self.desc = fill(
            "|cBattlemages|n combine magic and martial prowess in order "
            "to engage in combat. Their spellcasting usually being on par "
            "with their martial combat. ")

        # set starting trait values
        self.traits['STR']['base'] = 6
        self.traits['MAG']['base'] = 6
        self.traits['VIT']['base'] = 5
        self.traits['DEX']['base'] = 5
        self.traits['REFL']['mod'] = 2

        self.health_roll = '1d8+10'
Exemplo n.º 25
0
def menunode_races(caller, raw_string):
    """Race listing menu node."""
    text = ""
    if raw_string and raw_string[0] == 'F':
        text += raw_string

    text += "\n\nNext, select a race for your character:"

    help = fill("Your race gives your character certain bonuses and "
                "detriments, and makes certain 'focuses' available. "
                "Select a race by number to see its details.")
    options = []
    for r in races.ALL_RACES:
        race = races.load_race(r)
        options.append({"desc": "{:<40.40s}...".format(race._desc),
                        "goto": "menunode_race_and_focuses"})
    return (text, help), options
Exemplo n.º 26
0
def menunode_races(caller, raw_string):
    """Race listing menu node."""
    text = ""
    if raw_string and raw_string[0] == 'F':
        text += raw_string

    text += "\n\nNext, select a race for your character:"

    help = fill("Your race gives your character certain bonuses and "
                "detriments, and makes certain 'focuses' available. "
                "Select a race by number to see its details.")
    options = []
    for r in races.ALL_RACES:
        race = races.load_race(r)
        options.append({"desc": "{:<40.40s}...".format(race._desc),
                        "goto": "menunode_race_and_focuses"})
    return (text, help), options
Exemplo n.º 27
0
    def __init__(self):
        super(Mage, self).__init__()
        self.name = 'Mage'
        self.desc = fill(
            "|cMages|n learn to work the magic that flows within them "
            "in order to cast magic at their own command.")

        # set starting trait values
        self.traits['INT']['base'] = 6
        self.traits['PER']['base'] = 4
        self.traits['CHA']['base'] = 4
        self.traits['MAG']['base'] = 6
        self.traits['SP']['mod'] = -2
        self.traits['WILL']['mod'] = 2
        self.traits['MV']['base'] = 7

        self.health_roll = '1d6+6'
Exemplo n.º 28
0
    def __init__(self):
        super(Rogue, self).__init__()
        self.name = 'Rogue'
        self.desc = fill(
            "|cRogues|n are masters of stealth, subterfuge, and "
            "experts at engaging in surprise encounters. "
            "Rogues are also incredibly skilled, allowing them to "
            "diversify their strengths.")

        # set starting trait values
        self.traits['INT']['base'] = 6
        self.traits['PER']['base'] = 5
        self.traits['DEX']['base'] = 6
        self.traits['REFL']['mod'] = 2
        self.traits['MV']['base'] = 7

        self.health_roll = '1d8+8'
Exemplo n.º 29
0
    def __init__(self):
        super(Scout, self).__init__()
        self.name = 'Scout'
        self.desc = fill(
            "|cScouts|n are highly intelligent and well-trained individuals "
            "who prefer to work their secret craft in the shadows where "
            "they remain unseen. Scouts go by many names such as thieves, "
            "rogues and rangers but little is known by general society of "
            "their closely guarded secrets. ")

        # set starting trait values
        self.traits['STR']['base'] = 4
        self.traits['PER']['base'] = 6
        self.traits['INT']['base'] = 6
        self.traits['DEX']['base'] = 4

        self.health_roll = '1d6'
Exemplo n.º 30
0
    def __init__(self):
        super(Arcanist, self).__init__()
        self.name = 'Arcanist'
        self.desc = fill(
            "|cArcanists|n harness mysterious, arcane powers they pull from "
            "the ether. These magic and paranormal wielders employ occult "
            "powers that only they truly understand.")

        # set starting trait values
        self.traits['PER']['base'] = 4
        self.traits['INT']['base'] = 6
        self.traits['CHA']['base'] = 4
        self.traits['MAG']['base'] = 6
        self.traits['SP']['mod'] = -2
        self.traits['MV']['base'] = 7

        self.health_roll = '1d6-1'
Exemplo n.º 31
0
def menunode_chargen_mask_recog(caller):
    """Explain Masking and Recognition"""
    text = dedent("""\
        The |y@recog|n command lets you 'recognize' someone and assign a name to
        their short description.  That is, you can 'recognize' that 'A young Chinese
        man' is 'Dr. Wang' and use that in future instances after you learn his name.\n  
        Sometimes, though, you don't want to be recognized.  You can use the |ymask|n
        command to set a temporary, different short description (see |whelp @sdesc|n)
        on yourself to 'hide' who you are, or masquerade as someone else.  Think of a
        Halloween costume as an example.  While you are masked, other people's |wrecog|n
        keyed to you, will no longer work until you |yunmask|n yourself.\n
        Enter any key to continue.
    """)
    help = fill(
        "After you exit character generation, type |mhelp @recog|n or |mhelp @mask|n "
        "for more information on recognition and masking.")
    options = ({"key": "_default", "goto": "menunode_chargen_ic_ooc"})
    return (text, help), options
Exemplo n.º 32
0
    def __init__(self):
        super(Scout, self).__init__()
        self.name = 'Scout'
        self.desc = fill(
            "|cScouts|n are highly intelligent and well-trained individuals "
            "who prefer to work their secret craft in the shadows where "
            "they remain unseen. Scouts go by many names such as thieves, "
            "rogues and rangers but little is known by general society of "
            "their closely guarded secrets. "
        )

        # set starting trait values
        self.traits['STR']['base'] = 4
        self.traits['PER']['base'] = 6
        self.traits['INT']['base'] = 6
        self.traits['DEX']['base'] = 4

        self.health_roll = '1d6'
Exemplo n.º 33
0
    def __init__(self):
        super(Arcanist, self).__init__()
        self.name = 'Arcanist'
        self.desc = fill(
            "|cArcanists|n harness mysterious, arcane powers they pull from "
            "the ether. These magic and paranormal wielders employ occult "
            "powers that only they truly understand."
        )

        # set starting trait values
        self.traits['PER']['base'] = 4
        self.traits['INT']['base'] = 6
        self.traits['CHA']['base'] = 4
        self.traits['MAG']['base'] = 6
        self.traits['SP']['mod'] = -2
        self.traits['MV']['base'] = 7

        self.health_roll = '1d6-1'
Exemplo n.º 34
0
    def format_help_entry(title, help_text, aliases=None, suggested=None):
        """
        This visually formats the help entry.
        This method can be overriden to customize the way a help
        entry is displayed.

        Args:
            title (str): the title of the help entry.
            help_text (str): the text of the help entry.
            aliases (list of str or None): the list of aliases.
            suggested (list of str or None): suggested reading.

        Returns the formatted string, ready to be sent.

        """
        title_and_aliases = [title] + aliases if aliases else [title]
        if suggested:
            suggested = [
                sug for sug in suggested if sug not in title_and_aliases
            ]

        start_chunk = f"{_SEP}\n"
        title_chunk = f"|CManuel pour |w{title}|n" if title else ""
        aliases_chunk = " |C(Alternatives: {}|C)|n" \
            .format("|C,|n ".join(f"|w{ali}|n" for ali in aliases)) \
            if aliases else ""
        help_text_chunk = f"\n{dedent(help_text.rstrip())}" \
            if help_text else ""
        suggested_chunk = \
            "\n\n|CSuggestions:|n {}" \
                .format(fill("|C,|n ".join(f"|w{sug}|n" for sug in suggested))) \
                if suggested else ""
        end_chunk = f"\n{_SEP}"

        help_entry_chunks = [
            start_chunk,
            title_chunk,
            aliases_chunk,
            help_text_chunk,
            suggested_chunk,
            end_chunk,
        ]
        string = "".join(help_entry_chunks)
        return string
Exemplo n.º 35
0
    def __init__(self):
        super(Warrior, self).__init__()
        self.name = 'Warrior'
        self.desc = fill(
            "|cWarriors|n are individual soldiers, mercenaries, bounty "
            "hunters or various types of combatants. They believe no "
            "problem can't be solved with their melee weapon and choose "
            "strength as their highest primary trait.")

        # set starting trait values
        self.traits['STR']['base'] = 6
        self.traits['DEX']['base'] = 4
        self.traits['CHA']['base'] = 4
        self.traits['VIT']['base'] = 6
        self.traits['REFL']['mod'] = -2
        self.traits['PP']['base'] = 2
        self.traits['MV']['base'] = 5

        self.health_roll = '1d6+1'
Exemplo n.º 36
0
def menunode_chargen_speed_sdesc(caller):
    """Confirm speed, call sdesc"""
    text = dedent("""\
        Your default speed has been set to |y%s|n.  You can change this
        later using the |w@setspeed|n command in-game.
        
        Now set a |wshort description|n for yourself.  A short description
        is what your character looks like at a glance when someone
        first sees them or doesn't recognize them.  For example, if your 
        short description is |c'A young Chinese man'|n, then people who 
        enter the room will see |w'A young Chinese man is reading a book'|n.
    """) % caller.new_char.attributes.get("move_speed")
    help = fill(
        "You can only have one short description at a time, which you can change "
        "with the |m@sdesc|n command.  You can also set longer, "
        "more detailed descriptions.  The next few steps will tell you how, "
        "and also introduce |wposes|n, |wmasking|n and |wrecognition|n.")
    options = ({"key": ("_default"), "goto": "menunode_chargen_sdesc_pose"})
    return (text, help), options
Exemplo n.º 37
0
def menunode_welcome_archetypes(caller):
    """Starting page and Archetype listing."""
    text = dedent("""\
        |wWelcome to |mDimensions RPG|w, a MUSH/RPG chat built with |yEvennia|w.|n

        To begin, select a |cClass|n.

        Select a class by number below to view its details, or |whelp|n
        at any time for more info.
    """)
    help = fill("In |mDimensions|n, character |cClasses|n represent the "
                "characters' archetype or primary role. The various classes "
                "have different strengths and weaknesses, which are reflected "
                "in your character's starting traits.")
    options = []
    for arch in archetypes.VALID_ARCHETYPES:
        a = archetypes.load_archetype(arch)
        options.append({"desc": "|c{}|n".format(a.name),
                        "goto": "menunode_select_archetype"})
    return (text, help), options
Exemplo n.º 38
0
    def __init__(self):
        super(Warrior, self).__init__()
        self.name = 'Warrior'
        self.desc = fill(
            "|cWarriors|n are individual soldiers, mercenaries, bounty "
            "hunters or various types of combatants. They believe no "
            "problem can't be solved with their melee weapon and choose "
            "strength as their highest primary trait."
        )

        # set starting trait values
        self.traits['STR']['base'] = 6
        self.traits['DEX']['base'] = 4
        self.traits['CHA']['base'] = 4
        self.traits['VIT']['base'] = 6
        self.traits['REFL']['mod'] = -2
        self.traits['PP']['base'] = 2
        self.traits['MV']['base'] = 5

        self.health_roll = '1d6+1'
Exemplo n.º 39
0
def menunode_welcome_archetypes(caller):
    """Starting page and Archetype listing."""
    text = dedent("""\
        |wWelcome to |mAinneve|w, the example game for |yEvennia|w.|n

        To begin, select an |cArchetype|n. There are three base
        archetypes to choose from, plus three dual archetypes which
        combine the strengths and weaknesses of two archetypes into one.

        Select an Archetype by number below to view its details, or |whelp|n
        at any time for more info.
    """)
    help = fill("In |mAinneve|n, character |cArchetypes|n represent the "
                "characters' class or primary role. The various archetypes "
                "have different strengths and weaknesses, which are reflected "
                "in your character's starting traits.")
    options = []
    for arch in archetypes.VALID_ARCHETYPES:
        a = archetypes.load_archetype(arch)
        options.append({"desc": "|c{}|n".format(a.name),
                        "goto": "menunode_select_archetype"})
    return (text, help), options
Exemplo n.º 40
0
def menunode_race_and_focuses(caller, raw_string):
    """Race detail and focus listing menu node."""
    raw_string = raw_string.strip()
    if raw_string.isdigit() and int(raw_string) <= len(races.ALL_RACES):
        race = races.ALL_RACES[int(raw_string) - 1]
        race = races.load_race(race)
        caller.ndb._menutree.race = race

    race = caller.ndb._menutree.race

    text = race.desc + "Select a focus below to continue:"
    help = fill("After selecting a focus, you will be prompted "
                "to save your race/focus combination.")

    options = [{"desc": f.name,
                "goto": "menunode_select_race_focus"}
               for f in race.foci]
    options.append({"key": ("Back", "_default"),
                    "desc": "Return to Race selection",
                    "goto": "menunode_races"})

    return (text, help), options
Exemplo n.º 41
0
def menunode_welcome_archetypes(caller):
    """Starting page and Archetype listing."""
    text = dedent("""\
        |wWelcome to |mAinneve|w, the example game for |yEvennia|w.|n

        To begin, select an |cArchetype|n. There are three base
        archetypes to choose from, plus three dual archetypes which
        combine the strengths and weaknesses of two archetypes into one.

        Select an Archetype by number below to view its details, or |whelp|n
        at any time for more info.
    """)
    help = fill("In |mAinneve|n, character |cArchetypes|n represent the "
                "characters' class or primary role. The various archetypes "
                "have different strengths and weaknesses, which are reflected "
                "in your character's starting traits.")
    options = []
    for arch in archetypes.VALID_ARCHETYPES:
        a = archetypes.load_archetype(arch)
        options.append({"desc": "|c{}|n".format(a.name),
                        "goto": "menunode_select_archetype"})
    return (text, help), options
Exemplo n.º 42
0
JAVELIN = {
    "key": "a javelin",
    "aliases": ["javelin"],
    "typeclass": "typeclasses.weapons.RangedWeapon",
    "desc": "Long and light, the javelin has the longest range of thrown "
            "weapons.",
    "weight": 1,
    "value": 15*CC,
    "damage": 1,
    "range": 6,
}

TRIDENT = {
    "key": "a trident",
    "aliases": ["trident"],
    "typeclass": "typeclasses.weapons.RangedWeapon",
    "desc": "The trident's triple-pointed metal spearhead is heavy and "
            "inflicts the most damage of the thrown weapons.",
    "weight": 2,
    "value": 1*SC,
    "damage": 2,
    "range": 2,
}


# format all `desc` properties consistently
for proto in globals().values():
    if isinstance(proto, dict) and 'desc' in proto:
        proto['desc'] = fill(proto['desc'])

Exemplo n.º 43
0
 def _show_prototypes(prototypes):
     "Helper to show a list of available prototypes"
     string = "\nAvailable prototypes:\n %s"
     string %= utils.fill(", ".join(sorted(prototypes.keys())))
     return string
Exemplo n.º 44
0
    def func(self):
        """
        This command handles all the in-editor :-style commands. Since
        each command is small and very limited, this makes for a more
        efficient presentation.
        """
        caller = self.caller
        editor = caller.ndb._eveditor

        linebuffer = self.linebuffer
        lstart, lend = self.lstart, self.lend
        cmd = self.cmdstring
        echo_mode = self.editor._echo_mode

        if cmd == ":":
            # Echo buffer
            if self.linerange:
                buf = linebuffer[lstart:lend]
                editor.display_buffer(buf=buf, offset=lstart)
            else:
                editor.display_buffer()
        elif cmd == "::":
            # Echo buffer without the line numbers and syntax parsing
            if self.linerange:
                buf = linebuffer[lstart:lend]
                editor.display_buffer(buf=buf,
                                      offset=lstart,
                                      linenums=False,
                                      options={"raw": True})
            else:
                editor.display_buffer(linenums=False, options={"raw": True})
        elif cmd == ":::":
            # Insert single colon alone on a line
            editor.update_buffer([":"] if lstart == 0 else linebuffer + [":"])
            if echo_mode:
                caller.msg("Single ':' added to buffer.")
        elif cmd == ":h":
            # help entry
            editor.display_help()
        elif cmd == ":w":
            # save without quitting
            editor.save_buffer()
        elif cmd == ":wq":
            # save and quit
            editor.save_buffer()
            editor.quit()
        elif cmd == ":q":
            # quit. If not saved, will ask
            if self.editor._unsaved:
                caller.cmdset.add(SaveYesNoCmdSet)
                caller.msg(
                    "Save before quitting? |lcyes|lt[Y]|le/|lcno|ltN|le")
            else:
                editor.quit()
        elif cmd == ":q!":
            # force quit, not checking saving
            editor.quit()
        elif cmd == ":u":
            # undo
            editor.update_undo(-1)
        elif cmd == ":uu":
            # redo
            editor.update_undo(1)
        elif cmd == ":UU":
            # reset buffer
            editor.update_buffer(editor._pristine_buffer)
            caller.msg(
                "Reverted all changes to the buffer back to original state.")
        elif cmd == ":dd":
            # :dd <l> - delete line <l>
            buf = linebuffer[:lstart] + linebuffer[lend:]
            editor.update_buffer(buf)
            caller.msg("Deleted %s." % self.lstr)
        elif cmd == ":dw":
            # :dw <w> - delete word in entire buffer
            # :dw <l> <w> delete word only on line(s) <l>
            if not self.arg1:
                caller.msg("You must give a search word to delete.")
            else:
                if not self.linerange:
                    lstart = 0
                    lend = self.cline + 1
                    caller.msg("Removed %s for lines %i-%i." %
                               (self.arg1, lstart + 1, lend + 1))
                else:
                    caller.msg("Removed %s for %s." % (self.arg1, self.lstr))
                sarea = "\n".join(linebuffer[lstart:lend])
                sarea = re.sub(r"%s" % self.arg1.strip("\'").strip('\"'), "",
                               sarea, re.MULTILINE)
                buf = linebuffer[:lstart] + sarea.split(
                    "\n") + linebuffer[lend:]
                editor.update_buffer(buf)
        elif cmd == ":DD":
            # clear buffer
            editor.update_buffer("")

            # Reset indentation level to 0
            if editor._codefunc:
                if editor._indent >= 0:
                    editor._indent = 0
                    if editor._persistent:
                        caller.attributes.add("_eveditor_indent", 0)
            caller.msg("Cleared %i lines from buffer." % self.nlines)
        elif cmd == ":y":
            # :y <l> - yank line(s) to copy buffer
            cbuf = linebuffer[lstart:lend]
            editor._copy_buffer = cbuf
            caller.msg("%s, %s yanked." % (self.lstr.capitalize(), cbuf))
        elif cmd == ":x":
            # :x <l> - cut line to copy buffer
            cbuf = linebuffer[lstart:lend]
            editor._copy_buffer = cbuf
            buf = linebuffer[:lstart] + linebuffer[lend:]
            editor.update_buffer(buf)
            caller.msg("%s, %s cut." % (self.lstr.capitalize(), cbuf))
        elif cmd == ":p":
            # :p <l> paste line(s) from copy buffer
            if not editor._copy_buffer:
                caller.msg("Copy buffer is empty.")
            else:
                buf = linebuffer[:lstart] + editor._copy_buffer + linebuffer[
                    lstart:]
                editor.update_buffer(buf)
                caller.msg("Copied buffer %s to %s." %
                           (editor._copy_buffer, self.lstr))
        elif cmd == ":i":
            # :i <l> <txt> - insert new line
            new_lines = self.args.split('\n')
            if not new_lines:
                caller.msg(
                    "You need to enter a new line and where to insert it.")
            else:
                buf = linebuffer[:lstart] + new_lines + linebuffer[lstart:]
                editor.update_buffer(buf)
                caller.msg("Inserted %i new line(s) at %s." %
                           (len(new_lines), self.lstr))
        elif cmd == ":r":
            # :r <l> <txt> - replace lines
            new_lines = self.args.split('\n')
            if not new_lines:
                caller.msg("You need to enter a replacement string.")
            else:
                buf = linebuffer[:lstart] + new_lines + linebuffer[lend:]
                editor.update_buffer(buf)
                caller.msg("Replaced %i line(s) at %s." %
                           (len(new_lines), self.lstr))
        elif cmd == ":I":
            # :I <l> <txt> - insert text at beginning of line(s) <l>
            if not self.raw_string and not editor._codefunc:
                caller.msg("You need to enter text to insert.")
            else:
                buf = linebuffer[:lstart] + [
                    "%s%s" % (self.args, line)
                    for line in linebuffer[lstart:lend]
                ] + linebuffer[lend:]
                editor.update_buffer(buf)
                caller.msg("Inserted text at beginning of %s." % self.lstr)
        elif cmd == ":A":
            # :A <l> <txt> - append text after end of line(s)
            if not self.args:
                caller.msg("You need to enter text to append.")
            else:
                buf = linebuffer[:lstart] + [
                    "%s%s" % (line, self.args)
                    for line in linebuffer[lstart:lend]
                ] + linebuffer[lend:]
                editor.update_buffer(buf)
                caller.msg("Appended text to end of %s." % self.lstr)
        elif cmd == ":s":
            # :s <li> <w> <txt> - search and replace words
            # in entire buffer or on certain lines
            if not self.arg1 or not self.arg2:
                caller.msg(
                    "You must give a search word and something to replace it with."
                )
            else:
                if not self.linerange:
                    lstart = 0
                    lend = self.cline + 1
                    caller.msg("Search-replaced %s -> %s for lines %i-%i." %
                               (self.arg1, self.arg2, lstart + 1, lend))
                else:
                    caller.msg("Search-replaced %s -> %s for %s." %
                               (self.arg1, self.arg2, self.lstr))
                sarea = "\n".join(linebuffer[lstart:lend])

                regex = r"%s|^%s(?=\s)|(?<=\s)%s(?=\s)|^%s$|(?<=\s)%s$"
                regarg = self.arg1.strip("\'").strip('\"')
                if " " in regarg:
                    regarg = regarg.replace(" ", " +")
                sarea = re.sub(
                    regex % (regarg, regarg, regarg, regarg, regarg),
                    self.arg2.strip("\'").strip('\"'), sarea, re.MULTILINE)
                buf = linebuffer[:lstart] + sarea.split(
                    "\n") + linebuffer[lend:]
                editor.update_buffer(buf)
        elif cmd == ":f":
            # :f <l> flood-fill buffer or <l> lines of buffer.
            width = _DEFAULT_WIDTH
            if not self.linerange:
                lstart = 0
                lend = self.cline + 1
                caller.msg("Flood filled lines %i-%i." % (lstart + 1, lend))
            else:
                caller.msg("Flood filled %s." % self.lstr)
            fbuf = "\n".join(linebuffer[lstart:lend])
            fbuf = fill(fbuf, width=width)
            buf = linebuffer[:lstart] + fbuf.split("\n") + linebuffer[lend:]
            editor.update_buffer(buf)
        elif cmd == ":j":
            # :f <l> <w>  justify buffer of <l> with <w> as align (one of
            # f(ull), c(enter), r(ight) or l(left). Default is full.
            align_map = {
                "full": "f",
                "f": "f",
                "center": "c",
                "c": "c",
                "right": "r",
                "r": "r",
                "left": "l",
                "l": "l"
            }
            align_name = {
                "f": "Full",
                "c": "Center",
                "l": "Left",
                "r": "Right"
            }
            width = _DEFAULT_WIDTH
            if self.arg1 and self.arg1.lower() not in align_map:
                self.caller.msg(
                    "Valid justifications are [f]ull (default), [c]enter, [r]right or [l]eft"
                )
                return
            align = align_map[self.arg1.lower()] if self.arg1 else 'f'
            if not self.linerange:
                lstart = 0
                lend = self.cline + 1
                self.caller.msg("%s-justified lines %i-%i." %
                                (align_name[align], lstart + 1, lend))
            else:
                self.caller.msg("%s-justified %s." %
                                (align_name[align], self.lstr))
            jbuf = "\n".join(linebuffer[lstart:lend])
            jbuf = justify(jbuf, width=width, align=align)
            buf = linebuffer[:lstart] + jbuf.split("\n") + linebuffer[lend:]
            editor.update_buffer(buf)
        elif cmd == ":fi":
            # :fi <l> indent buffer or lines <l> of buffer.
            indent = " " * 4
            if not self.linerange:
                lstart = 0
                lend = self.cline + 1
                caller.msg("Indented lines %i-%i." % (lstart + 1, lend))
            else:
                caller.msg("Indented %s." % self.lstr)
            fbuf = [indent + line for line in linebuffer[lstart:lend]]
            buf = linebuffer[:lstart] + fbuf + linebuffer[lend:]
            editor.update_buffer(buf)
        elif cmd == ":fd":
            # :fi <l> indent buffer or lines <l> of buffer.
            if not self.linerange:
                lstart = 0
                lend = self.cline + 1
                caller.msg("Removed left margin (dedented) lines %i-%i." %
                           (lstart + 1, lend))
            else:
                caller.msg("Removed left margin (dedented) %s." % self.lstr)
            fbuf = "\n".join(linebuffer[lstart:lend])
            fbuf = dedent(fbuf)
            buf = linebuffer[:lstart] + fbuf.split("\n") + linebuffer[lend:]
            editor.update_buffer(buf)
        elif cmd == ":echo":
            # set echoing on/off
            editor._echo_mode = not editor._echo_mode
            caller.msg("Echo mode set to %s" % editor._echo_mode)
        elif cmd == ":!":
            if editor._codefunc:
                editor._codefunc(caller, editor._buffer)
            else:
                caller.msg(
                    "This command is only available in code editor mode.")
        elif cmd == ":<":
            # :<
            if editor._codefunc:
                editor.decrease_indent()
                indent = editor._indent
                if indent >= 0:
                    caller.msg(
                        "Decreased indentation: new indentation is {}.".format(
                            indent))
                else:
                    caller.msg(
                        "|rManual indentation is OFF.|n Use := to turn it on.")
            else:
                caller.msg(
                    "This command is only available in code editor mode.")
        elif cmd == ":>":
            # :>
            if editor._codefunc:
                editor.increase_indent()
                indent = editor._indent
                if indent >= 0:
                    caller.msg(
                        "Increased indentation: new indentation is {}.".format(
                            indent))
                else:
                    caller.msg(
                        "|rManual indentation is OFF.|n Use := to turn it on.")
            else:
                caller.msg(
                    "This command is only available in code editor mode.")
        elif cmd == ":=":
            # :=
            if editor._codefunc:
                editor.swap_autoindent()
                indent = editor._indent
                if indent >= 0:
                    caller.msg("Auto-indentation turned on.")
                else:
                    caller.msg("Auto-indentation turned off.")
            else:
                caller.msg(
                    "This command is only available in code editor mode.")
Exemplo n.º 45
0
    'Melee Weapons':
    (0, 'HAND_AXE', 'BATTLE_AXE', 'MAUL_HAMMER', 'LANCE_POLEARM',
     'PIKE_POLEARM', 'MAPLE_STAFF', 'MACE_ROD', 'MORNINGSTAR_ROD', 'SCYTHE',
     'SHORT_SWORD', 'RAPIER', 'WHIP'),
    'Ranged Weapons': (1, 'LONG_BOW', 'HAND_CROSSBOW', 'LIGHT_CROSSBOW'),
    'Ammunition': (5, 'ARROW_BUNDLE', 'QUARREL_BUNDLE'),
    'Thrown Weapons':
    (2, 'THROWING_AXE', 'THROWING_DAGGER', 'JAVELIN', 'TRIDENT'),
    'Armor': (3, 'CLOTH_GARMENT', 'LEATHER_GARMENT', 'BRIGANDINE',
              'CHAIN_MAIL', 'PLATED_MAIL', 'IRON_SCALE', 'IRON_BANDED'),
    'Shields': (4, 'BUCKLER_SHIELD', 'HERALDIC_SHIELD', 'TOWER_SHIELD'),
}
_CATEGORY_HELP = {
    'Melee Weapons':
    fill('These weapons are used in close combat. Their |rDamage|n '
         'statistic is added to your |CStrength|n trait to determine '
         'your attack score in combat.'),
    'Ranged Weapons':
    fill('These weapons require ammunition, and are used to attack from a '
         'distance. Their |rDamage\n statistic is added to your '
         '|CPerception|n trait to determine your attack score in combat.'),
    'Ammunition':
    'Ranged weapons require these items in order to attack.',
    'Thrown Weapons':
    fill('These ranged weapons do not require ammunition, as they are'
         'thrown at their target.'),
    'Armor':
    fill('Suited armor provides protection from damage. Their '
         '|yToughness|n statistic is added to your |CDexterity|n trait '
         'to determine your defense score in combat.'),
    'Shields':
Exemplo n.º 46
0
    'Ranged Weapons':
        (1, 'LONG_BOW', 'HAND_CROSSBOW', 'LIGHT_CROSSBOW'),
    'Ammunition':
        (5, 'ARROW_BUNDLE', 'QUARREL_BUNDLE'),
    'Thrown Weapons':
        (2, 'THROWING_AXE', 'THROWING_DAGGER', 'JAVELIN', 'TRIDENT'),
    'Armor':
        (3, 'CLOTH_GARMENT', 'LEATHER_GARMENT', 'BRIGANDINE', 'CHAIN_MAIL',
         'PLATED_MAIL', 'IRON_SCALE', 'IRON_BANDED'),
    'Shields':
        (4, 'BUCKLER_SHIELD', 'HERALDIC_SHIELD', 'TOWER_SHIELD'),
}
_CATEGORY_HELP = {
    'Melee Weapons':
        fill('These weapons are used in close combat. Their |rDamage|n '
             'statistic is added to your |CStrength|n trait to determine '
             'your attack score in combat.'),
    'Ranged Weapons':
        fill('These weapons require ammunition, and are used to attack from a '
             'distance. Their |rDamage\n statistic is added to your '
             '|CPerception|n trait to determine your attack score in combat.'),
    'Ammunition':
        'Ranged weapons require these items in order to attack.',
    'Thrown Weapons':
        fill('These ranged weapons do not require ammunition, as they are'
             'thrown at their target.'),
    'Armor':
        fill('Suited armor provides protection from damage. Their '
             '|yToughness|n statistic is added to your |CDexterity|n trait '
             'to determine your defense score in combat.'),
    'Shields':
Exemplo n.º 47
0
    def func(self):
        """
        This command handles all the in-editor :-style commands. Since
        each command is small and very limited, this makes for a more
        efficient presentation.
        """
        caller = self.caller
        editor = self.editor
        linebuffer = self.linebuffer
        lstart, lend = self.lstart, self.lend
        cmd = self.cmdstring
        echo_mode = self.editor._echo_mode

        if cmd == ":":
            # Echo buffer
            if self.linerange:
                buf = linebuffer[lstart:lend]
                editor.display_buffer(buf=buf, offset=lstart)
            else:
                editor.display_buffer()
        elif cmd == "::":
            # Echo buffer without the line numbers and syntax parsing
            if self.linerange:
                buf = linebuffer[lstart:lend]
                editor.display_buffer(buf=buf,
                                      offset=lstart,
                                      linenums=False, raw=True)
            else:
                editor.display_buffer(linenums=False, raw=True)
        elif cmd == ":::":
            # Insert single colon alone on a line
            editor.update_buffer(editor.buffer + "\n:")
            if echo_mode:
                caller.msg("Single ':' added to buffer.")
        elif cmd == ":h":
            # help entry
            editor.display_help()
        elif cmd == ":w":
            # save without quitting
            editor.save_buffer()
        elif cmd == ":wq":
            # save and quit
            editor.save_buffer()
            editor.quit()
        elif cmd == ":q":
            # quit. If not saved, will ask
            if self.editor._unsaved:
                caller.cmdset.add(SaveYesNoCmdSet)
                caller.msg("Save before quitting? {lcyes{lt[Y]{le/{lcno{ltN{le")
            else:
                editor.quit()
        elif cmd == ":q!":
            # force quit, not checking saving
            editor.quit()
        elif cmd == ":u":
            # undo
            editor.update_undo(-1)
        elif cmd == ":uu":
            # redo
            editor.update_undo(1)
        elif cmd == ":UU":
            # reset buffer
            editor.update_buffer(editor._pristine_buffer)
            caller.msg("Reverted all changes to the buffer back to original state.")
        elif cmd == ":dd":
            # :dd <l> - delete line <l>
            buf = linebuffer[:lstart] + linebuffer[lend:]
            editor.update_buffer(buf)
            caller.msg("Deleted %s." % (self.lstr))
        elif cmd == ":dw":
            # :dw <w> - delete word in entire buffer
            # :dw <l> <w> delete word only on line(s) <l>
            if not self.arg1:
                caller.msg("You must give a search word to delete.")
            else:
                if not self.linerange:
                    lstart = 0
                    lend = self.cline + 1
                    caller.msg("Removed %s for lines %i-%i." % (self.arg1, lstart + 1, lend + 1))
                else:
                    caller.msg("Removed %s for %s." % (self.arg1, self.lstr))
                sarea = "\n".join(linebuffer[lstart:lend])
                sarea = re.sub(r"%s" % self.arg1.strip("\'").strip('\"'), "", sarea, re.MULTILINE)
                buf = linebuffer[:lstart] + sarea.split("\n") + linebuffer[lend:]
                editor.update_buffer(buf)
        elif cmd == ":DD":
            # clear buffer
            editor.update_buffer("")
            caller.msg("Cleared %i lines from buffer." % self.nlines)
        elif cmd == ":y":
            # :y <l> - yank line(s) to copy buffer
            cbuf = linebuffer[lstart:lend]
            editor._copy_buffer = cbuf
            caller.msg("%s, %s yanked." % (self.lstr.capitalize(), cbuf))
        elif cmd == ":x":
            # :x <l> - cut line to copy buffer
            cbuf = linebuffer[lstart:lend]
            editor._copy_buffer = cbuf
            buf = linebuffer[:lstart] + linebuffer[lend:]
            editor.update_buffer(buf)
            caller.msg("%s, %s cut." % (self.lstr.capitalize(), cbuf))
        elif cmd == ":p":
            # :p <l> paste line(s) from copy buffer
            if not editor._copy_buffer:
                caller.msg("Copy buffer is empty.")
            else:
                buf = linebuffer[:lstart] + editor._copy_buffer + linebuffer[lstart:]
                editor.update_buffer(buf)
                caller.msg("Copied buffer %s to %s." % (editor._copy_buffer, self.lstr))
        elif cmd == ":i":
            # :i <l> <txt> - insert new line
            new_lines = self.args.split('\n')
            if not new_lines:
                caller.msg("You need to enter a new line and where to insert it.")
            else:
                buf = linebuffer[:lstart] + new_lines + linebuffer[lstart:]
                editor.update_buffer(buf)
                caller.msg("Inserted %i new line(s) at %s." % (len(new_lines), self.lstr))
        elif cmd == ":r":
            # :r <l> <txt> - replace lines
            new_lines = self.args.split('\n')
            if not new_lines:
                caller.msg("You need to enter a replacement string.")
            else:
                buf = linebuffer[:lstart] + new_lines + linebuffer[lend:]
                editor.update_buffer(buf)
                caller.msg("Replaced %i line(s) at %s." % (len(new_lines), self.lstr))
        elif cmd == ":I":
            # :I <l> <txt> - insert text at beginning of line(s) <l>
            if not self.args:
                caller.msg("You need to enter text to insert.")
            else:
                buf = linebuffer[:lstart] + ["%s%s" % (self.args, line) for line in linebuffer[lstart:lend]] + linebuffer[lend:]
                editor.update_buffer(buf)
                caller.msg("Inserted text at beginning of %s." % self.lstr)
        elif cmd == ":A":
            # :A <l> <txt> - append text after end of line(s)
            if not self.args:
                caller.msg("You need to enter text to append.")
            else:
                buf = linebuffer[:lstart] + ["%s%s" % (line, self.args) for line in linebuffer[lstart:lend]] + linebuffer[lend:]
                editor.update_buffer(buf)
                caller.msg("Appended text to end of %s." % self.lstr)
        elif cmd == ":s":
            # :s <li> <w> <txt> - search and replace words
            # in entire buffer or on certain lines
            if not self.arg1 or not self.arg2:
                caller.msg("You must give a search word and something to replace it with.")
            else:
                if not self.linerange:
                    lstart = 0
                    lend = self.cline + 1
                    caller.msg("Search-replaced %s -> %s for lines %i-%i." % (self.arg1, self.arg2, lstart + 1 , lend))
                else:
                    caller.msg("Search-replaced %s -> %s for %s." % (self.arg1, self.arg2, self.lstr))
                sarea = "\n".join(linebuffer[lstart:lend])

                regex = r"%s|^%s(?=\s)|(?<=\s)%s(?=\s)|^%s$|(?<=\s)%s$"
                regarg = self.arg1.strip("\'").strip('\"')
                if " " in regarg:
                    regarg = regarg.replace(" ", " +")
                sarea = re.sub(regex % (regarg, regarg, regarg, regarg, regarg), self.arg2.strip("\'").strip('\"'), sarea, re.MULTILINE)
                buf = linebuffer[:lstart] + sarea.split("\n") + linebuffer[lend:]
                editor.update_buffer(buf)
        elif cmd == ":f":
            # :f <l> flood-fill buffer or <l> lines of buffer.
            width = _DEFAULT_WIDTH
            if not self.linerange:
                lstart = 0
                lend = self.cline + 1
                caller.msg("Flood filled lines %i-%i." % (lstart + 1 , lend))
            else:
                caller.msg("Flood filled %s." % self.lstr)
            fbuf = "\n".join(linebuffer[lstart:lend])
            fbuf = fill(fbuf, width=width)
            buf = linebuffer[:lstart] + fbuf.split("\n") + linebuffer[lend:]
            editor.update_buffer(buf)
        elif cmd == ":fi":
            # :fi <l> indent buffer or lines <l> of buffer.
            indent = " " * 4
            if not self.linerange:
                lstart = 0
                lend = self.cline + 1
                caller.msg("Indented lines %i-%i." % (lstart + 1 , lend))
            else:
                caller.msg("Indented %s." % self.lstr)
            fbuf = [indent + line for line in linebuffer[lstart:lend]]
            buf = linebuffer[:lstart] + fbuf + linebuffer[lend:]
            editor.update_buffer(buf)
        elif cmd == ":fd":
            # :fi <l> indent buffer or lines <l> of buffer.
            if not self.linerange:
                lstart = 0
                lend = self.cline + 1
                caller.msg("Removed left margin (dedented) lines %i-%i." % (lstart + 1 , lend))
            else:
                caller.msg("Removed left margin (dedented) %s." % self.lstr)
            fbuf = "\n".join(linebuffer[lstart:lend])
            fbuf = dedent(fbuf)
            buf = linebuffer[:lstart] + fbuf.split("\n") + linebuffer[lend:]
            editor.update_buffer(buf)
        elif cmd == ":echo":
            # set echoing on/off
            editor._echo_mode = not editor._echo_mode
            caller.msg("Echo mode set to %s" % editor._echo_mode)
Exemplo n.º 48
0
    def func(self):
        """
        This command handles all the in-editor :-style commands. Since
        each command is small and very limited, this makes for a more
        efficient presentation.
        """
        caller = self.caller
        editor = caller.ndb._eveditor

        linebuffer = self.linebuffer
        lstart, lend = self.lstart, self.lend
        cmd = self.cmdstring
        echo_mode = self.editor._echo_mode

        if cmd == ":":
            # Echo buffer
            if self.linerange:
                buf = linebuffer[lstart:lend]
                editor.display_buffer(buf=buf, offset=lstart)
            else:
                editor.display_buffer()
        elif cmd == "::":
            # Echo buffer without the line numbers and syntax parsing
            if self.linerange:
                buf = linebuffer[lstart:lend]
                editor.display_buffer(buf=buf,
                                      offset=lstart,
                                      linenums=False, options={"raw": True})
            else:
                editor.display_buffer(linenums=False, options={"raw": True})
        elif cmd == ":::":
            # Insert single colon alone on a line
            editor.update_buffer([":"] if lstart == 0 else linebuffer + [":"])
            if echo_mode:
                caller.msg("Single ':' added to buffer.")
        elif cmd == ":h":
            # help entry
            editor.display_help()
        elif cmd == ":w":
            # save without quitting
            editor.save_buffer()
        elif cmd == ":wq":
            # save and quit
            editor.save_buffer()
            editor.quit()
        elif cmd == ":q":
            # quit. If not saved, will ask
            if self.editor._unsaved:
                caller.cmdset.add(SaveYesNoCmdSet)
                caller.msg("Save before quitting? |lcyes|lt[Y]|le/|lcno|ltN|le")
            else:
                editor.quit()
        elif cmd == ":q!":
            # force quit, not checking saving
            editor.quit()
        elif cmd == ":u":
            # undo
            editor.update_undo(-1)
        elif cmd == ":uu":
            # redo
            editor.update_undo(1)
        elif cmd == ":UU":
            # reset buffer
            editor.update_buffer(editor._pristine_buffer)
            caller.msg("Reverted all changes to the buffer back to original state.")
        elif cmd == ":dd":
            # :dd <l> - delete line <l>
            buf = linebuffer[:lstart] + linebuffer[lend:]
            editor.update_buffer(buf)
            caller.msg("Deleted %s." % self.lstr)
        elif cmd == ":dw":
            # :dw <w> - delete word in entire buffer
            # :dw <l> <w> delete word only on line(s) <l>
            if not self.arg1:
                caller.msg("You must give a search word to delete.")
            else:
                if not self.linerange:
                    lstart = 0
                    lend = self.cline + 1
                    caller.msg("Removed %s for lines %i-%i." % (self.arg1, lstart + 1, lend + 1))
                else:
                    caller.msg("Removed %s for %s." % (self.arg1, self.lstr))
                sarea = "\n".join(linebuffer[lstart:lend])
                sarea = re.sub(r"%s" % self.arg1.strip("\'").strip('\"'), "", sarea, re.MULTILINE)
                buf = linebuffer[:lstart] + sarea.split("\n") + linebuffer[lend:]
                editor.update_buffer(buf)
        elif cmd == ":DD":
            # clear buffer
            editor.update_buffer("")

            # Reset indentation level to 0
            if editor._codefunc:
                if editor._indent >= 0:
                    editor._indent = 0
                    if editor._persistent:
                        caller.attributes.add("_eveditor_indent", 0)
            caller.msg("Cleared %i lines from buffer." % self.nlines)
        elif cmd == ":y":
            # :y <l> - yank line(s) to copy buffer
            cbuf = linebuffer[lstart:lend]
            editor._copy_buffer = cbuf
            caller.msg("%s, %s yanked." % (self.lstr.capitalize(), cbuf))
        elif cmd == ":x":
            # :x <l> - cut line to copy buffer
            cbuf = linebuffer[lstart:lend]
            editor._copy_buffer = cbuf
            buf = linebuffer[:lstart] + linebuffer[lend:]
            editor.update_buffer(buf)
            caller.msg("%s, %s cut." % (self.lstr.capitalize(), cbuf))
        elif cmd == ":p":
            # :p <l> paste line(s) from copy buffer
            if not editor._copy_buffer:
                caller.msg("Copy buffer is empty.")
            else:
                buf = linebuffer[:lstart] + editor._copy_buffer + linebuffer[lstart:]
                editor.update_buffer(buf)
                caller.msg("Copied buffer %s to %s." % (editor._copy_buffer, self.lstr))
        elif cmd == ":i":
            # :i <l> <txt> - insert new line
            new_lines = self.args.split('\n')
            if not new_lines:
                caller.msg("You need to enter a new line and where to insert it.")
            else:
                buf = linebuffer[:lstart] + new_lines + linebuffer[lstart:]
                editor.update_buffer(buf)
                caller.msg("Inserted %i new line(s) at %s." % (len(new_lines), self.lstr))
        elif cmd == ":r":
            # :r <l> <txt> - replace lines
            new_lines = self.args.split('\n')
            if not new_lines:
                caller.msg("You need to enter a replacement string.")
            else:
                buf = linebuffer[:lstart] + new_lines + linebuffer[lend:]
                editor.update_buffer(buf)
                caller.msg("Replaced %i line(s) at %s." % (len(new_lines), self.lstr))
        elif cmd == ":I":
            # :I <l> <txt> - insert text at beginning of line(s) <l>
            if not self.raw_string and not editor._codefunc:
                caller.msg("You need to enter text to insert.")
            else:
                buf = linebuffer[:lstart] + ["%s%s" % (self.args, line)
                                             for line in linebuffer[lstart:lend]] + linebuffer[lend:]
                editor.update_buffer(buf)
                caller.msg("Inserted text at beginning of %s." % self.lstr)
        elif cmd == ":A":
            # :A <l> <txt> - append text after end of line(s)
            if not self.args:
                caller.msg("You need to enter text to append.")
            else:
                buf = linebuffer[:lstart] + ["%s%s" % (line, self.args)
                                             for line in linebuffer[lstart:lend]] + linebuffer[lend:]
                editor.update_buffer(buf)
                caller.msg("Appended text to end of %s." % self.lstr)
        elif cmd == ":s":
            # :s <li> <w> <txt> - search and replace words
            # in entire buffer or on certain lines
            if not self.arg1 or not self.arg2:
                caller.msg("You must give a search word and something to replace it with.")
            else:
                if not self.linerange:
                    lstart = 0
                    lend = self.cline + 1
                    caller.msg("Search-replaced %s -> %s for lines %i-%i." % (self.arg1, self.arg2, lstart + 1, lend))
                else:
                    caller.msg("Search-replaced %s -> %s for %s." % (self.arg1, self.arg2, self.lstr))
                sarea = "\n".join(linebuffer[lstart:lend])

                regex = r"%s|^%s(?=\s)|(?<=\s)%s(?=\s)|^%s$|(?<=\s)%s$"
                regarg = self.arg1.strip("\'").strip('\"')
                if " " in regarg:
                    regarg = regarg.replace(" ", " +")
                sarea = re.sub(regex % (regarg, regarg, regarg, regarg, regarg), self.arg2.strip("\'").strip('\"'),
                               sarea, re.MULTILINE)
                buf = linebuffer[:lstart] + sarea.split("\n") + linebuffer[lend:]
                editor.update_buffer(buf)
        elif cmd == ":f":
            # :f <l> flood-fill buffer or <l> lines of buffer.
            width = _DEFAULT_WIDTH
            if not self.linerange:
                lstart = 0
                lend = self.cline + 1
                caller.msg("Flood filled lines %i-%i." % (lstart + 1, lend))
            else:
                caller.msg("Flood filled %s." % self.lstr)
            fbuf = "\n".join(linebuffer[lstart:lend])
            fbuf = fill(fbuf, width=width)
            buf = linebuffer[:lstart] + fbuf.split("\n") + linebuffer[lend:]
            editor.update_buffer(buf)
        elif cmd == ":j":
            # :f <l> <w>  justify buffer of <l> with <w> as align (one of
            # f(ull), c(enter), r(ight) or l(left). Default is full.
            align_map = {"full": "f", "f": "f", "center": "c", "c": "c",
                         "right": "r", "r": "r", "left": "l", "l": "l"}
            align_name = {"f": "Full", "c": "Center", "l": "Left", "r": "Right"}
            width = _DEFAULT_WIDTH
            if self.arg1 and self.arg1.lower() not in align_map:
                self.caller.msg("Valid justifications are [f]ull (default), [c]enter, [r]right or [l]eft")
                return
            align = align_map[self.arg1.lower()] if self.arg1 else 'f'
            if not self.linerange:
                lstart = 0
                lend = self.cline + 1
                self.caller.msg("%s-justified lines %i-%i." % (align_name[align], lstart + 1, lend))
            else:
                self.caller.msg("%s-justified %s." % (align_name[align], self.lstr))
            jbuf = "\n".join(linebuffer[lstart:lend])
            jbuf = justify(jbuf, width=width, align=align)
            buf = linebuffer[:lstart] + jbuf.split("\n") + linebuffer[lend:]
            editor.update_buffer(buf)
        elif cmd == ":fi":
            # :fi <l> indent buffer or lines <l> of buffer.
            indent = " " * 4
            if not self.linerange:
                lstart = 0
                lend = self.cline + 1
                caller.msg("Indented lines %i-%i." % (lstart + 1, lend))
            else:
                caller.msg("Indented %s." % self.lstr)
            fbuf = [indent + line for line in linebuffer[lstart:lend]]
            buf = linebuffer[:lstart] + fbuf + linebuffer[lend:]
            editor.update_buffer(buf)
        elif cmd == ":fd":
            # :fi <l> indent buffer or lines <l> of buffer.
            if not self.linerange:
                lstart = 0
                lend = self.cline + 1
                caller.msg("Removed left margin (dedented) lines %i-%i." % (lstart + 1, lend))
            else:
                caller.msg("Removed left margin (dedented) %s." % self.lstr)
            fbuf = "\n".join(linebuffer[lstart:lend])
            fbuf = dedent(fbuf)
            buf = linebuffer[:lstart] + fbuf.split("\n") + linebuffer[lend:]
            editor.update_buffer(buf)
        elif cmd == ":echo":
            # set echoing on/off
            editor._echo_mode = not editor._echo_mode
            caller.msg("Echo mode set to %s" % editor._echo_mode)
        elif cmd == ":!":
            if editor._codefunc:
                editor._codefunc(caller, editor._buffer)
            else:
                caller.msg("This command is only available in code editor mode.")
        elif cmd == ":<":
            # :<
            if editor._codefunc:
                editor.decrease_indent()
                indent = editor._indent
                if indent >= 0:
                    caller.msg("Decreased indentation: new indentation is {}.".format(
                        indent))
                else:
                    caller.msg("|rManual indentation is OFF.|n Use := to turn it on.")
            else:
                caller.msg("This command is only available in code editor mode.")
        elif cmd == ":>":
            # :>
            if editor._codefunc:
                editor.increase_indent()
                indent = editor._indent
                if indent >= 0:
                    caller.msg("Increased indentation: new indentation is {}.".format(
                        indent))
                else:
                    caller.msg("|rManual indentation is OFF.|n Use := to turn it on.")
            else:
                caller.msg("This command is only available in code editor mode.")
        elif cmd == ":=":
            # :=
            if editor._codefunc:
                editor.swap_autoindent()
                indent = editor._indent
                if indent >= 0:
                    caller.msg("Auto-indentation turned on.")
                else:
                    caller.msg("Auto-indentation turned off.")
            else:
                caller.msg("This command is only available in code editor mode.")