示例#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(interval=6, callback=char.at_turn_start)
    skills.apply_skills(char)
    skills.finalize_skills(char.skills)
示例#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(char, 6, hook_key='at_turn_start')
    skills.apply_skills(char)
    skills.finalize_skills(char.skills)
示例#3
0
文件: tests.py 项目: lilomar/ainneve
 def setUp(self):
     super(EquipTestCase, self).setUp()
     apply_archetype(self.char1, 'warrior')
     apply_race(self.char1, 'human', 'cunning')
     self.obj1.db.desc = 'Test Obj'
     self.obj1.db.damage = 1
     self.obj1.db.weight = 1.0
     self.obj2.db.desc = 'Test Obj2'
     self.obj2.swap_typeclass('typeclasses.armors.Armor',
                              clean_attributes=True,
                              run_start_hooks=True)
     self.obj2.db.toughness = 1
     self.obj2.db.weight = 2.0
示例#4
0
def menunode_select_race_focus(caller, raw_string):
    """Focus detail and final race/focus selection menu node."""
    char = caller.new_char
    race = caller.ndb._menutree.race
    focus = race.foci[int(raw_string.strip()) - 1]
    text = "|wRace|n: |g{}|n\n|wFocus|n: ".format(race.name)
    text += focus.desc
    text += "Confirm this Race and Focus selection?"
    help = "Examine the bonuses and detriments of this race and focus combination\n"
    help += "and decide whether to apply them to your character."

    options = ({
        "key": ("Yes", "ye", "y"),
        "desc":
        "Become {} {} with the {} focus".format(
            'an' if race.name[0] == 'E' else 'a', race.name, focus.name),
        "exec":
        lambda s: races.apply_race(char, race, focus),
        "goto":
        "menunode_allocate_mana"
    }, {
        "key": ("No", "n", "_default"),
        "desc": "Return to {} details".format(race.name),
        "goto": "menunode_race_and_focuses"
    })

    return (text, help), options
示例#5
0
文件: tests.py 项目: lilomar/ainneve
 def setUp(self):
     super(ItemEncumbranceTestCase, self).setUp()
     apply_archetype(self.char1, 'warrior')
     apply_race(self.char1, 'human', 'cunning')
     self.char1.traits.STR.base += 3
     self.char1.traits.VIT.base += 3
     self.char1.traits.DEX.base += 2
     calculate_secondary_traits(self.char1.traits)
     self.obj1.db.desc = 'Test Obj'
     self.obj1.db.damage = 1
     self.obj1.db.weight = 1.0
     self.obj2.swap_typeclass('typeclasses.armors.Armor',
                              clean_attributes=True,
                              run_start_hooks=True)
     self.obj2.db.toughness = 1
     self.obj2.db.weight = 18.0
示例#6
0
def menunode_select_race_focus(caller, raw_string):
    """Focus detail and final race/focus selection menu node."""
    char = caller.new_char
    race = caller.ndb._menutree.race
    focus = race.foci[int(raw_string.strip()) - 1]
    text = "|wRace|n: |g{}|n\n|wFocus|n: ".format(race.name)
    text += focus.desc
    text += "Confirm this Race and Focus selection?"
    help = "Examine the bonuses and detriments of this race and focus combination\n"
    help += "and decide whether to apply them to your character."

    options = ({"key": ("Yes", "ye", "y"),
                "desc": "Become {} {} with the {} focus".format(
                    'an' if race.name[0] == 'E' else 'a',
                    race.name,
                    focus.name),
                "exec": lambda s: races.apply_race(char, race, focus),
                "goto": "menunode_allocate_mana"},
               {"key": ("No", "n", "_default"),
                "desc": "Return to {} details".format(race.name),
                "goto": "menunode_race_and_focuses"})

    return (text, help), options
 def test_apply_human_cunning(self):
     """test character becoming human with cunning focus"""
     self.check_traits(8, 2, 2, 5, 5, 8, 0, 8, 3, 2)
     races.apply_race(self.char1, 'human', 'cunning')
     # human/cunning bonuses: 4 will, 1 per, 2 int
     self.check_traits(8, 3, 4, 5, 5, 8, 0, 8, 3, 6)
