Esempio n. 1
0
 def thac0(self):
     if self.get('personal/race', '') == "creature":
         key = "creature"
     else:
         key = self.get('class/parent', '')
     thac0s = load_yaml("rules", "thac0.yaml")[key]
     for key2 in list(thac0s.keys()):
         if inrange(self.get('combat/level-hitdice', 1), key2):
             return int(thac0s[key2])
Esempio n. 2
0
 def abilities(self):
     subclass = self.get('class/class', '')
     parentclass = self.get('class/parent', '')
     level = self.get('combat/level-hitdice', '')
     various = load_yaml('rules', 'various.yaml')
     abilities = various['abilities']
     conditionals = self.get('abilities', {})
     race = self.get('personal/race', self())
     for ability in abilities:
         base = 0
         if ability in conditionals:
             if isinstance(conditionals[ability], str) and len(conditionals[ability]) > 0:
                 base = int(conditionals[ability])
         if subclass in abilities[ability]:
             for key in abilities[ability][subclass]:
                 if inrange(level, key):
                     base += int(abilities[ability][subclass][key])
                     continue
         elif parentclass in abilities[ability]:
             for key in abilities[ability][parentclass]:
                 if inrange(level, key):
                     base += int(abilities[ability][parentclass][key])
                     continue
         if base > 0:
             if race in abilities[ability]:
                 base += int(abilities[ability][race])
             conditionals[ability] = base
     for key in conditionals:
         racial_bonus = 0
         dex_bonus = 0
         if key in various['abilities']:
             if "racial_bonus" in various['abilities'][key] and race in various['abilities'][key]["racial_bonus"]:
                 racial_bonus = int(various['abilities'][key]["racial_bonus"][race])
             dex = int(self.get('/abilities/dex', 0))
             if "dexterity bonus" in various['abilities'][key]:
                 for d in various['abilities'][key]["dexterity bonus"]:
                     if inrange(dex, d):
                         dex_bonus = int(various['abilities'][key]["dexterity bonus"][d])
                         continue
         if isinstance(conditionals[key], str) and len(conditionals[key]) == 0:
             conditionals[key] = 0
         if int(conditionals[key]) > 0:
             conditionals[key] = int(conditionals[key]) + dex_bonus + racial_bonus
     return conditionals
Esempio n. 3
0
 def num_attacks(self):
     atr_objdata = FlattenedDict(load_yaml('rules', 'various.yaml'))
     atr = atr_objdata['various/attacks_per_round']
     parentclass = self.get('class/parent', '')
     if parentclass not in atr:
         myatr = 1
     else:
         for key in list(atr[parentclass].keys()):
             if inrange(self.get('combat/level-hitdice', 1), key):
                 myatr = int(atr[parentclass][key])
     return self.num_weapons() * int(myatr)
Esempio n. 4
0
 def saving_throws(self):
     """
     >>> char = Character(load_yaml('characters', 'bardic_rogue.yaml'))
     >>> isinstance(char.saving_throws, dict)
     True
     """
     key = self.get('class/parent', '')
     sts = FlattenedDict(load_yaml("rules", "saving_throws.yaml"))
     sts = FlattenedDict(sts.getsubtree(key))
     hitdice = self.get('combat/level-hitdice', 0)
     for key2 in sts.subkeys():
         if inrange(hitdice, key2):
             st = sts.getsubtree(key2)
             st['ppd'] = int(st['ppd']) + self.ppd_mod()
             return(st)
Esempio n. 5
0
 def saving_throw(self, against):
     saving = load_yaml('rules', 'saving_throws.yaml') or {}
     prettyname = saving['names'][against]
     race = self.get('personal/race', '')
     con = int(self.get('attributes/con', 0))
     mod = 0
     if race in list(saving.keys()):
         for key in list(saving[race].keys()):
             if inrange(con, key):
                 mod = int(saving[race][key])
                 continue
     target = int(FlattenedDict(self.saving_throws).get(against, 0))
     out = "%s Tries to roll a saving throw against %s" % (self.displayname(), prettyname)
     out += "<br>%s needs to roll %s" % (self.displayname(), target)
     roll = rolldice(numdice=1, numsides=20, modifier=mod)
     out += '<br>%s' % roll[1]
     if roll[0] >= int(target):
         out += '<br>Saved !'
         return (True, out)
     else:
         out += "<br>Did not save !"
         return (False, out)