def testLoseStatsWithIncreasingAge(self): char = Character(age = 79) self.assertEquals(char.mental_pool(), 7) self.assertEquals(char.physical_pool(), 10) char.buy_perception(4) char.buy_will(3) char.add_path(Lifepath(born=True, years=1)) self.assertEquals(char.mental_pool(), 0) self.assertEquals(char.perception, 3) self.assertEquals(char.will, 3) char.remove_path() char.buy_will() char.add_path(Lifepath(born=True, years=1)) self.assertEquals(char.perception, 3) self.assertEquals(char.will, 3) char.remove_path() char.buy_speed(4) char.buy_power(3) char.buy_forte(2) char.buy_agility(1) self.assertEquals(char.physical_pool(), 0) char.add_path(human.BornNobility()) self.assertEquals(char.physical_pool(), 0) self.assertEquals(char.speed, 3) self.assertEquals(char.power, 3) self.assertEquals(char.forte, 2) self.assertEquals(char.agility, 1)
def testBuyStatsMultiple(self): char = Character(age=1) char.buy_agility(2) char.buy_speed(2) char.buy_power(2) char.buy_forte(2) char.buy_perception(2) char.buy_will(2) self.assertEquals(char.perception, 2) self.assertEquals(char.will, 2) self.assertEquals(char.agility, 2) self.assertEquals(char.speed, 2) self.assertEquals(char.power, 2) self.assertEquals(char.forte, 2) self.assertEquals(char.mental_pool(), 1) self.assertEquals(char.physical_pool(), 2)
def testBuyStats(self): char = Character(age=1) char.buy_agility() char.buy_speed() char.buy_power() char.buy_forte() char.buy_perception() char.buy_will() self.assertEquals(char.perception, 1) self.assertEquals(char.will, 1) self.assertEquals(char.agility, 1) self.assertEquals(char.speed, 1) self.assertEquals(char.power, 1) self.assertEquals(char.forte, 1) self.assertEquals(char.mental_pool(), 3) self.assertEquals(char.physical_pool(), 6)
def testBuyStatsPastLimits(self): """for humans: will and perception 8, all others 6, with no stat can be above 6 in character creation """ char = Character(age = 11) char.buy_perception(6) self.assertRaises(ExceedsMaximum, char.buy_perception) char.remove_perception(6) char.buy_will(6) self.assertRaises(ExceedsMaximum, char.buy_will) char.remove_will(6) char.buy_agility(6) self.assertRaises(ExceedsMaximum, char.buy_agility) char.remove_agility(6) char.buy_speed(6) self.assertRaises(ExceedsMaximum, char.buy_speed) char.remove_speed(6) char.buy_power(6) self.assertRaises(ExceedsMaximum, char.buy_power) char.remove_power(6) char.buy_forte(6) self.assertRaises(ExceedsMaximum, char.buy_forte) char.remove_forte(6)
def testLoseStatsWithDecreasingAge(self): """Changes in Lifepaths can lead to altering point pools. Stats should be altered to avoid negative point pools. Assumption: higher stats should lose points first """ char = Character([Lifepath(years=14, born=True), Lifepath(years=3)]) self.assertEquals(char.age(), 17) self.assertEquals(char.mental_pool(), 7) self.assertEquals(char.physical_pool(), 16) char.buy_perception(4) char.buy_will(3) char.remove_path() self.assertEquals(char.age(), 14) self.assertEquals(char.mental_pool(), 0) self.assertEquals(char.perception, 3) self.assertEquals(char.will, 3) char.add_path(Lifepath(years=3)) char.buy_will() char.remove_path() self.assertEquals(char.age(), 14) self.assertEquals(char.mental_pool(), 0) self.assertEquals(char.perception, 3) self.assertEquals(char.will, 3) char.add_path(Lifepath(years=3)) self.assertEquals(char.physical_pool(), 16) char.buy_speed(6) char.buy_power(5) char.buy_forte(3) char.buy_agility(2) self.assertEquals(char.physical_pool(), 0) char.remove_path() self.assertEquals(char.speed, 4) self.assertEquals(char.power, 4) self.assertEquals(char.forte, 3) self.assertEquals(char.agility, 2)
def testFloaterPoints(self): """Some lifepaths give a bonus point for physical or mental stats. These points should be spent last and refunded first. """ char = Character([Lifepath(born=True, years=1), Lifepath(years=1, floater_points=1)]) self.assertEquals(char.mental_pool(), 5) self.assertEquals(char.physical_pool(), 10) self.assertEquals(char.floater_pool(), 1) char.buy_perception(3) char.buy_will(2) char.buy_forte(4) char.buy_power(2) char.buy_agility(2) char.buy_speed(2) self.assertEquals(char.physical_pool(), 0) self.assertEquals(char.mental_pool(), 0) self.assertEquals(char.floater_pool(), 1) char.buy_perception() self.assertEquals(char.mental_pool(), 0) self.assertEquals(char.floater_pool(), 0) self.assertEquals(char.perception, 4) self.assertRaises(CantAfford, char.buy_will) self.assertRaises(CantAfford, char.buy_forte) self.assertRaises(CantAfford, char.buy_speed) self.assertRaises(CantAfford, char.buy_agility) self.assertRaises(CantAfford, char.buy_power) char.remove_perception() self.assertEquals(char.mental_pool(), 0) self.assertEquals(char.floater_pool(), 1) char.buy_will() self.assertEquals(char.mental_pool(), 0) self.assertEquals(char.floater_pool(), 0) self.assertEquals(char.will, 3) self.assertRaises(CantAfford, char.buy_perception) self.assertRaises(CantAfford, char.buy_forte) self.assertRaises(CantAfford, char.buy_speed) self.assertRaises(CantAfford, char.buy_agility) self.assertRaises(CantAfford, char.buy_power) char.remove_will() self.assertEquals(char.mental_pool(), 0) self.assertEquals(char.floater_pool(), 1) char.buy_forte() self.assertEquals(char.physical_pool(), 0) self.assertEquals(char.floater_pool(), 0) self.assertEquals(char.forte, 5) self.assertRaises(CantAfford, char.buy_will) self.assertRaises(CantAfford, char.buy_perception) self.assertRaises(CantAfford, char.buy_speed) self.assertRaises(CantAfford, char.buy_agility) self.assertRaises(CantAfford, char.buy_power) char.remove_forte() self.assertEquals(char.physical_pool(), 0) self.assertEquals(char.floater_pool(), 1) char.buy_power() self.assertEquals(char.physical_pool(), 0) self.assertEquals(char.floater_pool(), 0) self.assertEquals(char.power, 3) self.assertRaises(CantAfford, char.buy_will) self.assertRaises(CantAfford, char.buy_perception) self.assertRaises(CantAfford, char.buy_forte) self.assertRaises(CantAfford, char.buy_speed) self.assertRaises(CantAfford, char.buy_agility) char.remove_power() self.assertEquals(char.physical_pool(), 0) self.assertEquals(char.floater_pool(), 1) char.buy_agility() self.assertEquals(char.physical_pool(), 0) self.assertEquals(char.floater_pool(), 0) self.assertEquals(char.agility, 3) self.assertRaises(CantAfford, char.buy_will) self.assertRaises(CantAfford, char.buy_perception) self.assertRaises(CantAfford, char.buy_forte) self.assertRaises(CantAfford, char.buy_speed) self.assertRaises(CantAfford, char.buy_power) char.remove_agility() self.assertEquals(char.physical_pool(), 0) self.assertEquals(char.floater_pool(), 1) char.buy_speed() self.assertEquals(char.physical_pool(), 0) self.assertEquals(char.floater_pool(), 0) self.assertEquals(char.speed, 3) self.assertRaises(CantAfford, char.buy_will) self.assertRaises(CantAfford, char.buy_perception) self.assertRaises(CantAfford, char.buy_forte) self.assertRaises(CantAfford, char.buy_power) self.assertRaises(CantAfford, char.buy_agility) char.remove_speed() self.assertEquals(char.physical_pool(), 0) self.assertEquals(char.floater_pool(), 1)
class CharacterSkillTests(unittest.TestCase): def setUp(self): self.c = Character(starting_paths=[Lifepath(born=True, years=1, floater_points=100)]) self.c.buy_agility(2) self.c.buy_speed(2) self.c.buy_power(2) self.c.buy_forte(2) self.c.buy_perception(2) self.c.buy_will(2) def testBlank(self): self.assertEquals(self.c.skill_points(), 0) self.assertEquals(self.c.get_skills(), []) def testCountSkillPoints(self): """The first and second times a path is taken, the first untaken skill must be opened The third time, this is not the case, but the path only gives half points After this, no points are awarded. """ self.assertEquals(self.c.skill_points(), 0) self.c.add_path(Lifepath(name = "Path A", skill_points=1)) self.assertEquals(self.c.skill_points(), 1) self.c.add_path(Lifepath(name = "Path B", skill_points=2)) self.assertEquals(self.c.skill_points(), 3) self.c.add_path(Lifepath(name = "Path C", skill_points=1, skills=[skill.Skill(name='Required Skill'), skill.Skill(name='Optional Skill')])) self.assertEquals(self.c.skill_points(), 3) self.c.add_path(Lifepath(name = "Path B", skill_points=2)) self.assertEquals(self.c.skill_points(), 5) self.c.add_path(Lifepath(name = "Path B", skill_points=2)) self.assertEquals(self.c.skill_points(), 6) self.c.add_path(Lifepath(name = "Path B", skill_points=2)) self.assertEquals(self.c.skill_points(), 6) def testLifepathSkillList(self): self.assertEquals(self.c.lifepath_skills(), []) self.c.add_path(Lifepath(name = "Path A", skills = [skill.Skill(name='Lifepath Skill')], skill_points=1)) self.assertTrue(len(self.c.lifepath_skills()), 1) self.c.add_path(Lifepath(name = "Path B", skills = [skill.Skill(name='Lifepath Skill')], skill_points=1)) self.assertEquals(len(self.c.lifepath_skills()), 1) self.c.add_path(Lifepath(name = "Path C", skills = [skill.Skill(name='New Skill'), skill.Skill(name='Other Skill')], skill_points=1)) self.assertEquals(len(self.c.lifepath_skills()), 3) def testRequiredLPSkills(self): self.c.add_path(Lifepath(name = "Path A", skills=[skill.PerceptionRoot(name='Skill on list 1'), skill.AgilityRoot(name='Skill on list 2')], skill_points=1)) self.assertEquals(len(self.c.lifepath_skills()), 2) self.assertEquals([{'name':'Skill on list 1','roots':['Perception']}], self.c.required_skills()) self.assertEquals([{'name':'Skill on list 1','roots':['Perception'],'points':1}], self.c.get_skills()) self.assertEquals([{'name':'Skill on list 1','roots':['Perception'],'points':1}], self.c.get_skills()) #self.assertEquals(len(self.c.get_skills()), 1) self.assertEquals(self.c.skill_points(), 0) self.c.add_path(Lifepath(name = "Path A", skills=[skill.PerceptionRoot(name='Skill on list 1'), skill.AgilityRoot(name='Skill on list 2')], skill_points=1)) self.assertEquals(self.c.skill_points(), 0) self.assertEquals(len(self.c.lifepath_skills()), 2) self.assertTrue({'name':'Skill on list 1','roots':['Perception']} in self.c.required_skills()) self.assertTrue({'name':'Skill on list 2','roots':['Agility']} in self.c.required_skills()) self.assertTrue({'name':'Skill on list 1','roots':['Perception'],'points':1} in self.c.get_skills()) self.assertTrue({'name':'Skill on list 2','roots':['Agility'],'points':1} in self.c.get_skills()) def testBuySkillNotOnList(self): """General points are halved the third time a lifepath is taken, and removed the fourth time. """ # like floater points, general points are always spent last and returned first path_g = Lifepath(name ='Path G', general_skill_points=2) self.assertRaises(CantAfford, self.c.buy_skill, skill.Skill(name='Skill not on lifepath list')) self.c.add_path(Lifepath(skill_points=1)) self.assertRaises(CantAfford, self.c.buy_skill, skill.PerceptionRoot(name='Skill not on lifepath list')) self.c.add_path(path_g) self.assertEquals(self.c.general_skill_points(), 2) self.c.buy_skill(skill.PerceptionRoot(name='Skill not on lifepath list')) self.assertEquals(self.c.skill_points(), 1) self.assertEquals(self.c.general_skill_points(), 1) self.c.buy_skill(skill.PerceptionRoot(name='Skill not on lifepath list')) self.assertEquals(self.c.general_skill_points(), 0) self.assertEquals(self.c.skill_points(), 1) self.assertRaises(CantAfford, self.c.buy_skill, skill.PerceptionRoot(name='Skill not on lifepath list')) self.c.add_path(path_g) self.assertEquals(self.c.general_skill_points(), 2) self.c.add_path(path_g) self.assertEquals(self.c.general_skill_points(), 3) self.c.add_path(path_g) self.assertEquals(self.c.general_skill_points(), 3) def testBuySkillOnList(self): self.assertEquals(self.c.get_skills(), []) self.c.add_path(Lifepath(name = "Path A", skills=[skill.PerceptionRoot(name='Skill on list 1'), skill.AgilityRoot(name='Skill on list 2')], skill_points=1)) self.assertEquals([{'name':'Skill on list 1','roots':['Perception'],'points':1}], self.c.get_skills()) self.assertEquals(self.c.skill_points(), 0) self.assertRaises(CantAfford, self.c.buy_skill, skill.PerceptionRoot(name='Skill on list 2')) self.c.add_path(Lifepath(name = "Path B", skill_points=2)) self.assertEquals(self.c.skill_points(), 2) self.c.buy_skill(skill.PerceptionRoot(name='Skill on list 1')) self.assertEquals(self.c.skill_points(), 1) self.assertTrue({'name':'Skill on list 1','roots':['Perception'],'points':2} in self.c.get_skills()) self.c.buy_skill(skill.PerceptionRoot(name='Skill on list 2')) self.assertTrue({'name':'Skill on list 2','roots':['Perception'],'points':1} in self.c.get_skills()) self.assertEquals(self.c.skill_points(), 0) def testSkillExponent(self): self.assertEquals(self.c.skill_totals(), []) self.c.bought_skills = [{'name':'Skill on list 1','roots':['Perception'],'points':1}] self.assertEquals(self.c.skill_totals(), [{'name':'Skill on list 1', 'exponent':1}]) self.c.bought_skills = [{'name':'Skill on list 1','roots':['Perception'],'points':3}] self.assertEquals(self.c.skill_totals(), [{'name':'Skill on list 1', 'exponent':3}]) self.c.perception += 1 self.assertEquals(self.c.skill_totals(), [{'name':'Skill on list 1', 'exponent':3}]) self.c.perception += 1 self.assertEquals(self.c.skill_totals(), [{'name':'Skill on list 1', 'exponent':4}]) self.c.bought_skills = [{'name':'Skill on list 1','roots':['Perception', 'Will'],'points':3}] self.assertEquals(self.c.skill_totals(), [{'name':'Skill on list 1', 'exponent':3}]) def testRemoveSkills(self): skill_one = skill.PerceptionRoot(name='Skill on list 1') skill_two = skill.AgilityRoot(name='Skill on list 2') self.c.add_path(Lifepath(name = "Path A", skills=[skill_one, skill_two], skill_points=2)) self.assertEquals([{'name':'Skill on list 1','roots':['Perception'],'points':1}], self.c.get_skills()) self.assertRaises(Exception, self.c.remove_skill, skill_one) self.assertEquals(self.c.skill_points(), 1) self.c.buy_skill(skill_two) self.assertEquals(self.c.skill_points(), 0) self.assertTrue({'name':'Skill on list 2','roots':['Agility'],'points':1} in self.c.get_skills()) self.c.remove_skill(skill_two) self.assertEquals([{'name':'Skill on list 1','roots':['Perception'],'points':1}], self.c.get_skills()) self.assertEquals(self.c.skill_points(), 1) self.c.buy_skill(skill_two) self.c.add_path(Lifepath(name='Path G', general_skill_points = 1)) self.assertEquals(self.c.general_skill_points(), 1) self.assertEquals(self.c.skill_points(), 0) self.c.buy_skill(skill_two) self.assertEquals(self.c.general_skill_points(), 0) self.assertEquals(self.c.skill_points(), 0) self.c.remove_skill(skill_two) self.assertEquals(self.c.general_skill_points(), 1) self.assertEquals(self.c.skill_points(), 0) def testRemovePath(self): pass