示例#8
0
 def test_apply_elf_agility(self):
     """test character becoming elf with agility focus"""
     self.check_traits(8, 2, 2, 5, 5, 8, 0, 8, 3, 2)
     races.apply_race(self.char1, 'elf', 'agility')
     # elf/agility bonuses: 1 str, 2 dex, 2 refl
     self.check_traits(9, 2, 2, 7, 5, 8, 0, 8, 5, 2)
示例#9
0
 def test_apply_human_prestige(self):
     """test character becoming human with prestige focus"""
     self.check_traits(8, 2, 2, 5, 5, 8, 0, 8, 3, 2)
     races.apply_race(self.char1, 'human', 'prestige')
     # human/prestige bonuses: 1 will, 1 int, 2 cha
     self.check_traits(8, 2, 3, 5, 7, 8, 0, 8, 3, 3)
示例#10
0
 def test_apply_dwarf_resilience(self):
     """test character becoming dwarf with resilience focus"""
     self.check_traits(8, 2, 2, 5, 5, 8, 0, 8, 3, 2)
     races.apply_race(self.char1, 'dwarf', 'resilience')
     # dwarf/resilience bonuses: 1 dex, 2 vit, 3 fort, 3 will
     self.check_traits(8, 2, 2, 6, 5, 10, 0, 11, 3, 5)
示例#11
0
 def test_apply_dwarf_alertness(self):
     """test character becoming dwarf with alertness focus"""
     self.check_traits(8, 2, 2, 5, 5, 8, 0, 8, 3, 2)
     races.apply_race(self.char1, 'dwarf', 'alertness')
     # dwarf/alertness bonuses: 2 per, 1 cha, 2 refl, 1 will
     self.check_traits(8, 4, 2, 5, 6, 8, 0, 8, 5, 3)
示例#12
0
 def test_apply_elf_alertness(self):
     """test character becoming elf with alertness focus"""
     self.check_traits(8, 2, 2, 5, 5, 8, 0, 8, 3, 2)
     races.apply_race(self.char1, 'elf', 'alertness')
     # elf/alertness bonuses: 2 per, 1 cha, 2 refl
     self.check_traits(8, 4, 2, 5, 6, 8, 0, 8, 5, 2)
示例#13
0
 def test_apply_dwarf_brawn(self):
     """test character becoming dwarf with brawn focus"""
     self.check_traits(8, 2, 2, 5, 5, 8, 0, 8, 3, 2)
     races.apply_race(self.char1, 'dwarf', 'brawn')
     # dwarf/brawn bonuses: 2 str, 1 vit, 1 fort, 1 will
     self.check_traits(10, 2, 2, 5, 5, 9, 0, 9, 3, 3)
示例#14
0
 def test_apply_elf_agility(self):
     """test character becoming elf with agility focus"""
     self.check_traits(8, 2, 2, 5, 5, 8, 0, 8, 3, 2)
     races.apply_race(self.char1, 'elf', 'agility')
     # elf/agility bonuses: 1 str, 2 dex, 2 refl
     self.check_traits(9, 2, 2, 7, 5, 8, 0, 8, 5, 2)
示例#15
0
 def test_apply_elf_spirit(self):
     """test character becoming elf with spirit focus"""
     self.check_traits(8, 2, 2, 5, 5, 8, 0, 8, 3, 2)
     races.apply_race(self.char1, 'elf', 'spirit')
     # elf/spirit bonuses: 1 vit, 2 mag, 1 fort, 1 refl, 1 will
     self.check_traits(8, 2, 2, 5, 5, 9, 2, 9, 4, 3)
