Example #1
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
Example #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)
Example #3
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)
 def test_load_dwarf(self):
     """test that `load_race` loads Dwarf race class"""
     e = races.load_race('dwarf')
     self.assertEqual(e.name, 'Dwarf')
     self.assertEqual(e.plural, 'Dwarves')
     self.assertEqual(e.size, 'small')
     self.assertIn(e.foci[0].name, ('Brawn', 'Resilience', 'Alertness'))
     self.assertIn(e.foci[1].name, ('Brawn', 'Resilience', 'Alertness'))
     self.assertIn(e.foci[2].name, ('Brawn', 'Resilience', 'Alertness'))
     self.assertEqual(e.bonuses, {'WILL': 1})
 def test_load_elf(self):
     """test that `load_race` loads Elf race class"""
     e = races.load_race('elf')
     self.assertEqual(e.name, 'Elf')
     self.assertEqual(e.plural, 'Elves')
     self.assertEqual(e.size, 'medium')
     self.assertIn(e.foci[0].name, ('Agility', 'Spirit', 'Alertness'))
     self.assertIn(e.foci[1].name, ('Agility', 'Spirit', 'Alertness'))
     self.assertIn(e.foci[2].name, ('Agility', 'Spirit', 'Alertness'))
     self.assertEqual(e.bonuses, {})
 def test_load_human(self):
     """test that `load_race` loads Human race class"""
     h = races.load_race('human')
     self.assertEqual(h.name, 'Human')
     self.assertEqual(h.plural, 'Humans')
     self.assertEqual(h.size, 'medium')
     self.assertIn(h.foci[0].name, ('Agility', 'Cunning', 'Prestige'))
     self.assertIn(h.foci[1].name, ('Agility', 'Cunning', 'Prestige'))
     self.assertIn(h.foci[2].name, ('Agility', 'Cunning', 'Prestige'))
     self.assertEqual(h.bonuses, {'WILL': 1})
Example #7
0
 def test_load_dwarf(self):
     """test that `load_race` loads Dwarf race class"""
     e = races.load_race('dwarf')
     self.assertEqual(e.name, 'Dwarf')
     self.assertEqual(e.plural, 'Dwarves')
     self.assertEqual(e.size, 'small')
     self.assertIn(e.foci[0].name, ('Brawn', 'Resilience', 'Alertness'))
     self.assertIn(e.foci[1].name, ('Brawn', 'Resilience', 'Alertness'))
     self.assertIn(e.foci[2].name, ('Brawn', 'Resilience', 'Alertness'))
     self.assertEqual(e.bonuses, {'WILL': 1})
Example #8
0
 def test_load_elf(self):
     """test that `load_race` loads Elf race class"""
     e = races.load_race('elf')
     self.assertEqual(e.name, 'Elf')
     self.assertEqual(e.plural, 'Elves')
     self.assertEqual(e.size, 'medium')
     self.assertIn(e.foci[0].name, ('Agility', 'Spirit', 'Alertness'))
     self.assertIn(e.foci[1].name, ('Agility', 'Spirit', 'Alertness'))
     self.assertIn(e.foci[2].name, ('Agility', 'Spirit', 'Alertness'))
     self.assertEqual(e.bonuses, {})
Example #9
0
 def test_load_human(self):
     """test that `load_race` loads Human race class"""
     h = races.load_race('human')
     self.assertEqual(h.name, 'Human')
     self.assertEqual(h.plural, 'Humans')
     self.assertEqual(h.size, 'medium')
     self.assertIn(h.foci[0].name, ('Agility', 'Cunning', 'Prestige'))
     self.assertIn(h.foci[1].name, ('Agility', 'Cunning', 'Prestige'))
     self.assertIn(h.foci[2].name, ('Agility', 'Cunning', 'Prestige'))
     self.assertEqual(h.bonuses, {'WILL': 1})
Example #10
0
    def become_race(self, race):
        """
        This method applies a race to the character.

        Args:
            race (str): Class path for the race

        Returns:
            bool: True if successful, False if otherwise
        """

        # set the race
        self.db.race = races.load_race(race)
        self.db.slots = self.db.race.slots
Example #11
0
    def become_race(self, race):
        """
        This method applies a race to the character.

        Args:
            race (str): Class path for the race

        Returns:
            bool: True if successful, False if otherwise
        """

        # set the race
        self.db.race = races.load_race(race)
        self.db.slots = self.db.race.slots
Example #12
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
Example #13
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
Example #14
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