|
|
@@ -82,8 +82,12 @@ class PanelOptimizer(wx.Panel):
|
|
|
Called at process end, rediresct to the result view.
|
|
|
minStatChangeBySlider(event)
|
|
|
Changes text when a slider is changed.
|
|
|
- minStatChangeByTExt(event)
|
|
|
+ minStatChangeByText(event)
|
|
|
Changes the slider when the text is changed.
|
|
|
+ adaptStats(event)
|
|
|
+ Sets all stats requeriments to the unit current values.
|
|
|
+ resetsStats(event)
|
|
|
+ Sets all stats requeriments to the unit base values.
|
|
|
|
|
|
"""
|
|
|
|
|
|
@@ -344,59 +348,70 @@ class PanelOptimizer(wx.Panel):
|
|
|
)
|
|
|
self.minStatTextList = [
|
|
|
wx.TextCtrl(
|
|
|
- minStatBox, id=wx.ID_ANY, value="", pos=(155, 0), size=(65, 25),
|
|
|
+ parent=minStatBox, id=wx.ID_ANY, value="",
|
|
|
+ pos=(155, 0), size=(65, 25), name="tx0",
|
|
|
style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB
|
|
|
),
|
|
|
wx.TextCtrl(
|
|
|
- minStatBox, id=wx.ID_ANY, value="", pos=(155, 25), size=(65, 25),
|
|
|
+ parent=minStatBox, id=wx.ID_ANY, value="",
|
|
|
+ pos=(155, 25), size=(65, 25), name="tx1",
|
|
|
style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB
|
|
|
),
|
|
|
wx.TextCtrl(
|
|
|
- minStatBox, id=wx.ID_ANY, value="", pos=(155, 50), size=(65, 25),
|
|
|
+ parent=minStatBox, id=wx.ID_ANY, value="",
|
|
|
+ pos=(155, 50), size=(65, 25), name="tx2",
|
|
|
style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB
|
|
|
),
|
|
|
wx.TextCtrl(
|
|
|
- minStatBox, id=wx.ID_ANY, value="", pos=(155, 75), size=(65, 25),
|
|
|
+ parent=minStatBox, id=wx.ID_ANY, value="",
|
|
|
+ pos=(155, 75), size=(65, 25), name="tx3",
|
|
|
style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB
|
|
|
),
|
|
|
wx.TextCtrl(
|
|
|
- minStatBox, id=wx.ID_ANY, value="", pos=(155, 100), size=(65, 25),
|
|
|
+ parent=minStatBox, id=wx.ID_ANY, value="",
|
|
|
+ pos=(155, 100), size=(65, 25), name="tx4",
|
|
|
style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB
|
|
|
),
|
|
|
wx.TextCtrl(
|
|
|
- minStatBox, id=wx.ID_ANY, value="", pos=(155, 125), size=(65, 25),
|
|
|
+ parent=minStatBox, id=wx.ID_ANY, value="",
|
|
|
+ pos=(155, 125), size=(65, 25), name="tx5",
|
|
|
style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB
|
|
|
),
|
|
|
wx.TextCtrl(
|
|
|
- minStatBox, id=wx.ID_ANY, value="", pos=(155, 150), size=(65, 25),
|
|
|
+ parent=minStatBox, id=wx.ID_ANY, value="",
|
|
|
+ pos=(155, 150), size=(65, 25), name="tx6",
|
|
|
style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB
|
|
|
),
|
|
|
wx.TextCtrl(
|
|
|
- minStatBox, id=wx.ID_ANY, value="", pos=(155, 175), size=(65, 25),
|
|
|
+ parent=minStatBox, id=wx.ID_ANY, value="",
|
|
|
+ pos=(155, 175), size=(65, 25), name="tx7",
|
|
|
style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB
|
|
|
),
|
|
|
wx.TextCtrl(
|
|
|
- minStatBox, id=wx.ID_ANY, value="", pos=(155, 200), size=(65, 25),
|
|
|
+ parent=minStatBox, id=wx.ID_ANY, value="",
|
|
|
+ pos=(155, 200), size=(65, 25), name="tx8",
|
|
|
style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB
|
|
|
),
|
|
|
wx.TextCtrl(
|
|
|
- minStatBox, id=wx.ID_ANY, value="", pos=(155, 225), size=(65, 25),
|
|
|
+ parent=minStatBox, id=wx.ID_ANY, value="",
|
|
|
+ pos=(155, 225), size=(65, 25), name="tx9",
|
|
|
style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB
|
|
|
)
|
|
|
]
|
|
|
for i in range(0, 9):
|
|
|
self.Bind(
|
|
|
- wx.EVT_TEXT_ENTER,
|
|
|
+ wx.EVT_TEXT,
|
|
|
self.minStatChangeByText, self.minStatTextList[i]
|
|
|
)
|
|
|
minStatsReset = wx.Button(
|
|
|
parent=minStatBox, id=wx.ID_ANY, pos=(10, 250),
|
|
|
size=(100, 20), style=wx.LC_REPORT, label="Reset all"
|
|
|
)
|
|
|
+ self.Bind(wx.EVT_BUTTON, self.resetStats, minStatsReset)
|
|
|
minStatsAdapt = wx.Button(
|
|
|
parent=minStatBox, id=wx.ID_ANY, pos=(120, 250),
|
|
|
size=(100, 20), style=wx.LC_REPORT, label="Adapt all")
|
|
|
- # TODO: Add binds
|
|
|
+ self.Bind(wx.EVT_BUTTON, self.adaptStats, minStatsAdapt)
|
|
|
self.optionsSizer.Add(minStatBox)
|
|
|
|
|
|
# Allowed main stats for even slots
|
|
|
@@ -592,7 +607,7 @@ class PanelOptimizer(wx.Panel):
|
|
|
""")
|
|
|
row = cursor.fetchone()
|
|
|
# First, set sliders max values
|
|
|
- self.minStatSlidList[0].SetMax(50000) #HP
|
|
|
+ self.minStatSlidList[0].SetMax(100000) #HP
|
|
|
self.minStatSlidList[1].SetMax(5000) #ATK
|
|
|
self.minStatSlidList[2].SetMax(5000) #DEF
|
|
|
self.minStatSlidList[3].SetMax(500) #SPD
|
|
|
@@ -600,7 +615,7 @@ class PanelOptimizer(wx.Panel):
|
|
|
self.minStatSlidList[5].SetMax(500) #CRD
|
|
|
self.minStatSlidList[6].SetMax(100) #RES
|
|
|
self.minStatSlidList[7].SetMax(85) #ACC
|
|
|
- self.minStatSlidList[8].SetMax(250000) #EHP
|
|
|
+ self.minStatSlidList[8].SetMax(500000) #EHP
|
|
|
self.minStatSlidList[9].SetMax(8000) #DMG
|
|
|
self.unitInfoBox.SetLabel(row[17] + " #" + row[16])
|
|
|
for i in range(0, 8):
|
|
|
@@ -642,21 +657,21 @@ class PanelOptimizer(wx.Panel):
|
|
|
baseCrr = 100
|
|
|
baseDmg = math.ceil(
|
|
|
(baseAtk * (100 - baseCrr) / 100) +
|
|
|
- ((baseAtk + (baseAtk * baseCrd / 100)) * baseCrr / 100)
|
|
|
+ (baseAtk * ( baseCrr / 100) * baseCrd / 100)
|
|
|
)
|
|
|
self.statGrid.SetCellValue(row=9, col=0, s=str(baseDmg))
|
|
|
self.minStatSlidList[9].SetMin(baseDmg)
|
|
|
currentAtk = int(self.statGrid.GetCellValue(row=1, col=1))
|
|
|
currentCrr = \
|
|
|
- int(self.statGrid.GetCellValue(row=4, col=0).replace("%", ""))
|
|
|
+ int(self.statGrid.GetCellValue(row=4, col=1).replace("%", ""))
|
|
|
currentCrd = \
|
|
|
int(self.statGrid.GetCellValue(row=5, col=1).replace("%", ""))
|
|
|
if (currentCrr > 100):
|
|
|
# Dont use crit rate over 100
|
|
|
currentCrr = 100
|
|
|
currentDmg = math.ceil(
|
|
|
- (currentAtk * (100 - currentCrr) / 100) +
|
|
|
- ((currentAtk + (currentAtk * currentCrd / 100)) * currentCrr / 100)
|
|
|
+ (currentAtk * (100 - currentCrr) / 100) + # Non-crit
|
|
|
+ (currentAtk * ( currentCrr / 100) * currentCrd / 100) # Crit
|
|
|
)
|
|
|
self.statGrid.SetCellValue(row=9, col=1, s=str(currentDmg))
|
|
|
self.minStatSlidList[9].SetValue(currentDmg)
|
|
|
@@ -713,6 +728,7 @@ class PanelOptimizer(wx.Panel):
|
|
|
# Try to infer data to set the default options, reset the rest
|
|
|
# Except the team list, rune level and storage: never reset those.
|
|
|
self.statCheckListList[0].SetCheckedItems(())
|
|
|
+ self.statCheckListList[1].SetCheckedItems(())
|
|
|
for i in range(0, 3):
|
|
|
if currEvenStats[i] == 1: # HP
|
|
|
self.statCheckListList[0].Check(0, True)
|
|
|
@@ -741,10 +757,7 @@ class PanelOptimizer(wx.Panel):
|
|
|
for i in range(0, 23):
|
|
|
if j < 3:
|
|
|
# If a set of 2 has 4 or 2:
|
|
|
- if i in [
|
|
|
- 1, 2, 4, 6, 7, 9, 12, 13, 14, 15,
|
|
|
- 16, 17, 18, 19, 20, 21, 22, 23
|
|
|
- ]:
|
|
|
+ if i in [1, 2, 4, 6, 7, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]:
|
|
|
if currSets[i] >= 4:
|
|
|
currSetList[j] = i - 1
|
|
|
currSetList[j + 1] = i - 1
|
|
|
@@ -786,7 +799,8 @@ class PanelOptimizer(wx.Panel):
|
|
|
# Example call:
|
|
|
# ../RuneOptimizer optimize 7223811472 -l 15
|
|
|
#-e rage,blade --stats atk,crr,crd -h 10000 -f 10
|
|
|
- command = executable_path + " optimize "
|
|
|
+ # TODO: Executable name for windows.
|
|
|
+ command = "RuneOptimizer optimize "
|
|
|
unitId = self.unitId
|
|
|
command += unitId
|
|
|
level = self.levelChoice.GetSelection()
|
|
|
@@ -797,9 +811,8 @@ class PanelOptimizer(wx.Panel):
|
|
|
else:
|
|
|
level = "current"
|
|
|
command += (" --level " + level)
|
|
|
- #print(" Rune level: " + level)
|
|
|
sets = ""
|
|
|
- for i in range (0, 2):
|
|
|
+ for i in range (0, 3):
|
|
|
selected = self.setChoiceList[i].GetString(
|
|
|
self.setChoiceList[i].GetSelection()
|
|
|
).upper().replace(" ", "");
|
|
|
@@ -845,8 +858,6 @@ class PanelOptimizer(wx.Panel):
|
|
|
stats = stats[:-1]
|
|
|
# TODO: ELSE ERROR
|
|
|
command += (" --stats " + stats)
|
|
|
- #print(" Main stats: " + stats)
|
|
|
-
|
|
|
command += (" --min-hp " + str(self.minStatSlidList[0].GetValue()))
|
|
|
command += (" --min-atk " + str(self.minStatSlidList[1].GetValue()))
|
|
|
command += (" --min-def " + str(self.minStatSlidList[2].GetValue()))
|
|
|
@@ -938,10 +949,6 @@ class PanelOptimizer(wx.Panel):
|
|
|
|
|
|
jsonText = text
|
|
|
|
|
|
- print('Finished. Result:\n' + jsonText)
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
# DEBUG: Sample data.
|
|
|
#self.unitId = "7223811472"
|
|
|
#json = ""{"result_count":5000,"results":[
|
|
|
@@ -950,7 +957,7 @@ class PanelOptimizer(wx.Panel):
|
|
|
# {"id":2,"rating":185,"hp":17730,"atk":2521,"dfc":862,"spd":147,"crr":60,"crd":164,"res":28,"acc":15,"ehp":73704,"dmg":5002,"runes":["21564691276","22920616295","27654723287","25633344349","26207902579","22348038576"]},
|
|
|
# {"id":3,"rating":179,"hp":15810,"atk":2431,"dfc":1011,"spd":137,"crr":61,"crd":160,"res":27,"acc":15,"ehp":73968,"dmg":4804,"runes":["21564691276","22920616295","27444728625","22750814840","26670411873","22348038576"]},
|
|
|
# {"id":4,"rating":176,"hp":15319,"atk":2530,"dfc":909,"spd":142,"crr":60,"crd":165,"res":28,"acc":15,"ehp":66202,"dmg":5035,"runes":["21564691276","16759622995","27654723287","22750814840","26207902579","22348038576"]}]}
|
|
|
- #"""
|
|
|
+ #
|
|
|
|
|
|
print ("---- RESULT OUTPUT -------------------------------------------")
|
|
|
print(jsonText)
|
|
|
@@ -979,7 +986,7 @@ class PanelOptimizer(wx.Panel):
|
|
|
caption="Error"
|
|
|
)
|
|
|
|
|
|
- def minStatChangeBySlider(self, event):
|
|
|
+ def minStatChangeBySlider(self, event=None):
|
|
|
"""Changes text when a slider is changed.
|
|
|
|
|
|
Doesn't do validation.
|
|
|
@@ -990,13 +997,12 @@ class PanelOptimizer(wx.Panel):
|
|
|
The event that triggered the call (default is None).
|
|
|
|
|
|
"""
|
|
|
-
|
|
|
slidId = int(event.GetEventObject().GetName().replace("slid", ""))
|
|
|
self.minStatTextList[slidId].SetValue(
|
|
|
str(event.GetEventObject().GetValue())
|
|
|
)
|
|
|
|
|
|
- def minStatChangeByText(self, event):
|
|
|
+ def minStatChangeByText(self, event=None):
|
|
|
"""Changes the slider when the text is changed.
|
|
|
|
|
|
Validates the text value.
|
|
|
@@ -1008,17 +1014,49 @@ class PanelOptimizer(wx.Panel):
|
|
|
|
|
|
"""
|
|
|
textId = int(event.GetEventObject().GetName().replace("tx", ""))
|
|
|
- if event.GetEventObject().GetValue().isdigit() == False:
|
|
|
+ if event.GetEventObject().GetValue().isdigit() == False and \
|
|
|
+ event.GetEventObject().GetValue() != "":
|
|
|
event.GetEventObject().SetValue(
|
|
|
str(self.minStatSlidList[textId].GetValue())
|
|
|
)
|
|
|
- value = int(event.GetEventObject().GetValue())
|
|
|
minValue = self.minStatSlidList[textId].GetMin()
|
|
|
maxValue = self.minStatSlidList[textId].GetMax()
|
|
|
- if value < minValue:
|
|
|
+ if event.GetEventObject().GetValue().isdigit():
|
|
|
+ value = int(event.GetEventObject().GetValue())
|
|
|
+ else:
|
|
|
value = minValue
|
|
|
- event.GetEventObject().SetValue(str(value))
|
|
|
- elif value > maxValue:
|
|
|
- value = maxValue
|
|
|
- event.GetEventObject().SetValue(str(value))
|
|
|
+ # Unbind scroll event of the slider, set value and rebind.
|
|
|
+ self.Unbind(wx.EVT_SCROLL, self.minStatSlidList[textId])
|
|
|
self.minStatSlidList[textId].SetValue(value)
|
|
|
+ self.Bind(
|
|
|
+ wx.EVT_SCROLL,
|
|
|
+ self.minStatChangeBySlider, self.minStatSlidList[textId]
|
|
|
+ )
|
|
|
+
|
|
|
+ def adaptStats(self, event=None):
|
|
|
+ """Sets all stats requeriments to the unit current values.
|
|
|
+
|
|
|
+ Parameters
|
|
|
+ ----------
|
|
|
+ event : wxEvent, optional
|
|
|
+ The event that triggered the call (default is None).
|
|
|
+
|
|
|
+ """
|
|
|
+ for i in range(0, 10):
|
|
|
+ self.minStatSlidList[i].SetValue(self.unitStats[i])
|
|
|
+ self.minStatTextList[i].SetValue(str(self.unitStats[i]))
|
|
|
+
|
|
|
+ def resetStats(self, event=None):
|
|
|
+ """Sets all stats requeriments to the unit base values.
|
|
|
+
|
|
|
+ Parameters
|
|
|
+ ----------
|
|
|
+ event : wxEvent, optional
|
|
|
+ The event that triggered the call (default is None).
|
|
|
+
|
|
|
+ """
|
|
|
+ for i in range(0, 10):
|
|
|
+ self.minStatSlidList[i].SetValue(self.minStatSlidList[i].GetMin())
|
|
|
+ self.minStatTextList[i].SetValue(
|
|
|
+ str(self.minStatSlidList[i].GetMin())
|
|
|
+ )
|