def testCheaperTraits(self): """All traits on the available list cost only one point """ char = Character([human.BornNobility(), human.NobleCoeptir(), human.NobleArmiger()]) char.buy_trait(trait.Tough()) self.assertEquals(char.traits(), [trait.MarkOfPrivilege(), trait.AnvilTrained(), trait.Tough()]) self.assertEquals(char.trait_points(), 0)
def testSuperficialWoundTolerance(self): char = Character([Lifepath(born=True, years=1)]) char.buy_forte() self.assertEquals(char.superficial_wound(), 'H1') char.buy_forte() self.assertEquals(char.superficial_wound(), 'H2') char.buy_forte() self.assertEquals(char.superficial_wound(), 'H2')
def testAge(self): age_req = Requirement(age=10) char = Character() char.add_path(Lifepath(years=5, born=True)) self.assertFalse(age_req.allowed(char)) char.add_path(Lifepath(years=5)) self.assertTrue(age_req.allowed(char))
def testInjuredWoundTolerance(self): char = Character([Lifepath(born=True, years=1)]) char.buy_forte() self.assertEquals(char.injured_wound(), 'H1') char.buy_forte() self.assertEquals(char.injured_wound(), 'H3') char.buy_forte() self.assertEquals(char.injured_wound(), 'H3')
def testCantAffordTraits(self): char = Character([human.BornNobility(), human.NobleCoeptir(), human.NobleArmiger()]) self.assertEquals(char.trait_points(), 1) self.assertRaises(NotAllowed, char.buy_trait, trait.CalmDemeanor()) self.assertEquals(char.trait_points(), 1) char.add_path(human.NobleLPAnvil()) self.assertEquals(char.trait_points(),2) char.buy_trait(trait.CalmDemeanor()) self.assertEquals(char.traits(), [trait.MarkOfPrivilege(), trait.AnvilTrained(), trait.CorvusAndCrucis(), trait.CalmDemeanor()]) self.assertEquals(char.trait_points(),0)
def testBonusStatPoints(self): char = Character([Lifepath(years=1, born=True)]) char.add_path(Lifepath(physical_points=1)) self.assertEquals(char.physical_pool(), 11) char.remove_path() char.add_path(Lifepath(mental_points=1)) self.assertEquals(char.mental_pool(), 6)
def testTraitList(self): char = Character([human.BornNobility(), human.NobleCoeptir(), human.NobleArmiger()]) self.assertEquals(char.traits(), [trait.MarkOfPrivilege(), trait.AnvilTrained()]) char.add_path(human.NobleLPAnvil()) self.assertEquals(char.traits(), [trait.MarkOfPrivilege(), trait.AnvilTrained(), trait.CorvusAndCrucis()]) char.add_path(human.NobleLPAnvil()) self.assertEquals(char.traits(), [trait.MarkOfPrivilege(), trait.AnvilTrained(), trait.CorvusAndCrucis(), trait.IronTrained()])
def testTraitsGetCheaper(self): """A trait can be bought, after which a lifepath is added that puts that trait on the available list. The difference in cost should be refunded """ char = Character([human.BornNobility(), human.Bastard(), human.TheocracyStudent(), human.Soldier(), human.Sergeant()]) self.assertEquals(char.trait_points(), 3) char.buy_trait(trait.Tough()) self.assertEquals(char.trait_points(), 0) char.add_path(human.NobleArmiger()) self.assertEquals(char.trait_points(), 2) self.assertTrue(char.has_trait(trait.Tough()))
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 testAddWorld(self): c = Character() self.assertRaises(Exception, c.set_world, world.World()) w = world.World(name='TestLand', empire=world.COMORAN, location=world.INT, atmosphere=world.HLS, topography=world.BROAD, index=world.LOW, government=world.NOBLE, military=world.LORDSPILOT, attitude=world.PARANOID, export=world.INDUSTRIAL, quarantine=world.NONE, regulation=world.LOOSE, hydrology=world.LAND) c.set_world(w) self.assertEquals(c.get_world().get_name(), 'TestLand')
def testAnyLifepath(self): charA = Character([Lifepath(name='A', born=True)]) charB = Character([Lifepath(name='B', born=True)]) charC = Character([Lifepath(name='C', born=True)]) one_path_once=Requirement(paths={('A',): 1}) self.assertTrue(one_path_once.allowed(charA)) self.assertFalse(one_path_once.allowed(charB)) self.assertFalse(one_path_once.allowed(charC)) two_paths_once=Requirement(paths={('A', 'B'): 1}) self.assertTrue(two_paths_once.allowed(charA)) self.assertTrue(two_paths_once.allowed(charB)) self.assertFalse(two_paths_once.allowed(charC)) one_path_once_twice=Requirement(paths={('A',):1, ('B',):1}) self.assertFalse(one_path_once_twice.allowed(charA)) self.assertFalse(one_path_once_twice.allowed(charB)) self.assertFalse(one_path_once_twice.allowed(charC)) one_path_twice=Requirement(paths={('A',): 2}) self.assertFalse(one_path_twice.allowed(charA)) self.assertFalse(one_path_twice.allowed(charB)) self.assertFalse(one_path_twice.allowed(charC)) charA.add_path(Lifepath('A')) self.assertTrue(one_path_twice.allowed(charA)) two_paths_twice=Requirement(paths={('A', 'B'): 2}) self.assertTrue(two_paths_twice.allowed(charA)) self.assertFalse(two_paths_twice.allowed(charB)) self.assertFalse(two_paths_twice.allowed(charC)) charB.add_path(Lifepath('A')) self.assertTrue(two_paths_twice.allowed(charB))
def testLifepathTraits(self): """All traits on all the paths the character has taken are listed. """ char = Character() char.add_path(human.BornNobility()) self.assertEquals(char.lifepath_traits(), [trait.MarkOfPrivilege(), trait.YourLordship(), trait.YourEminence(), trait.YourGrace(), trait.YourMajesty()])
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 testLoseBoughtTraits(self): """A trait can be bought, then a lifepath removed, causing either: 1. The loss of the points used to buy the trait 2. The trait becomes more expensive than the character can afford In these cases, traits should be removed, starting with the most recently addded, until balance is restored """ char = Character([human.BornNobility(), human.Bastard(), human.Soldier(), human.Sergeant()]) self.assertEquals(char.trait_points(), 2) char.add_path(human.NobleArmiger()) char.buy_trait(trait.Tough()) self.assertEquals(char.trait_points(), 1) char.remove_path() self.assertEquals(char.trait_points(), 2) self.assertFalse(char.has_trait(trait.Tough()))
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 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 testArtha(self): char = Character() self.assertEquals(char.artha_fate(),3) self.assertEquals(char.artha_persona(),2) self.assertEquals(char.artha_deeds(),1) char.add_path(Lifepath(born=True)) self.assertEquals(char.artha_fate(),3) self.assertEquals(char.artha_persona(),2) self.assertEquals(char.artha_deeds(),1) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),3) self.assertEquals(char.artha_persona(),2) self.assertEquals(char.artha_deeds(),1) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),3) self.assertEquals(char.artha_persona(),2) self.assertEquals(char.artha_deeds(),1) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),3) self.assertEquals(char.artha_persona(),2) self.assertEquals(char.artha_deeds(),1) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),3) self.assertEquals(char.artha_persona(),2) self.assertEquals(char.artha_deeds(),1) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),3) self.assertEquals(char.artha_persona(),2) self.assertEquals(char.artha_deeds(),0) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),2) self.assertEquals(char.artha_persona(),1) self.assertEquals(char.artha_deeds(),0) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),1) self.assertEquals(char.artha_persona(),1) self.assertEquals(char.artha_deeds(),0) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),1) self.assertEquals(char.artha_persona(),0) self.assertEquals(char.artha_deeds(),0) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),0) self.assertEquals(char.artha_persona(),0) self.assertEquals(char.artha_deeds(),0) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),0) self.assertEquals(char.artha_persona(),0) self.assertEquals(char.artha_deeds(),0)
def setUp(self): self.char = Character()
class TraitTests(unittest.TestCase): def setUp(self): self.char = Character([ Lifepath(born=True, years=1,trait_points=100)]) def testDie(self): dietrait = DieTrait('Mark of Privilege', 3) self.assertEquals(dietrait.name, 'Mark of Privilege') self.assertEquals(dietrait.cost, 3) dietrait = DieTrait('Corvus and Crucis', 4) self.assertEquals(dietrait.name, 'Corvus and Crucis') self.assertEquals(dietrait.cost, 4) def testCallOn(self): cotrait = CallOnTrait('Follow the Money', 2) self.assertEquals(cotrait.name, 'Follow the Money') self.assertEquals(cotrait.cost, 2) cotrait = CallOnTrait('Forked Tongue', 3) self.assertEquals(cotrait.name, 'Forked Tongue') self.assertEquals(cotrait.cost, 3) def testChar(self): ctrait = CharacterTrait('Testing Fiend') ctrait2 = CharacterTrait('Testing Fiend') self.assertEquals(ctrait.name, 'Testing Fiend') self.assertEquals(ctrait.cost, 1) self.assertEquals(ctrait, ctrait2) def testISolzjah(self): # No Kerrn requirement? Humans and Vaylen can take it? pass def testHumanOnlyTrait(self): human_only = [BrightMark(), Forged(), FuurBlood(), HammerLord(), Primarch()] pass def testRequiresBrightMarkTrait(self): """test if Gift of Ahmilahk and The Psychologists Code require the Bright Makr """ req_bright_mark = [GiftOfAhmilahk(), ThePsychologistsCode()] for x in req_bright_mark: self.assertFalse(x.allowed(self.char)) self.assertFalse(x in self.char.allowed_traits()) self.char.buy_trait(BrightMark()) self.assertTrue(x.allowed(self.char)) self.assertTrue(x in self.char.allowed_traits()) self.char.remove_trait(BrightMark()) def testWarriorsCode(self): """test requirements for Warriors Code trait 'Bright Mark required. Alternately, the player may use the mule trait,but he must also take a Branded Character Trait. The circle brands him as one of their own' Bright mark OR (Mule AND Branded?) Is branded free? I will guess no """ self.assertFalse(WarriorsCode().allowed(self.char)) self.assertFalse(WarriorsCode() in self.char.allowed_traits()) self.char.buy_trait(BrightMark()) self.assertTrue(WarriorsCode().allowed(self.char)) self.assertTrue(WarriorsCode() in self.char.allowed_traits()) self.char.remove_trait(BrightMark()) self.assertFalse(WarriorsCode().allowed(self.char)) self.assertFalse(WarriorsCode() in self.char.allowed_traits()) self.char.buy_trait(Mule()) self.assertFalse(WarriorsCode().allowed(self.char)) self.assertFalse(WarriorsCode() in self.char.allowed_traits()) self.char.buy_trait(Branded()) self.assertTrue(WarriorsCode().allowed(self.char)) self.assertTrue(WarriorsCode() in self.char.allowed_traits()) def testAnvilLord(self): """test requirements for Anvil Lord Trait 'if not gained as an lp trait, the character must be born to rule or have the magnate lifepath' ie: requires magnate, born to rule, or anvil lord """ for test_name in ['Magnate', 'Born to Rule', 'Anvil Lord']: self.assertFalse(AnvilLord().allowed(self.char)) self.assertFalse(AnvilLord() in self.char.allowed_traits()) self.char.add_path( Lifepath(test_name)) self.assertTrue(AnvilLord().allowed(self.char)) self.assertTrue(AnvilLord() in self.char.allowed_traits()) self.char.remove_path() def testAnvilTrained(self): """test requirements for Anvil Trained trait: may not be taken by mukhadish i.e., only human, kern or vaylen """ pass def testArbiter(self): """test requirements for Arbiter Trait Archcotare or Cult Leader LP """ for test_name in ['Archcotare', 'Cult Leader']: self.assertFalse(Arbiter().allowed(self.char)) self.assertFalse(Arbiter() in self.char.allowed_traits()) self.char.add_path(Lifepath(test_name)) self.assertTrue(Arbiter().allowed(self.char)) self.assertTrue(Arbiter() in self.char.allowed_traits()) self.char.remove_path() def testRequiresBornToRule(self): """Test requirements for Bastard and Your Eminence/Grace/Lordship/Majesty: Born to Rule Lifepath """ req_born_to_rule = [Bastard(), YourEminence(), YourGrace(), YourLordship(), YourMajesty()] for x in req_born_to_rule: self.assertFalse(x.allowed(self.char)) self.assertFalse(x in self.char.allowed_traits()) self.char.remove_path() self.char.add_path( Lifepath(name='Born to Rule', born=True, trait_points=100)) self.assertTrue(x.allowed(self.char)) self.assertTrue(x in self.char.allowed_traits()) self.char.remove_path() self.char.add_path( Lifepath(born=True, trait_points=100)) def testBornOnTheWheel(self): """test requirements for Born on the Wheel trait: Born on the Wheel LP only """ self.assertFalse(BornOnTheWheel().allowed(self.char)) self.assertFalse(BornOnTheWheel() in self.char.allowed_traits()) self.char.add_path(Lifepath(name='Born on the Wheel')) self.assertTrue(BornOnTheWheel().allowed(self.char)) self.assertTrue(BornOnTheWheel() in self.char.allowed_traits()) def testCitizenOfTheCommune(self): """test requirements for Citizen of the Commune trait: Born Citizen LP only """ self.assertFalse(CitizenOfTheCommune().allowed(self.char)) self.assertFalse(CitizenOfTheCommune() in self.char.allowed_traits()) self.char.remove_path() self.char.add_path( Lifepath(name='Born Citizen', born=True, trait_points=100)) self.assertTrue(CitizenOfTheCommune().allowed(self.char)) self.assertTrue(CitizenOfTheCommune() in self.char.allowed_traits()) def testCodebreaker(self): """test requirements for Codebreaker trait: Psychologist-type characters only """ pass def testContender(self): """test requirements for Contender trait: Mark of Privilege Trait """ self.assertFalse(Contender().allowed(self.char)) self.assertFalse(Contender() in self.char.allowed_traits()) self.char.buy_trait(MarkOfPrivilege()) self.assertTrue(Contender().allowed(self.char)) self.assertTrue(Contender() in self.char.allowed_traits()) def testCorvusAndCrucis(self): #Characters with a human body #ie: humans, and vaylen in the human or infiltrator settings pass def testCotarFomas(self): """test requirements for Cotar Fomas trait: cotar fomas lp only """ self.assertFalse(CotarFomas().allowed(self.char)) self.assertFalse(CotarFomas() in self.char.allowed_traits()) self.char.add_path( Lifepath(name='Cotar Fomas')) self.assertTrue(CotarFomas().allowed(self.char)) self.assertTrue(CotarFomas() in self.char.allowed_traits()) def testDevotedToFire(self): """test requirements for Devoted to Fire trait: Devoted to Fire LP only What?! But why is it listed in the Sodalis-Brother LP? """ self.assertFalse(DevotedToFire().allowed(self.char)) self.assertFalse(DevotedToFire() in self.char.allowed_traits()) self.char.add_path( Lifepath(name='Devoted to Fire')) self.assertTrue(DevotedToFire().allowed(self.char)) self.assertTrue(DevotedToFire() in self.char.allowed_traits()) def testDregutai(self): """test requirements for Dregutai trait: Dregus LP only """ self.assertFalse(Dregutai().allowed(self.char)) self.assertFalse(Dregutai() in self.char.allowed_traits()) self.char.add_path( Lifepath(name='Dregus')) self.assertTrue(Dregutai().allowed(self.char)) self.assertTrue(Dregutai() in self.char.allowed_traits()) def testEducated(self): """test requirements for Educated trait: Human and Vaylen only #any vaylen setting? It seems like more of a human or makara caste thing """ h = Human([Lifepath(born=True, trait_points=100)]) self.assertTrue(Educated().allowed(h)) self.assertTrue(Educated() in h.allowed_traits()) def testEmperorsSteward(self): """test requirements of Emperor's Steward Trait:Lord Steward LP """ self.assertFalse(EmperorsSteward().allowed(self.char)) self.assertFalse(EmperorsSteward() in self.char.allowed_traits()) self.char.add_path(Lifepath(name='Lord Steward')) self.assertTrue(EmperorsSteward().allowed(self.char)) self.assertTrue(EmperorsSteward() in self.char.allowed_traits()) def testFamily(self): #Kerrn Diazspherah, Human, Mukhadish Underworld setting and Vaylen setting characters only #any human? the human stock? pass def testGarbo(self): #Human or Human-bodied Vaylen only #Ie, human stock, or lifepath in human caste or invader settings? any or ends in? pass def testRequiresCorvusAndCrucis(self): """test requirements for Iron Trained and Wigged trait: Corvus and Crucis trait """ for x in [IronTrained(), Wigged()]: self.assertFalse(x.allowed(self.char)) self.assertFalse(x in self.char.allowed_traits()) self.char.buy_trait(CorvusAndCrucis()) self.assertTrue(x.allowed(self.char)) self.assertTrue(x in self.char.allowed_traits()) self.char.remove_trait(CorvusAndCrucis()) def testKeeperOfTheFire(self): """test requirements for Keeper of the Fire Trait: Keeper of the Fire LP only No such lifepath. I assume they mean Cotar """ self.assertFalse(KeeperOfTheFire().allowed(self.char)) self.assertFalse(KeeperOfTheFire() in self.char.allowed_traits()) self.char.add_path(Lifepath(name='Cotar')) self.assertTrue(KeeperOfTheFire().allowed(self.char)) self.assertTrue(KeeperOfTheFire() in self.char.allowed_traits()) def testKravMagahTrained(self): #Human, Vaylen and Mukhadish characters may only take this if there are no Kerrn player characters in their group # So Kerrn can take it without restriction. Maybe a notice otherwise? pass def testMarkOfPrivilege(self): """test requirements for Mark of Privilege trait: Born to Rule, Vaylen Captain and Vaylen Command LPs only """ self.assertFalse(MarkOfPrivilege().allowed(self.char)) self.assertFalse(MarkOfPrivilege() in self.char.allowed_traits()) self.char.add_path(Lifepath(name='Born to Rule')) self.assertTrue(MarkOfPrivilege().allowed(self.char)) self.assertTrue(MarkOfPrivilege() in self.char.allowed_traits()) def testMetropolitan(self): """test requirements for Metropolitan and Word is Law traits: Cotar Antistes LP only """ self.assertFalse(Metropolitan().allowed(self.char)) self.assertFalse(Metropolitan() in self.char.allowed_traits()) self.assertFalse(WordIsLaw().allowed(self.char)) self.assertFalse(WordIsLaw() in self.char.allowed_traits()) self.char.add_path( Lifepath(name='Cotar Antistes')) self.assertTrue(Metropolitan().allowed(self.char)) self.assertTrue(Metropolitan() in self.char.allowed_traits()) self.assertTrue(WordIsLaw().allowed(self.char)) self.assertTrue(WordIsLaw() in self.char.allowed_traits()) def testOfficer(self): """test requirements for Officer trait: Hammer Captain and Vaylen Captain LPs only """ self.assertFalse(Officer().allowed(self.char)) self.assertFalse(Officer() in self.char.allowed_traits()) self.char.add_path( Lifepath(name='Hammer Captain')) self.assertTrue(Officer().allowed(self.char)) self.assertTrue(Officer() in self.char.allowed_traits()) def testOwnerAboard(self): #The character must purchase a ship as part of his starting resources and must begin with Resources 7 or higher pass def testPublicServant(self): """test requirements for public servant:Civilian Commune or Merchant League Only taken once, or "ends with"? """ self.assertFalse(PublicServant().allowed(self.char)) self.assertFalse(PublicServant() in self.char.allowed_traits()) self.char.add_path(CommuneLifepath()) self.assertTrue(PublicServant().allowed(self.char)) self.assertTrue(PublicServant() in self.char.allowed_traits()) self.char.remove_path() self.assertFalse(PublicServant().allowed(self.char)) self.assertFalse(PublicServant() in self.char.allowed_traits()) self.char.add_path(MerchantLeagueLifepath()) self.assertTrue(PublicServant().allowed(self.char)) self.assertTrue(PublicServant() in self.char.allowed_traits()) def testSenator(self): """test requirements for Senator trait: Legislative [Official] LP only """ self.assertFalse(Senator().allowed(self.char)) self.assertFalse(Senator() in self.char.allowed_traits()) self.char.add_path(Lifepath(name='Legislative Official')) self.assertTrue(Senator().allowed(self.char)) self.assertTrue(Senator() in self.char.allowed_traits()) def testSlaggah(self): """test requirements for Slaggah trait: only for characters with the Artillery or Strategy skills Not sure if that's a real requirement """ pass def testTough(self): """round up calculations for mortal wound """ self.char.buy_power() self.char.buy_forte() self.assertEquals(self.char.mortal_wound(), 'H7') self.assertEquals(self.char.maimed_wound(), 'H5') self.char.buy_forte() self.assertEquals(self.char.mortal_wound(), 'H7') self.assertEquals(self.char.maimed_wound(), 'H5') self.char.buy_trait(Tough()) self.assertEquals(self.char.mortal_wound(), 'H8') self.assertEquals(self.char.maimed_wound(), 'H6') self.char.buy_forte() def testVig(self): """test requirements for Vig Trait: Outcast and Criminal LPs only """ self.assertFalse(Vig().allowed(self.char)) self.assertFalse(Vig() in self.char.allowed_traits()) self.char.add_path(OutcastLifepath()) self.assertTrue(Vig().allowed(self.char)) self.assertTrue(Vig() in self.char.allowed_traits())
def testMortalWoundTolerance(self): char = Character([Lifepath(born=True, years=1)]) char.buy_power() char.buy_forte() self.assertEquals(char.mortal_wound(), 'H7') char.buy_forte() self.assertEquals(char.mortal_wound(), 'H7') char.buy_forte() self.assertEquals(char.mortal_wound(), 'H8')
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)
def testRemoveStats(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) char.remove_agility() char.remove_speed() char.remove_power() char.remove_forte() char.remove_perception() char.remove_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)
class CharacterStatsTests(unittest.TestCase): def setUp(self): self.char = Character() def testStatPtsAge0(self): self.assertEquals(self.char.mental_pool(), 0) self.assertEquals(self.char.physical_pool(), 0) def testStatPtsRange(self): various_ages = {Character(age=1):[5,10], Character(age=10):[5,10], Character(age=11):[6,13], Character(age=14):[6,13], Character(age=15):[6,16], Character(age=16):[6,16], Character(age=17):[7,16], Character(age=25):[7,16], Character(age=26):[7,15], Character(age=29):[7,15], Character(age=30):[7,14], Character(age=35):[7,14], Character(age=36):[7,13], Character(age=40):[7,13], Character(age=41):[7,12], Character(age=55):[7,12], Character(age=56):[7,11], Character(age=65):[7,11], Character(age=66):[7,10], Character(age=79):[7,10], Character(age=80):[6,9], Character(age=100):[6,9]} for character, points in various_ages.iteritems(): self.assertEquals(character.mental_pool(), points[0]) self.assertEquals(character.physical_pool(), points[1]) def testStatsDefault(self): """Can characters start with any stat at 0? Paraplegics, I guess. """ self.assertEquals(self.char.perception, 0) self.assertEquals(self.char.will, 0) self.assertEquals(self.char.agility, 0) self.assertEquals(self.char.speed, 0) self.assertEquals(self.char.power, 0) self.assertEquals(self.char.forte, 0) 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 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 testRemoveStats(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) char.remove_agility() char.remove_speed() char.remove_power() char.remove_forte() char.remove_perception() char.remove_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 testBuyStatsWithoutPoints(self): char = Character(age = 1) char.buy_will(5) self.assertEquals(char.will, 5) self.assertEquals(char.mental_pool(), 0) self.assertRaises(CantAfford, char.buy_will) self.assertRaises(CantAfford, char.buy_perception) char.buy_forte(3) char.buy_speed(3) char.buy_power(3) char.buy_agility(1) self.assertEquals(char.forte, 3) self.assertEquals(char.speed, 3) self.assertEquals(char.power, 3) self.assertEquals(char.agility,1) self.assertEquals(char.physical_pool(),0) self.assertRaises(CantAfford, char.buy_forte) self.assertRaises(CantAfford, char.buy_agility) self.assertRaises(CantAfford, char.buy_speed) self.assertRaises(CantAfford, char.buy_power) 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 testAgeOver100(self): """Character's age cannot exceed 100 """ char = Character(age = 100) self.assertRaises(ExceedsMaximum, char.add_path, Lifepath(years=1)) self.assertFalse(Lifepath(years=1).allowed(char)) 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 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 testBonusStatPoints(self): char = Character([Lifepath(years=1, born=True)]) char.add_path(Lifepath(physical_points=1)) self.assertEquals(char.physical_pool(), 11) char.remove_path() char.add_path(Lifepath(mental_points=1)) self.assertEquals(char.mental_pool(), 6) 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) def testMortalWoundTolerance(self): char = Character([Lifepath(born=True, years=1)]) char.buy_power() char.buy_forte() self.assertEquals(char.mortal_wound(), 'H7') char.buy_forte() self.assertEquals(char.mortal_wound(), 'H7') char.buy_forte() self.assertEquals(char.mortal_wound(), 'H8') def testSuperficialWoundTolerance(self): char = Character([Lifepath(born=True, years=1)]) char.buy_forte() self.assertEquals(char.superficial_wound(), 'H1') char.buy_forte() self.assertEquals(char.superficial_wound(), 'H2') char.buy_forte() self.assertEquals(char.superficial_wound(), 'H2') def testInjuredWoundTolerance(self): char = Character([Lifepath(born=True, years=1)]) char.buy_forte() self.assertEquals(char.injured_wound(), 'H1') char.buy_forte() self.assertEquals(char.injured_wound(), 'H3') char.buy_forte() self.assertEquals(char.injured_wound(), 'H3') def testMaimedWoundTolerance(self): char = Character([Lifepath(born=True, years=1)]) char.buy_power() char.buy_forte() self.assertEquals(char.maimed_wound(), 'H5') char.buy_forte() self.assertEquals(char.maimed_wound(), 'H5') char.buy_forte() self.assertEquals(char.maimed_wound(), 'H6') def testResources(self): self.assertEquals(self.char.resources(), 0) self.char.add_path(Lifepath(born=True, resources=1)) self.assertEquals(self.char.resources(), 1) self.char.remove_path() self.assertEquals(self.char.resources(), 0) def testResourcesAfterMultiplePaths(self): """I assume only the exact same path counts as the same path, as opposed to any path with the same name """ self.char.add_path(human.BornLeague()).add_path(human.LeagueStudent()) self.assertEquals(self.char.resources(), 2) self.char.add_path(human.Accountant()).add_path(human.Accountant()).add_path(human.Accountant()) self.assertEquals(self.char.resources(), 7) self.char.remove_path(3).add_path(human.Scrivener()).add_path(human.Scrivener()).add_path(human.Scrivener()) self.assertEqual(self.char.resources(), 4) def testCircles(self): self.assertEquals(self.char.circles(), 0) self.char.add_path(Lifepath(born=True, circles=1)) self.assertEquals(self.char.circles(), 1) self.char.remove_path() self.assertEquals(self.char.circles(), 0) def testCirclesAfterMultiplePaths(self): self.char.add_path(human.BornNobility()).add_path(human.NobleCoeptir()).add_path(human.NobleArmiger()) self.assertEquals(self.char.circles(), 1) self.char.add_path(human.NobleLPAnvil()).add_path(human.NobleLPAnvil()).add_path(human.NobleLPAnvil()) self.assertEquals(self.char.circles(), 3) def testArtha(self): char = Character() self.assertEquals(char.artha_fate(),3) self.assertEquals(char.artha_persona(),2) self.assertEquals(char.artha_deeds(),1) char.add_path(Lifepath(born=True)) self.assertEquals(char.artha_fate(),3) self.assertEquals(char.artha_persona(),2) self.assertEquals(char.artha_deeds(),1) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),3) self.assertEquals(char.artha_persona(),2) self.assertEquals(char.artha_deeds(),1) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),3) self.assertEquals(char.artha_persona(),2) self.assertEquals(char.artha_deeds(),1) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),3) self.assertEquals(char.artha_persona(),2) self.assertEquals(char.artha_deeds(),1) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),3) self.assertEquals(char.artha_persona(),2) self.assertEquals(char.artha_deeds(),1) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),3) self.assertEquals(char.artha_persona(),2) self.assertEquals(char.artha_deeds(),0) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),2) self.assertEquals(char.artha_persona(),1) self.assertEquals(char.artha_deeds(),0) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),1) self.assertEquals(char.artha_persona(),1) self.assertEquals(char.artha_deeds(),0) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),1) self.assertEquals(char.artha_persona(),0) self.assertEquals(char.artha_deeds(),0) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),0) self.assertEquals(char.artha_persona(),0) self.assertEquals(char.artha_deeds(),0) char.add_path(Lifepath()) self.assertEquals(char.artha_fate(),0) self.assertEquals(char.artha_persona(),0) self.assertEquals(char.artha_deeds(),0)
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)
class CharacterTraitsTests(unittest.TestCase): def setUp(self): self.char = Character() def testGainsRequiredTrait(self): self.assertFalse(self.char.has_trait('Required Trait')) self.char.add_path(Lifepath(born=True, traits=[trait.Trait(name='Required Trait'), trait.Trait(name='Optional Trait')])) self.assertTrue(self.char.has_trait(trait.Trait(name='Required Trait'))) self.assertFalse(self.char.has_trait(trait.Trait(name='Optional Trait'))) def testGainsRequiredTraitsAfterMultiplePaths(self): self.char.add_path(Lifepath(born=True, traits=[trait.Trait(name='First Trait'), trait.Trait(name='Second Trait')])) self.assertTrue(self.char.has_trait(trait.Trait(name='First Trait'))) self.assertFalse(self.char.has_trait(trait.Trait(name='Second Trait'))) self.char.add_path(Lifepath(traits=[trait.Trait(name='First Trait'), trait.Trait(name='Second Trait')])) self.assertTrue(self.char.has_trait(trait.Trait(name='Second Trait'))) def testCountTraitPoints(self): """Most paths give trait points. However, they also might give access to traits. Every time a a path is taken: the first trait in the list that the character does not have is bought for one trait point The second time and later times a path is taken: If there is no such trait, then the path awards one less trait point I assume this is the case even with paths that never award traits plan: add path with no points or traits (0) add path with 1 point and first trait (0) add path with 2 points and second trait (1) add path with 2 points and first trait (2) add path with 1 point and second trait (2) add path with 1 point and no traits (3) add same path with 1 point and no traits (3) """ self.char.add_path(human.BornNobility()) self.assertEquals(self.char.trait_points(), 0) self.char.add_path(human.NobleCoeptir()) self.assertEquals(self.char.trait_points(), 1) self.char.add_path(human.NobleArmiger()) self.assertEquals(self.char.trait_points(), 1) self.char.add_path(human.NobleLPAnvil()) self.assertEquals(self.char.trait_points(), 2) self.char.add_path(human.NobleLPAnvil()) self.assertEquals(self.char.trait_points(), 3) self.char.add_path(human.NobleLPAnvil()) self.assertEquals(self.char.trait_points(), 3) self.char.remove_path(5) self.assertEquals(self.char.trait_points(), 0) self.char.add_path(human.Companion()) self.assertEquals(self.char.trait_points(), 2) self.char.add_path(human.Lady()) self.assertEquals(self.char.trait_points(), 3) self.char.add_path(human.Lady()) self.assertEquals(self.char.trait_points(), 3) def testTraitList(self): char = Character([human.BornNobility(), human.NobleCoeptir(), human.NobleArmiger()]) self.assertEquals(char.traits(), [trait.MarkOfPrivilege(), trait.AnvilTrained()]) char.add_path(human.NobleLPAnvil()) self.assertEquals(char.traits(), [trait.MarkOfPrivilege(), trait.AnvilTrained(), trait.CorvusAndCrucis()]) char.add_path(human.NobleLPAnvil()) self.assertEquals(char.traits(), [trait.MarkOfPrivilege(), trait.AnvilTrained(), trait.CorvusAndCrucis(), trait.IronTrained()]) def testLifepathTraits(self): """All traits on all the paths the character has taken are listed. """ char = Character() char.add_path(human.BornNobility()) self.assertEquals(char.lifepath_traits(), [trait.MarkOfPrivilege(), trait.YourLordship(), trait.YourEminence(), trait.YourGrace(), trait.YourMajesty()]) def testAllowedTraits(self): """all traits the character has not bought and can currently afford """ char = human.Human() self.assertEquals(char.allowed_traits(), []) char.add_path(human.BornNobility()) self.assertEquals(char.allowed_traits(), []) char.add_path(human.NobleCoeptir()) self.assertTrue(trait.Amorous() in char.allowed_traits()) self.assertTrue(trait.YourLordship() in char.allowed_traits()) self.assertTrue(trait.YourEminence() in char.allowed_traits()) self.assertTrue(trait.YourGrace() in char.allowed_traits()) self.assertTrue(trait.YourMajesty() in char.allowed_traits()) def testBuyTraits(self): char = Character([human.BornNobility(), human.NobleCoeptir(), human.NobleArmiger()]) char.buy_trait(trait.CharacterTrait()) self.assertEquals(char.traits(), [trait.MarkOfPrivilege(), trait.AnvilTrained(), trait.CharacterTrait()]) self.assertEquals(self.char.trait_points(),0) def testCantAffordTraits(self): char = Character([human.BornNobility(), human.NobleCoeptir(), human.NobleArmiger()]) self.assertEquals(char.trait_points(), 1) self.assertRaises(NotAllowed, char.buy_trait, trait.CalmDemeanor()) self.assertEquals(char.trait_points(), 1) char.add_path(human.NobleLPAnvil()) self.assertEquals(char.trait_points(),2) char.buy_trait(trait.CalmDemeanor()) self.assertEquals(char.traits(), [trait.MarkOfPrivilege(), trait.AnvilTrained(), trait.CorvusAndCrucis(), trait.CalmDemeanor()]) self.assertEquals(char.trait_points(),0) def testRemoveTraits(self): char = Character([human.BornNobility(), human.NobleCoeptir(), human.NobleArmiger(), human.NobleLPAnvil()]) char.buy_trait(trait.CharacterTrait('Trait 1')) char.buy_trait(trait.IronTrained()) self.assertEquals(char.trait_points(), 0) char.remove_trait(trait.IronTrained()) self.assertEquals(char.trait_points(), 1) self.assertRaises(Exception, char.remove_trait, trait.CharacterTrait('Trait 2')) char.remove_trait(trait.CharacterTrait('Trait 1')) self.assertEquals(char.trait_points(), 2) def testCheaperTraits(self): """All traits on the available list cost only one point """ char = Character([human.BornNobility(), human.NobleCoeptir(), human.NobleArmiger()]) char.buy_trait(trait.Tough()) self.assertEquals(char.traits(), [trait.MarkOfPrivilege(), trait.AnvilTrained(), trait.Tough()]) self.assertEquals(char.trait_points(), 0) def testTraitsGetCheaper(self): """A trait can be bought, after which a lifepath is added that puts that trait on the available list. The difference in cost should be refunded """ char = Character([human.BornNobility(), human.Bastard(), human.TheocracyStudent(), human.Soldier(), human.Sergeant()]) self.assertEquals(char.trait_points(), 3) char.buy_trait(trait.Tough()) self.assertEquals(char.trait_points(), 0) char.add_path(human.NobleArmiger()) self.assertEquals(char.trait_points(), 2) self.assertTrue(char.has_trait(trait.Tough())) def testLoseBoughtTraits(self): """A trait can be bought, then a lifepath removed, causing either: 1. The loss of the points used to buy the trait 2. The trait becomes more expensive than the character can afford In these cases, traits should be removed, starting with the most recently addded, until balance is restored """ char = Character([human.BornNobility(), human.Bastard(), human.Soldier(), human.Sergeant()]) self.assertEquals(char.trait_points(), 2) char.add_path(human.NobleArmiger()) char.buy_trait(trait.Tough()) self.assertEquals(char.trait_points(), 1) char.remove_path() self.assertEquals(char.trait_points(), 2) self.assertFalse(char.has_trait(trait.Tough()))
def setUp(self): self.char = Character([ Lifepath(born=True, years=1,trait_points=100)])
def testBuyTraits(self): char = Character([human.BornNobility(), human.NobleCoeptir(), human.NobleArmiger()]) char.buy_trait(trait.CharacterTrait()) self.assertEquals(char.traits(), [trait.MarkOfPrivilege(), trait.AnvilTrained(), trait.CharacterTrait()]) self.assertEquals(self.char.trait_points(),0)
def testRemoveTraits(self): char = Character([human.BornNobility(), human.NobleCoeptir(), human.NobleArmiger(), human.NobleLPAnvil()]) char.buy_trait(trait.CharacterTrait('Trait 1')) char.buy_trait(trait.IronTrained()) self.assertEquals(char.trait_points(), 0) char.remove_trait(trait.IronTrained()) self.assertEquals(char.trait_points(), 1) self.assertRaises(Exception, char.remove_trait, trait.CharacterTrait('Trait 2')) char.remove_trait(trait.CharacterTrait('Trait 1')) self.assertEquals(char.trait_points(), 2)
def testAnyFromSetting(self): """born lifepaths never count towards this """ from character.human import AnvilLifepath, HammerLifepath one_if_by_land = Requirement(paths={(AnvilLifepath,):1}) two_if_by_space = Requirement(paths={(HammerLifepath,):2}) combined_arms = Requirement(paths={(AnvilLifepath,HammerLifepath):1}) soldier = Character([AnvilLifepath(born=True)]) sailor = Character([HammerLifepath(born=True)]) marine = Character([HammerLifepath(born=True), AnvilLifepath()]) self.assertFalse(one_if_by_land.allowed(soldier)) self.assertFalse(two_if_by_space.allowed(soldier)) self.assertFalse(combined_arms.allowed(soldier)) soldier.add_path(AnvilLifepath()) self.assertTrue(one_if_by_land.allowed(soldier)) self.assertFalse(two_if_by_space.allowed(soldier)) self.assertTrue(combined_arms.allowed(soldier)) self.assertFalse(one_if_by_land.allowed(sailor)) self.assertFalse(two_if_by_space.allowed(sailor)) self.assertFalse(combined_arms.allowed(sailor)) sailor.add_path(HammerLifepath()) self.assertFalse(one_if_by_land.allowed(sailor)) self.assertFalse(two_if_by_space.allowed(sailor)) self.assertTrue(combined_arms.allowed(sailor)) sailor.add_path(HammerLifepath()) self.assertTrue(two_if_by_space.allowed(sailor)) self.assertTrue(one_if_by_land.allowed(marine)) self.assertFalse(two_if_by_space.allowed(marine)) self.assertTrue(combined_arms.allowed(marine)) marine.add_path(HammerLifepath()) self.assertFalse(two_if_by_space.allowed(marine)) marine.add_path(HammerLifepath()) self.assertTrue(two_if_by_space.allowed(marine))
def testMaimedWoundTolerance(self): char = Character([Lifepath(born=True, years=1)]) char.buy_power() char.buy_forte() self.assertEquals(char.maimed_wound(), 'H5') char.buy_forte() self.assertEquals(char.maimed_wound(), 'H5') char.buy_forte() self.assertEquals(char.maimed_wound(), 'H6')