Exemplo n.º 1
0
def sample_char(char, archetype, race, focus=None):
    """Loads sample traits onto a character.

    Args:
        char (Character): character to load traits
        archetype (str): name of base archetype
        race (str): name of race to become
        focus Optional(str): focus to apply. if None, default is race's
            first item in foci collection
        """
    archetypes.apply_archetype(char, archetype, reset=True)
    char.traits.STR.base += 1
    char.traits.PER.base += 1
    char.traits.INT.base += 1
    char.traits.DEX.base += 1
    char.traits.CHA.base += 1
    char.traits.VIT.base += 2
    char.traits.MAG.base += 2
    focus = focus or races.load_race(race).foci[0]
    races.apply_race(char, race, focus)
    archetypes.calculate_secondary_traits(char.traits)
    archetypes.finalize_traits(char.traits)
    tickerhandler.add(char, 6, hook_key='at_turn_start')
    skills.apply_skills(char)
    skills.finalize_skills(char.skills)
Exemplo n.º 2
0
def sample_char(char, archetype, race, focus=None):
    """Loads sample traits onto a character.

    Args:
        char (Character): character to load traits
        archetype (str): name of base archetype
        race (str): name of race to become
        focus Optional(str): focus to apply. if None, default is race's
            first item in foci collection
        """
    archetypes.apply_archetype(char, archetype, reset=True)
    char.traits.STR.base += 1
    char.traits.PER.base += 1
    char.traits.INT.base += 1
    char.traits.DEX.base += 1
    char.traits.CHA.base += 1
    char.traits.VIT.base += 2
    char.traits.MAG.base += 2
    focus = focus or races.load_race(race).foci[0]
    races.apply_race(char, race, focus)
    archetypes.calculate_secondary_traits(char.traits)
    archetypes.finalize_traits(char.traits)
    tickerhandler.add(interval=6, callback=char.at_turn_start)
    skills.apply_skills(char)
    skills.finalize_skills(char.skills)
Exemplo n.º 3
0
def menunode_allocate_mana(caller, raw_string):
    """Mana point allocation menu node."""
    char = caller.new_char
    tr = char.traits
    manas = ('WM', 'BM')
    raw_string = raw_string.strip()
    if raw_string.isdigit() and int(raw_string) <= len(manas):
        tr[manas[int(raw_string) - 1]].base += 1

    remaining = tr.MAG.actual - sum(tr[m].base for m in manas)
    if remaining:
        text = "Your |CMagic|n trait is |w{}|n.\n\n".format(tr.MAG.actual)
        text += "This allows you to allocate that many points to your\n"
        text += "|wWhite Mana|n and |xBlack Mana|n counters.\n"
        text += "You have |w{}|n points remaining. ".format(remaining)
        text += "Select a mana counter to increase:"
        help = "Magic users spend Mana points when casting spells. Different\n"
        help += "colors of magic require different colors of mana. The effects of\n"
        help += "different magics vary by color.\n\n"
        help += "  White - white magic spells are generally support/healing based\n"
        help += "  Black - black magic spells are generally attack-oriented\n\n"
        help += "The number of points allocated here determines the number of\n"
        help += "each color mana that will be spawned each turn of the game."
        options = [{
            "desc":
            _format_trait_opts(tr[m], '|w' if m == 'WM' else '|x'),
            "goto":
            "menunode_allocate_mana"
        } for m in manas]

        def reset_mana(s):
            for m in manas:
                char.traits[m].base = 0

        options.append({
            "desc": "Start Over",
            "exec": reset_mana,
            "goto": "menunode_allocate_mana"
        })
        return (text, help), options
    else:
        if tr.MAG.actual > 0:
            output = "Final Mana Values:\n"
            output += "  |wWhite Mana|n: |w{}|n\n".format(tr.WM.actual)
            output += "  |xBlack Mana|n: |w{}|n\n".format(tr.BM.actual)
        else:
            output = ""
        # TODO: implement spells; add level 0 spell cmdsets here

        archetypes.calculate_secondary_traits(char.traits)
        archetypes.finalize_traits(char.traits)
        tickerhandler.add(interval=6, callback=char.at_turn_start)
        skills.apply_skills(char)
        return menunode_allocate_skills(caller, output)
Exemplo n.º 4
0
def menunode_allocate_mana(caller, raw_string):
    """Mana point allocation menu node."""
    char = caller.new_char
    tr = char.traits
    manas = ('WM', 'BM')
    raw_string = raw_string.strip()
    if raw_string.isdigit() and int(raw_string) <= len(manas):
        tr[manas[int(raw_string) - 1]].base += 1

    remaining = tr.MAG.actual - sum(tr[m].base for m in manas)
    if remaining:
        text = "Your |CMagic|n trait is |w{}|n.\n\n".format(tr.MAG.actual)
        text += "This allows you to allocate that many points to your\n"
        text += "|wWhite Mana|n and |xBlack Mana|n counters.\n"
        text += "You have |w{}|n points remaining. ".format(remaining)
        text += "Select a mana counter to increase:"
        help = "Magic users spend Mana points when casting spells. Different\n"
        help += "colors of magic require different colors of mana. The effects of\n"
        help += "different magics vary by color.\n\n"
        help += "  White - white magic spells are generally support/healing based\n"
        help += "  Black - black magic spells are generally attack-oriented\n\n"
        help += "The number of points allocated here determines the number of\n"
        help += "each color mana that will be spawned each turn of the game."
        options = [{"desc": _format_trait_opts(tr[m], '|w' if m == 'WM' else '|x'),
                    "goto": "menunode_allocate_mana"}
                   for m in manas]

        def reset_mana(s):
            for m in manas:
                char.traits[m].base = 0

        options.append({"desc": "Start Over",
                        "exec": reset_mana,
                        "goto": "menunode_allocate_mana"})
        return (text, help), options
    else:
        if tr.MAG.actual > 0:
            output = "Final Mana Values:\n"
            output += "  |wWhite Mana|n: |w{}|n\n".format(tr.WM.actual)
            output += "  |xBlack Mana|n: |w{}|n\n".format(tr.BM.actual)
        else:
            output = ""
        # TODO: implement spells; add level 0 spell cmdsets here

        archetypes.calculate_secondary_traits(char.traits)
        archetypes.finalize_traits(char.traits)
        tickerhandler.add(interval=6, callback=char.at_turn_start)
        skills.apply_skills(char)
        return menunode_allocate_skills(caller, output)