def doattack(self):
        if (self.advantage.get() and not self.disadvantage.get()):
            attstring = '2d20h1'
        elif (not self.advantage.get() and self.disadvantage.get()):
            attstring = '2d20l1'
        else:
            attstring = '1d20'
        attroll = r.call(attstring)

        if (self.attackE.get()):
            attmodifiers = r.call(self.attackE.get())
        else:
            attmodifiers = 0

        if (attroll == 20):
            attresult = 'Critical Hit'
            damresult = str(r.call(self.damageE.get(), option='critical'))
        elif (attroll == 1):
            attresult = 'Critical Miss'
            damresult = '0'
        else:
            attresult = str(attroll + attmodifiers)
            damresult = str(r.call(self.damageE.get()))
        self.attackresult['text'] = 'Attack result: ' + attresult
        self.damageresult['text'] = 'Damage done: ' + damresult
Exemple #2
0
 def attack(self, character, adv, dis, attackBonus, damageBonus):
     #character: a character object that is performing the attack
     #adv: boolean, whether you have advantage
     #dis: boolean, whether you have disadvantage
     #attackBonus: string, a rolled bonus to attack 
     #damageBonus: string, a rolled bonus to damage
     modifier = abilMod(character.abilities[self.ability])
     result = [[], [], '']
     if (character.spellslots[self.level] == 0):
         result = [[], [], 'You are out of spells of that level.']
         return result
     elif (self.level > 0):
         character.spendSpell(self.level)
     for all in range(self.multiple):
         opt = 'execute'
         if (self.attackroll):
             if (adv and not dis):
                 attackstring = '2d20h1'
             elif (not adv and dis):
                 attackstring = '2d20l1'
             else:
                 attackstring = '1d20'
             AB = (r.call(attackBonus) + character.proficiencyBonus + 
                   modifier)
             attackresult = r.call(attackstring)
             if (attackresult == 1):
                 result[0].append('Miss')
                 opt = 'zero'
             elif (attackresult == 20):
                 result[0].append('Critical')
                 opt = 'critical'
             else:
                 result[0].append(attackresult + AB)
                 opt = 'execute'
         DB = r.call(damageBonus,
                     option=opt) + (modifier if self.addabiltodamage else 0)
         if (self.level == 0):
             dice = self.damagedice + ('+' + self.damagedice) * (
                 character.cantripscale - 1)
         else:
             dice = self.damagedice
         result[1].append(r.call(dice, option=opt, modifiers=DB))
     if (not self.attackroll):
         saveDC = 8 + character.proficiencyBonus + modifier
         result[0] = ('Make a DC ' + str(saveDC) + ' ' + self.savetype +
                      ' saving throw.')
     result[2] = self.effects
     return result
 def pull(self, otherwin):
     abils = [0, 0, 0, 0, 0, 0]
     for i in range(len(otherwin.entries)):
         abils[i] = int(otherwin.entries[i].get())
     hp = r.call(otherwin.hp.get(),
                 option='average') if otherwin.av.get() else r.call(
                     otherwin.hp.get())
     rv = monster(otherwin.name.get(),
                  hp,
                  otherwin.hp.get(),
                  r.call('1d20',
                         modifiers=modifier(abils[1])),
                  otherwin.ac.get(),
                  abils)
     self.frames.append(sub(self.master, rv))
     self.draw()
 def pull(self):
     data = {}
     data['name'] = self.name.get()
     data['level'] = (self.level.get())
     data['caster level'] = (self.casterlevel.get())
     data['class'] = self.Class.get().lower()
     data['max hp'] = str(r.call(self.maxhp.get()))
     return data
Exemple #5
0
 def attack(self, character, adv, dis, attackBonus, damageBonus):
     #character: a character object that is performing the attack
     #adv: boolean, whether you have advantage
     #dis: boolean, whether you have disadvantage
     #attackBonus: string, a rolled bonus to attack 
     #damageBonus: string, a rolled bonus to damage
     result = [[], [], '']
     modifier = abilMod(character.abilities[self.ability])
     if (self.ammunition == 0):
         result = [[], [], 'You are out of ammunition for this weapon.']
         return result
     if (self.ammunition):
         self.ammunition -= 1
     for all in range(self.multiple):
         opt = 'execute'
         if (self.attackroll):
             if (adv and not dis):
                 attackstring = '2d20h1'
             elif (not adv and dis):
                 attackstring = '2d20l1'
             else:
                 attackstring = '1d20'
             AB = (r.call(attackBonus) + character.proficiencyBonus + 
                   modifier + self.magicbonus)
             attackresult = r.call(attackstring)
             if (attackresult == 1):
                 result[0].append('Miss')
                 opt = 'zero'
             elif (attackresult == 20):
                 result[0].append('Critical')
                 opt = 'critical'
             else:
                 result[0].append(attackresult + AB)
                 option = 'execute'
         DB = r.call(damageBonus, option=opt) + modifier + self.magicbonus
         result[1].append(r.call(self.damagedice, option=opt, modifiers=DB))
     if (not self.attackroll):
         result[0] = 'Attack auto-hits.'
     result[2] = self.effects
     return result
 def changeHP(self, totemp=False):
     amount = r.call(self.amount.get())
     h = int(self.current.get())
     t = int(self.temp.get())
     m = int(self.max.get())
     if (totemp):
         t += amount
     else:
         if (amount < 0):
             if (abs(amount) > t):
                 amount += t
                 t = 0
                 h += amount
             else:
                 t += amount
         else:
             h += amount
             h = m if h > m else h
     util.replaceEntry(self.temp, str(t))
     util.replaceEntry(self.current, str(h))
 def __init__(self, name, init):
     self.name = name
     self.initiative = r.call(init)
 def changeHP(self):
     var = round(r.call(self.change.get()))
     self.creature.alterHP(var)
     self.refresh()
 def doRoll(self):
     self.result["text"] = r.call(self.generalRoll.get())