Skip to content

Commit

Permalink
Added ability modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
AdoenLunnae committed Oct 13, 2018
1 parent af4d869 commit 2498307
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 16 deletions.
29 changes: 23 additions & 6 deletions func.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand All @@ -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


85 changes: 77 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)
Expand All @@ -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)

Expand All @@ -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)
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions modif.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@
'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}


0 comments on commit 2498307

Please sign in to comment.