diff --git a/func.py b/func.py index 470908e..b58be4f 100644 --- a/func.py +++ b/func.py @@ -1,11 +1,12 @@ # -*-coding:utf-8-*- import math +from modif import * -def getdmg(atq, aroll, base, deff, droll, ta, acu, numdef): +def getdmg(atq, aroll, base, deff, droll, ta, acu, numdef, modatq, moddef): if acu: - abs = 20 + 10 * ta - diff = 10 * math.trunc((atq + aroll - abs) / 10) + abso = 20 + 10 * ta + diff = 10 * math.trunc((atq + aroll + modatq - abso) / 10) if diff > 0: dmg = base * diff // 100 if dmg > 0: @@ -16,9 +17,9 @@ def getdmg(atq, aroll, base, deff, droll, ta, acu, numdef): return u'No produce daño' else: - pendef=[0, -30, -50, -70, -90] - totalat= atq+aroll - totaldef= deff+droll+pendef[numdef-1] + pendef = [0, -30, -50, -70, -90] + totalat = atq + aroll + modatq + totaldef = deff + droll + pendef[numdef-1] + moddef diff = 10 * math.trunc((totalat-totaldef) / 10) if diff > 0: abso = 20 + 10 * ta @@ -31,3 +32,19 @@ def getdmg(atq, aroll, base, deff, droll, ta, acu, numdef): elif diff < 0: contr = -diff // 2 return 'Contraataque con +{}'.format(contr) + + +def getmodat(varlist, halflist): + mod = 0 + for i in range(0, 23): + mod += modifatk[list(modifatk.keys())[i]] * varlist[i].get() / (halflist[i].get() + 1) + return mod + + +def getmoddef(varlist): + mod = 0 + for i in range(0, 35): + mod += modifdef[list(modifdef.keys())[i]] * varlist[i].get() + return mod + + diff --git a/main.py b/main.py index e34a629..c598c52 100644 --- a/main.py +++ b/main.py @@ -3,17 +3,26 @@ import tkinter as tk from tkinter import ttk from func import * +from modif import * class App: def __init__(self): + # Create window self.raiz = tk.Tk() self.raiz.title("AnimaCombatHelper") self.raiz.resizable(0, 0) self.raiz.configure(bg='gray') - - atqframe = ttk.LabelFrame(self.raiz, text='Atacante') - defframe = ttk.LabelFrame(self.raiz, text='Defensor') + notebook = ttk.Notebook(self.raiz) + calc = ttk.Frame(notebook) + mod = ttk.Frame(notebook) + notebook.add(calc, text=u'Calculadora de daño') + notebook.add(mod, text='Modificadores') + notebook.pack(expand=1, fill='both') + # ----------------Damage Calculator---------------- # + # Create Labels + atqframe = ttk.LabelFrame(calc, text='Atacante') + defframe = ttk.LabelFrame(calc, text='Defensor') arolllabel = ttk.Label(atqframe, text='Tirada') atqlabel = ttk.Label(atqframe, text='Hab. Ataque') dmglabel = ttk.Label(atqframe, text=u'Daño base') @@ -22,14 +31,17 @@ def __init__(self): talabel = ttk.Label(defframe, text='TA') numdeflabel = ttk.Label(defframe, text=u'Defensa Nº') - aroll, atq, dmg, droll, deff, ta, acu, numdef = tk.StringVar(), tk.StringVar(), tk.StringVar(), tk.StringVar(), \ - tk.StringVar(), tk.StringVar(), tk.IntVar(), tk.StringVar() + # Create Variables + aroll, atq, dmg, droll = tk.StringVar(), tk.StringVar(), tk.StringVar(), tk.StringVar() + deff, ta, acu, numdef = tk.StringVar(), tk.StringVar(), tk.IntVar(), tk.StringVar() aroll.set(0) droll.set(0) atq.set(0) deff.set(0) dmg.set(0) acu.set(0) + + # Create interactive fields arollbox = ttk.Entry(atqframe, width=12, textvariable=aroll) drollbox = ttk.Entry(defframe, width=12, textvariable=droll) atqbox = ttk.Entry(atqframe, width=12, textvariable=atq) @@ -39,10 +51,11 @@ def __init__(self): acubutton = ttk.Checkbutton(defframe, text=u'Acumulación', variable=acu) numdef = ttk.Combobox(defframe, width=10, textvariable=numdef) taselect['values'] = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) - numdef['values'] = (u'1ª', u'2ª', u'3ª', u'4ª', u'5ª+') + numdef['values'] = ('1', '2', '3', '4', '5+') taselect.current(0) numdef.current(0) + # Place widgets atqframe.grid(column=0, row=0) defframe.grid(column=0, row=1) @@ -59,11 +72,63 @@ def __init__(self): drollbox.grid(column=0, row=1) defbox.grid(column=1, row=1) taselect.grid(column=2, row=1) - final = ttk.Label(self.raiz, text='No pasa nada') + + final = ttk.Label(calc, text='No pasa nada') final.grid(column=0, row=2) + acubutton.grid(column=0, row=2) numdeflabel.grid(column=1, row=2) numdef.grid(column=2, row=2) + + # ----------------Modifiers---------------- # + # Create Frames + atqmodframe = ttk.Labelframe(mod, text='Atacante', padding=(0, 0, 0, 227)) + defmodframe = ttk.Labelframe(mod, text='Defensor') + + # Create Labels + atqnamelabel = ttk.Label(atqmodframe, text='Modificador') + defnamelabel = ttk.Label(defmodframe, text='Modificador') + atqhalflabel = ttk.Label(atqmodframe, text='Mitad') + + # Create Variables + atqmodvars = [] + defmodvars = [] + atqmodhalfs = [] + for i in range(0, 23): + aux = tk.IntVar() + atqmodvars.append(aux) + aux = tk.IntVar() + atqmodhalfs.append(aux) + for i in range(0, 35): + aux = tk.IntVar() + defmodvars.append(aux) + + # Create checkbuttons + atqmodbuttons = [] + atqhalfbuttons = [] + defmodbuttons = [] + for i in range(0, 23): + aux = ttk.Checkbutton(atqmodframe, text=list(modifatk.keys())[i], variable=atqmodvars[i], width=15) + atqmodbuttons.append(aux) + aux = ttk.Checkbutton(atqmodframe, variable=atqmodhalfs[i]) + atqhalfbuttons.append(aux) + for i in range(0, 35): + aux = ttk.Checkbutton(defmodframe, text=list(modifdef.keys())[i], variable=defmodvars[i], width=28) + defmodbuttons.append(aux) + + # Place widgets + atqmodframe.grid(column=0, row=0, padx=5) + defmodframe.grid(column=1, row=0, padx=5) + atqnamelabel.grid(column=0, row=0) + atqhalflabel.grid(column=1, row=0) + defnamelabel.grid(column=0, row=0) + for i in range(0, 23): + atqmodbuttons[i].grid(column=0, row=i+1) + atqhalfbuttons[i].grid(column=1, row=i+1) + for i in range(0, 35): + defmodbuttons[i].grid(column=0, row=i+1) + + # -------------LOOP------------- # while 1: if acu.get(): deff.set(0) @@ -75,13 +140,17 @@ def __init__(self): drollbox.configure(state='normal') try: final.configure(text=getdmg(int(atq.get()), int(aroll.get()), int(dmg.get()), - int(deff.get()), int(droll.get()), int(ta.get()), acu.get(), int(numdef.get()[0]))) + int(deff.get()), int(droll.get()), int(ta.get()), + acu.get(), int(numdef.get()[0]), getmodat(atqmodvars, atqmodhalfs), + getmoddef(defmodvars))) except ValueError: final.configure(text='No pasa nada') self.raiz.update_idletasks() self.raiz.update() + + def main(): window = App() return 0 diff --git a/modif.py b/modif.py index e69de29..747a8d2 100644 --- a/modif.py +++ b/modif.py @@ -0,0 +1,17 @@ +modifatk = {'A la defensiva': -30, 'A la ofensiva': 10, 'Adversario diminuto': -20, 'Adversario pequeño': -10, + 'Amenazado': -20, 'Ataque total': 30, 'Cargando': 10, 'Ceguera completa': -100, 'Ceguera parcial': -30, + 'Derribado': -30, 'Desenfundado': -30, 'Dolor': -40, 'Dolor extremo': -80, 'Espacio reducido': -40, + 'Espalda': -30, 'Flanco': -10, 'Levitando': -20, 'Miedo': -60, u'Parálisis completa': -200, + u'Parálisis menor': -20, u'Parálisis parcial': -80, u'Posición superior': 20, 'Vuelo 7-14': 10, + 'Vuelo 15+': 10} + +modifdef = {'A la defensiva': 10, 'A la ofensiva': -30, u'Adversario diminuto(Parada)': -10, "Aguantar el golpe": -80, + "Amenazado": -100, u'Ataque en área(Esquiva)': -80, u'Ataque en área(Parada)': -120, + 'Cargando(Esquiva)': -20, 'Cargando(Parada)': -10, 'Ceguera absoluta': -80, 'Ceguera Parcial(Esquiva)': -10, + 'Ceguera Parcial(Parada)': -30, 'Defensa Total': 30, 'Derribado': -30, 'Desenfundado': -20, 'Dolor': -40, + 'Dolor Extremo': -80, 'Espacio Reducido': -20, 'Espalda': -80, 'Flanco': -30, 'Levitando(Esquiva)': -40, + 'Levitando(Parada)': -20, 'Miedo': -60, u'Parálisis completa': -200, u'Parál. Menor(Esquiva)': -40, + u'Parál. Menor(Parada)': -20, u'Parálisis Parcial': -80, 'Proyectil Disparado(Esquiva)': -30, + 'Proyectil Disparado(Parada)': -80, u'Proyectil Disparado(Maestría Parada)': -20, + 'Proyectil Disparado(Escudo)': -20, 'Proyectil Lanzado(Parada)': -50, 'Sorpresa': -90, 'Vuelo 7-14': 10, + 'Vuelo 15+(Esquiva)': 20, 'Vuelo 15+(Parada)': 10}