示例#16
0
 def test_apply_elf_spirit(self):
     """test character becoming elf with spirit focus"""
     self.check_traits(8, 2, 2, 5, 5, 8, 0, 8, 3, 2)
     races.apply_race(self.char1, 'elf', 'spirit')
     # elf/spirit bonuses: 1 vit, 2 mag, 1 fort, 1 refl, 1 will
     self.check_traits(8, 2, 2, 5, 5, 9, 2, 9, 4, 3)
示例#17
0
 def test_apply_human_cunning(self):
     """test character becoming human with cunning focus"""
     self.check_traits(8, 2, 2, 5, 5, 8, 0, 8, 3, 2)
     races.apply_race(self.char1, 'human', 'cunning')
     # human/cunning bonuses: 4 will, 1 per, 2 int
     self.check_traits(8, 3, 4, 5, 5, 8, 0, 8, 3, 6)
示例#18
0
 def test_apply_human_agility(self):
     """test character becoming human with agility focus"""
     self.check_traits(8, 2, 2, 5, 5, 8, 0, 8, 3, 2)
     races.apply_race(self.char1, 'human', 'agility')
     # human/agility bonuses: 1 will, 1 str, 2 dex, 2 refl
     self.check_traits(9, 2, 2, 7, 5, 8, 0, 8, 5, 3)
示例#19
0
 def test_apply_elf_alertness(self):
     """test character becoming elf with alertness focus"""
     self.check_traits(8, 2, 2, 5, 5, 8, 0, 8, 3, 2)
     races.apply_race(self.char1, 'elf', 'alertness')
     # elf/alertness bonuses: 2 per, 1 cha, 2 refl
     self.check_traits(8, 4, 2, 5, 6, 8, 0, 8, 5, 2)
示例#20
0
 def test_apply_dwarf_alertness(self):
     """test character becoming dwarf with alertness focus"""
     self.check_traits(8, 2, 2, 5, 5, 8, 0, 8, 3, 2)
     races.apply_race(self.char1, 'dwarf', 'alertness')
     # dwarf/alertness bonuses: 2 per, 1 cha, 2 refl, 1 will
     self.check_traits(8, 4, 2, 5, 6, 8, 0, 8, 5, 3)
示例#21
0
 def test_apply_dwarf_resilience(self):
     """test character becoming dwarf with resilience focus"""
     self.check_traits(8, 2, 2, 5, 5, 8, 0, 8, 3, 2)
     races.apply_race(self.char1, 'dwarf', 'resilience')
     # dwarf/resilience bonuses: 1 dex, 2 vit, 3 fort, 3 will
     self.check_traits(8, 2, 2, 6, 5, 10, 0, 11, 3, 5)
示例#22
0
 def test_apply_dwarf_brawn(self):
     """test character becoming dwarf with brawn focus"""
     self.check_traits(8, 2, 2, 5, 5, 8, 0, 8, 3, 2)
     races.apply_race(self.char1, 'dwarf', 'brawn')
     # dwarf/brawn bonuses: 2 str, 1 vit, 1 fort, 1 will
     self.check_traits(10, 2, 2, 5, 5, 9, 0, 9, 3, 3)
示例#23
0
 def test_apply_human_prestige(self):
     """test character becoming human with prestige focus"""
     self.check_traits(8, 2, 2, 5, 5, 8, 0, 8, 3, 2)
     races.apply_race(self.char1, 'human', 'prestige')
     # human/prestige bonuses: 1 will, 1 int, 2 cha
     self.check_traits(8, 2, 3, 5, 7, 8, 0, 8, 3, 3)
示例#24
0
 def test_apply_human_agility(self):
     """test character becoming human with agility focus"""
     self.check_traits(8, 2, 2, 5, 5, 8, 0, 8, 3, 2)
     races.apply_race(self.char1, 'human', 'agility')
     # human/agility bonuses: 1 will, 1 str, 2 dex, 2 refl
     self.check_traits(9, 2, 2, 7, 5, 8, 0, 8, 5, 3)