def initCharacter(self): abils = self.pullABIL() info = self.pullINFO() self.activeCharacter = dnd.character( info['name'], int(info['level']), abils, self.characterdata['Attacks'], info['class'], int(info['caster level']), self.characterdata['spell slots']) self.spell.draw()
def getConfigData(self): reader = cp.ConfigParser() ini_name = './character/' + self.info.name.get() + '.ini' data = {'Attacks': {}} try: reader.read(ini_name) except (KeyError): errorWindow = tk.Toplevel() tk.Label( errorWindow, text= "There is no .ini file in the character directory\nwith name " + ini_name).pack() tk.Button(errorWindow, command=errorWindow.destroy, text="OK").pack() return None for sp in reader['Spells']: args = dnd.readConfig(reader['Spells'][sp]) args[-1] = args[-1].replace('$', '\n') data['Attacks'][sp] = dnd.spell(*args) for wep in reader['Weapons']: args = dnd.readConfig(reader['Weapons'][wep]) args[-1] = args[-1].replace('$', '\n') data['Attacks'][wep] = dnd.weapon(*args) for ab in ['str', 'dex', 'con', 'int', 'wis', 'cha']: data[ab] = reader['Character'][ab] data['level'] = reader['Character']['level'] data['caster level'] = reader['Character']['caster level'] data['class'] = reader['Character']['class'] data['max HP'] = reader['HP']['max hp'] data['HP'] = reader['HP']['current hp'] data['temp HP'] = reader['HP']['current temp hp'] data['spell slots'] = reader['Spell Slots']['spell slots'] self.characterdata['Attacks'] = data['Attacks'] try: self.characterdata['spell slots'] = r.readList(data['spell slots'], mode='int') except (SyntaxError): self.characterdata['spell slots'] = [0] return data
def doAttack(self): try: res = dnd.resultFormat(self.top.activeCharacter.attacks[ self.attack.get().casefold()].attack( self.top.activeCharacter, self.adv.get(), self.dis.get( ), self.attackBonus.get(), self.damageBonus.get())) self.attackResult["text"] = res[0] self.damageResult["text"] = res[1] self.effects["text"] = res[2] self.top.spell.draw() except (KeyError): self.attackResult["text"] = "Attack with that name not found."
def calcModifiers(self): for (i, e) in enumerate(self.entries): self.modlabels[i]["text"] = dnd.abilMod(int(e.get())) self.modlabels[i].grid(row=i, column=2)