|
|
@@ -1,8 +1,6 @@
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
"""
|
|
|
-RuneOptimizer GUI.
|
|
|
-
|
|
|
This file is part of RuneOptimizer.
|
|
|
|
|
|
RuneOptimizer is free software: you can redistribute it and/or modify it
|
|
|
@@ -28,6 +26,9 @@ import subprocess
|
|
|
import json
|
|
|
from types import SimpleNamespace
|
|
|
|
|
|
+exec(compile(source=open('frames/RuneOptimizerFrame.py').read(), filename='frames/RuneOptimizerFrame.py', mode='exec'))
|
|
|
+exec(compile(source=open('frames/ResultsFrame.py').read(), filename='frames/ResultsFrame.py', mode='exec'))
|
|
|
+
|
|
|
conn = None
|
|
|
|
|
|
stat_names = [
|
|
|
@@ -41,1487 +42,10 @@ set_names = [
|
|
|
"FIGHT", "DETERMINATION", "ENHANCE", "ACCURACY", "TOLERANCE"
|
|
|
]
|
|
|
|
|
|
-class ResultsFrame(wx.Frame):
|
|
|
- """
|
|
|
- The frame uset to see and check results.
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- unitId : str
|
|
|
- ID of the unit being optimized (default "").
|
|
|
- unitName : str
|
|
|
- Name of the unit being optimized (default "").
|
|
|
- data : Python Object
|
|
|
- Results from RuneOptimizer (default None).
|
|
|
- currentStats : int[10]
|
|
|
- The current stats of the unit being optimized. (default is
|
|
|
- [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).
|
|
|
- page : int
|
|
|
- Currently displayed page, 0-index (default 0).
|
|
|
- totalPages : int
|
|
|
- Number of pages of results (default 0).
|
|
|
- linesPerPage : int
|
|
|
- Number of results to show per page (default 10).
|
|
|
- pgPrevBt : wx.Button
|
|
|
- Button to go to the previous page.
|
|
|
- pgPrevBt : wx.Button
|
|
|
- Button to go to the previous page.
|
|
|
- resultsPageIndicator : wx.StaticText
|
|
|
- Label to indicate the current and maximum pages.
|
|
|
- resultGrid : wx.Grid.grid
|
|
|
- Table of results.
|
|
|
- resultContent : wx.BoxSizer
|
|
|
- Holds every widget that is hidden until a result is selected.
|
|
|
- statGrid : wx.Grid.grid
|
|
|
- Table to show the new stats with the selected result.
|
|
|
- runeIds : wx.StaticText[6]
|
|
|
- Labels with the IDs of the runes in the current result.
|
|
|
- runeLocations : wx.StaticText[6]
|
|
|
- Labels with the locations of the runes in the current result.
|
|
|
- runeSets : wx.StaticText[6]
|
|
|
- Labels with the set names of the runes in the current result.
|
|
|
- runeMains : wx.StaticText[6]
|
|
|
- Labels with the main stats of the runes in the current result.
|
|
|
- runeInnates : wx.StaticText[6]
|
|
|
- Labels with the innates of the runes in the current result.
|
|
|
- runeStats : wx.StaticText[6][4]
|
|
|
- Labels with the stats of the runes in the current result.
|
|
|
- selectedResultndex : int
|
|
|
- Selected result index (default -1).
|
|
|
-
|
|
|
- Methods
|
|
|
- -------
|
|
|
- processResults(jsonData)
|
|
|
- Processes data obtained from RuneOptimizer.
|
|
|
- pgPrev(event)
|
|
|
- Goes to the previous result page.
|
|
|
- pgNext(event)
|
|
|
- Goes to the next result page.
|
|
|
- closeWindow(event)
|
|
|
- Closes the frame.
|
|
|
- applyRunes(event)
|
|
|
- Applies the runes in the currently selected result.
|
|
|
- printResults()
|
|
|
- Populates the results table with the results in the currently
|
|
|
- selected page.
|
|
|
- resultSelected(event)
|
|
|
- Populates and shows the runes and effective stats with the
|
|
|
- currently seleced result.
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- unitId = ""
|
|
|
- unitName = ""
|
|
|
- data = None
|
|
|
- currentStats = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
|
- page = 0
|
|
|
- totalPages = 0
|
|
|
- linesPerPage = 10
|
|
|
- pgPrevBt = None
|
|
|
- pgNextBt = None
|
|
|
- resultsPageIndicator = None
|
|
|
- resultGrid = None
|
|
|
- resultContent = None
|
|
|
- statGrid = None
|
|
|
- runeIds = None
|
|
|
- runeLocations = None
|
|
|
- runeSets = None
|
|
|
- runeMains = None
|
|
|
- runeInnates = None
|
|
|
- runeStats = None
|
|
|
- selectedResultIndex = -1
|
|
|
-
|
|
|
- def __init__(self, *args, **kw):
|
|
|
- """Initializes the class.
|
|
|
-
|
|
|
- Sets upt all the widgets.
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- global conn
|
|
|
- # ensure the parent's __init__ is called
|
|
|
- super(ResultsFrame, self).__init__(*args, **kw)
|
|
|
-
|
|
|
- # create a panel in the frame
|
|
|
- pnl = wx.Panel(self)
|
|
|
-
|
|
|
- self.resultGrid = wx.grid.Grid(parent=pnl, id=-1, pos=(50, 30), size=(544, 220))
|
|
|
- self.resultGrid.CreateGrid(numRows=10, numCols=11, selmode=wx.grid.Grid.GridSelectionModes.SelectRows)
|
|
|
- self.resultGrid.EnableEditing(False)
|
|
|
- self.resultGrid.SetDefaultCellAlignment(horiz=wx.ALIGN_RIGHT, vert=wx.ALIGN_CENTRE)
|
|
|
- monospaceFont = wx.Font(10, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
|
|
|
- self.resultGrid.SetDefaultCellFont(monospaceFont)
|
|
|
- self.resultGrid.SetRowLabelSize(width=35)
|
|
|
- self.resultGrid.SetColLabelValue(col=0, value="Rating")
|
|
|
- self.resultGrid.SetColSize(col=0, width=50)
|
|
|
- self.resultGrid.SetColLabelValue(col=1, value="HP")
|
|
|
- self.resultGrid.SetColSize(col=1, width=50)
|
|
|
- self.resultGrid.SetColLabelValue(col=2, value="ATK")
|
|
|
- self.resultGrid.SetColSize(col=2, width=40)
|
|
|
- self.resultGrid.SetColLabelValue(col=3, value="DEF")
|
|
|
- self.resultGrid.SetColSize(col=3, width=40)
|
|
|
- self.resultGrid.SetColLabelValue(col=4, value="SPD")
|
|
|
- self.resultGrid.SetColSize(col=4, width=40)
|
|
|
- self.resultGrid.SetColLabelValue(col=5, value="CRR")
|
|
|
- self.resultGrid.SetColSize(col=5, width=40)
|
|
|
- self.resultGrid.SetColLabelValue(col=6, value="CRD")
|
|
|
- self.resultGrid.SetColSize(col=6, width=40)
|
|
|
- self.resultGrid.SetColLabelValue(col=7, value="RES")
|
|
|
- self.resultGrid.SetColSize(col=7, width=40)
|
|
|
- self.resultGrid.SetColLabelValue(col=8, value="ACC")
|
|
|
- self.resultGrid.SetColSize(col=8, width=40)
|
|
|
- self.resultGrid.SetColLabelValue(col=9, value="EHP")
|
|
|
- self.resultGrid.SetColSize(col=9, width=60)
|
|
|
- self.resultGrid.SetColLabelValue(col=10, value="DMG")
|
|
|
- self.resultGrid.SetColSize(col=10, width=50)
|
|
|
- self.resultGrid.SetColLabelSize(height=20)
|
|
|
- self.resultGrid.SetDefaultRowSize(height=20)
|
|
|
- self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.resultSelected, self.resultGrid)
|
|
|
-
|
|
|
- # Paginator
|
|
|
- self.pgPrevBt = wx.Button(parent=pnl, id=-1, pos=(580, 30), size=(40, 50), style=wx.LC_REPORT, label="Prev\npage")
|
|
|
- self.resultsPageIndicator = wx.StaticText(parent=pnl, label="1/1",id=-1, pos=(580, 80), size=(40, 15), style=wx.ALIGN_CENTRE_HORIZONTAL)
|
|
|
- self.pgNextBt = wx.Button(parent=pnl, id=-1, pos=(580, 100), size=(40, 50), style=wx.LC_REPORT, label="Next\npage")
|
|
|
- self.Bind(wx.EVT_BUTTON, self.pgPrev, self.pgPrevBt)
|
|
|
- self.Bind(wx.EVT_BUTTON, self.pgNext, self.pgNextBt)
|
|
|
-
|
|
|
- self.resultContent = wx.BoxSizer(wx.VERTICAL)
|
|
|
-
|
|
|
- # Stats table
|
|
|
- self.statGrid = wx.grid.Grid(parent=pnl, id=-1, pos=(650, 30), size=(205, 220), style=wx.LC_REPORT)
|
|
|
- self.statGrid.CreateGrid(numRows=10, numCols=2, selmode=wx.grid.Grid.GridSelectionModes.SelectRowsOrColumns)
|
|
|
- self.statGrid.EnableEditing(False)
|
|
|
- self.statGrid.SetDefaultCellAlignment(horiz=wx.ALIGN_RIGHT, vert=wx.ALIGN_CENTRE)
|
|
|
- monospaceFont = wx.Font(10, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
|
|
|
- self.statGrid.SetDefaultCellFont(monospaceFont)
|
|
|
- self.statGrid.SetColSize(col=0, width=70)
|
|
|
- self.statGrid.SetColLabelValue(col=0, value="Value")
|
|
|
- self.statGrid.SetColLabelValue(col=1, value="Diff")
|
|
|
- self.statGrid.SetRowLabelSize(width=35)
|
|
|
- self.statGrid.SetColLabelSize(height=20)
|
|
|
- self.statGrid.SetRowSize(row=0, height=20)
|
|
|
- self.statGrid.SetRowSize(row=1, height=20)
|
|
|
- self.statGrid.SetRowSize(row=2, height=20)
|
|
|
- self.statGrid.SetRowSize(row=3, height=20)
|
|
|
- self.statGrid.SetRowSize(row=4, height=20)
|
|
|
- self.statGrid.SetRowSize(row=5, height=20)
|
|
|
- self.statGrid.SetRowSize(row=6, height=20)
|
|
|
- self.statGrid.SetRowSize(row=7, height=20)
|
|
|
- self.statGrid.SetRowSize(row=8, height=20)
|
|
|
- self.statGrid.SetRowSize(row=9, height=20)
|
|
|
- self.statGrid.SetRowLabelValue(row=0, value=" HP")
|
|
|
- self.statGrid.SetRowLabelValue(row=1, value="ATK")
|
|
|
- self.statGrid.SetRowLabelValue(row=2, value="DEF")
|
|
|
- self.statGrid.SetRowLabelValue(row=3, value="SPD")
|
|
|
- self.statGrid.SetRowLabelValue(row=4, value="CRR")
|
|
|
- self.statGrid.SetRowLabelValue(row=5, value="CRD")
|
|
|
- self.statGrid.SetRowLabelValue(row=6, value="RES")
|
|
|
- self.statGrid.SetRowLabelValue(row=7, value="ACC")
|
|
|
- self.statGrid.SetRowLabelValue(row=8, value="EHP")
|
|
|
- self.statGrid.SetRowLabelValue(row=9, value="DMG")
|
|
|
- self.resultContent.Add(self.statGrid)
|
|
|
-
|
|
|
- monospaceFont = wx.Font(10, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
|
|
|
- monospaceFont.PointSize -= 2
|
|
|
- monospaceFontBold = wx.Font(10, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)
|
|
|
- monospaceFontBold.PointSize -= 2
|
|
|
- monospaceFontItalic = wx.Font(10, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_ITALIC, wx.FONTWEIGHT_NORMAL)
|
|
|
- monospaceFontItalic.PointSize -= 2
|
|
|
-
|
|
|
- #Rune set list
|
|
|
- runeListBox = [
|
|
|
- wx.StaticBox(parent=pnl, label="Slot1:",id=-1, pos=(200, 255), size=(140, 160)),
|
|
|
- wx.StaticBox(parent=pnl, label="Slot2:",id=-1, pos=(350, 255), size=(140, 160)),
|
|
|
- wx.StaticBox(parent=pnl, label="Slot3:",id=-1, pos=(350, 420), size=(140, 160)),
|
|
|
- wx.StaticBox(parent=pnl, label="Slot4:",id=-1, pos=(200, 420), size=(140, 160)),
|
|
|
- wx.StaticBox(parent=pnl, label="Slot5:",id=-1, pos=(50, 420), size=(140, 160)),
|
|
|
- wx.StaticBox(parent=pnl, label="Slot6:",id=-1, pos=(50, 255), size=(140, 160)),
|
|
|
- ]
|
|
|
- for i in range(0, 6):
|
|
|
- runeListBox[i].SetFont(monospaceFont)
|
|
|
- self.resultContent.Add(runeListBox[i])
|
|
|
-
|
|
|
- self.runeIds = [
|
|
|
- wx.StaticText(runeListBox[0], label="",id=-1, pos=(5, 0), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[1], label="",id=-1, pos=(5, 0), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[2], label="",id=-1, pos=(5, 0), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[3], label="",id=-1, pos=(5, 0), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[4], label="",id=-1, pos=(5, 0), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[5], label="",id=-1, pos=(5, 0), size=(120, 10)),
|
|
|
- ]
|
|
|
-
|
|
|
- self.runeLocations = [
|
|
|
- wx.StaticText(runeListBox[0], label="",id=-1, pos=(5, 15), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[1], label="",id=-1, pos=(5, 15), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[2], label="",id=-1, pos=(5, 15), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[3], label="",id=-1, pos=(5, 15), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[4], label="",id=-1, pos=(5, 15), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[5], label="",id=-1, pos=(5, 15), size=(120, 10)),
|
|
|
- ]
|
|
|
-
|
|
|
- self.runeSets = [
|
|
|
- wx.StaticText(runeListBox[0], label="",id=-1, pos=(5, 30), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[1], label="",id=-1, pos=(5, 30), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[2], label="",id=-1, pos=(5, 30), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[3], label="",id=-1, pos=(5, 30), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[4], label="",id=-1, pos=(5, 30), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[5], label="",id=-1, pos=(5, 30), size=(120, 10)),
|
|
|
- ]
|
|
|
-
|
|
|
- wx.StaticLine(parent=runeListBox[0], id=-1, pos=(5, 45), size=(130, 1), style=wx.LC_REPORT)
|
|
|
- wx.StaticLine(parent=runeListBox[1], id=-1, pos=(5, 45), size=(130, 1), style=wx.LC_REPORT)
|
|
|
- wx.StaticLine(parent=runeListBox[2], id=-1, pos=(5, 45), size=(130, 1), style=wx.LC_REPORT)
|
|
|
- wx.StaticLine(parent=runeListBox[3], id=-1, pos=(5, 45), size=(130, 1), style=wx.LC_REPORT)
|
|
|
- wx.StaticLine(parent=runeListBox[4], id=-1, pos=(5, 45), size=(130, 1), style=wx.LC_REPORT)
|
|
|
- wx.StaticLine(parent=runeListBox[5], id=-1, pos=(5, 45), size=(130, 1), style=wx.LC_REPORT)
|
|
|
-
|
|
|
- self.runeMains = [
|
|
|
- wx.StaticText(runeListBox[0], label="",id=-1, pos=(5, 50), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[1], label="",id=-1, pos=(5, 50), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[2], label="",id=-1, pos=(5, 50), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[3], label="",id=-1, pos=(5, 50), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[4], label="",id=-1, pos=(5, 50), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[5], label="",id=-1, pos=(5, 50), size=(120, 10)),
|
|
|
- ]
|
|
|
- for i in range(0, 6):
|
|
|
- self.runeMains[i].SetFont(monospaceFontBold)
|
|
|
-
|
|
|
- self.runeInnates = [
|
|
|
- wx.StaticText(runeListBox[0], label="",id=-1, pos=(5, 65), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[1], label="",id=-1, pos=(5, 65), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[2], label="",id=-1, pos=(5, 65), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[3], label="",id=-1, pos=(5, 65), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[4], label="",id=-1, pos=(5, 65), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[5], label="",id=-1, pos=(5, 65), size=(120, 10)),
|
|
|
- ]
|
|
|
- for i in range(0, 6):
|
|
|
- self.runeInnates[i].SetFont(monospaceFontItalic)
|
|
|
-
|
|
|
- self.runeStats = [
|
|
|
- [
|
|
|
- wx.StaticText(runeListBox[0], label="",id=-1, pos=(5, 80), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[0], label="",id=-1, pos=(5, 95), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[0], label="",id=-1, pos=(5, 110), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[0], label="",id=-1, pos=(5, 125), size=(120, 10))
|
|
|
- ],
|
|
|
- [
|
|
|
- wx.StaticText(runeListBox[1], label="",id=-1, pos=(5, 80), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[1], label="",id=-1, pos=(5, 95), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[1], label="",id=-1, pos=(5, 110), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[1], label="",id=-1, pos=(5, 125), size=(120, 10))
|
|
|
- ],
|
|
|
- [
|
|
|
- wx.StaticText(runeListBox[2], label="",id=-1, pos=(5, 80), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[2], label="",id=-1, pos=(5, 95), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[2], label="",id=-1, pos=(5, 110), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[2], label="",id=-1, pos=(5, 125), size=(120, 10))
|
|
|
- ],
|
|
|
- [
|
|
|
- wx.StaticText(runeListBox[3], label="",id=-1, pos=(5, 80), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[3], label="",id=-1, pos=(5, 95), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[3], label="",id=-1, pos=(5, 110), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[3], label="",id=-1, pos=(5, 125), size=(120, 10))
|
|
|
- ],
|
|
|
- [
|
|
|
- wx.StaticText(runeListBox[4], label="",id=-1, pos=(5, 80), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[4], label="",id=-1, pos=(5, 95), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[4], label="",id=-1, pos=(5, 110), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[4], label="",id=-1, pos=(5, 125), size=(120, 10))
|
|
|
- ],
|
|
|
- [
|
|
|
- wx.StaticText(runeListBox[5], label="",id=-1, pos=(5, 80), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[5], label="",id=-1, pos=(5, 95), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[5], label="",id=-1, pos=(5, 110), size=(120, 10)),
|
|
|
- wx.StaticText(runeListBox[5], label="",id=-1, pos=(5, 125), size=(120, 10))
|
|
|
- ],
|
|
|
- ]
|
|
|
-
|
|
|
- # Action buttons
|
|
|
- applyBt = wx.Button(parent=pnl, id=-1, pos=(650, 330), size=(165, 60), style=wx.LC_REPORT, label="Apply runes")
|
|
|
- self.Bind(wx.EVT_BUTTON, self.applyRunes, applyBt)
|
|
|
- self.resultContent.Add(applyBt)
|
|
|
- closeBt = wx.Button(parent=pnl, id=-1, pos=(650, 430), size=(165, 60), style=wx.LC_REPORT, label="Close")
|
|
|
- self.Bind(wx.EVT_BUTTON, self.closeWindow, closeBt)
|
|
|
-
|
|
|
- # By default, hide everything
|
|
|
- self.resultContent.ShowItems(False)
|
|
|
-
|
|
|
- def processResults(self, jsonData):
|
|
|
- """Processes data obtained from RuneOptimizer.
|
|
|
-
|
|
|
- Reads the JSON data and initializes the property data.
|
|
|
- Automatically calls printResults();
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- jsonData : str
|
|
|
- The data, as received from RuneOptimizer.
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- self.data = json.loads(jsonData, object_hook=lambda d: SimpleNamespace(**d))
|
|
|
- self.totalPages = math.ceil(len(self.data.results) / self.linesPerPage)
|
|
|
- self.printResults()
|
|
|
-
|
|
|
- def pgPrev(self, event):
|
|
|
- """Goes to the previous page of results.
|
|
|
-
|
|
|
- Checks if there is a previous page to go to. If so, it
|
|
|
- automatically calls printResults();
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- event : wxEvent, optional
|
|
|
- The event that triggered the call (default is None).
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- if self.page > 0:
|
|
|
- self.page -= 1
|
|
|
- self.printResults()
|
|
|
-
|
|
|
- def pgNext(self, event):
|
|
|
- """Goes to the next page of results.
|
|
|
-
|
|
|
- Checks if there is a next page to go to. If so, it
|
|
|
- automatically calls printResults();
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- event : wxEvent, optional
|
|
|
- The event that triggered the call (default is None).
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- if self.page < self.totalPages:
|
|
|
- self.page += 1
|
|
|
- self.printResults()
|
|
|
-
|
|
|
- def closeWindow(self, event):
|
|
|
- """Closes the window.
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- event : wxEvent, optional
|
|
|
- The event that triggered the call (default is None).
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- self.Close(True)
|
|
|
-
|
|
|
- def applyRunes(self, event):
|
|
|
- """Applies the selected results and saves data to the database.
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- event : wxEvent, optional
|
|
|
- The event that triggered the call (default is None).
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- global conn
|
|
|
-
|
|
|
- if (self.selectedResultIndex < 0):
|
|
|
- # TODO: Show error
|
|
|
- return;
|
|
|
- print("self.selectedResultIndex: " + str(self.selectedResultIndex))
|
|
|
- for i in range(0, 6):
|
|
|
- print(self.data.results[self.selectedResultIndex].runes[i])
|
|
|
- # First, unassign all runes currently assigned to the unit
|
|
|
- cursor = conn.execute(
|
|
|
- """
|
|
|
- UPDATE runes SET unit = null
|
|
|
- WHERE unit = ?
|
|
|
- """,
|
|
|
- (
|
|
|
- self.unitId,
|
|
|
- )
|
|
|
- )
|
|
|
-
|
|
|
- # Next, mark units as modified
|
|
|
- cursor = conn.execute(
|
|
|
- """
|
|
|
- UPDATE units SET modified = 1
|
|
|
- WHERE id = ? OR id IN (SELECT unit FROM runes WHERE id IN (?, ?, ?, ?, ?, ?))
|
|
|
- """,
|
|
|
- (
|
|
|
- self.unitId,
|
|
|
- self.data.results[self.selectedResultIndex].runes[0],
|
|
|
- self.data.results[self.selectedResultIndex].runes[1],
|
|
|
- self.data.results[self.selectedResultIndex].runes[2],
|
|
|
- self.data.results[self.selectedResultIndex].runes[3],
|
|
|
- self.data.results[self.selectedResultIndex].runes[4],
|
|
|
- self.data.results[self.selectedResultIndex].runes[5]
|
|
|
- )
|
|
|
- )
|
|
|
-
|
|
|
- # Lastly, assign the runes
|
|
|
- cursor = conn.execute(
|
|
|
- """
|
|
|
- UPDATE runes SET unit = ?
|
|
|
- WHERE id IN (?, ?, ?, ?, ?, ?)
|
|
|
- """,
|
|
|
- (
|
|
|
- self.unitId,
|
|
|
- self.data.results[self.selectedResultIndex].runes[0],
|
|
|
- self.data.results[self.selectedResultIndex].runes[1],
|
|
|
- self.data.results[self.selectedResultIndex].runes[2],
|
|
|
- self.data.results[self.selectedResultIndex].runes[3],
|
|
|
- self.data.results[self.selectedResultIndex].runes[4],
|
|
|
- self.data.results[self.selectedResultIndex].runes[5]
|
|
|
- )
|
|
|
- )
|
|
|
- conn.commit()
|
|
|
- # TODO: Recalculate all modified units stats from the database
|
|
|
- print("Applied!")
|
|
|
- recalculteStatsOfModifiedUnits()
|
|
|
- print("All recalculated!")
|
|
|
-
|
|
|
- # Fetch the new values for self.currentStats
|
|
|
- cursor = conn.execute(
|
|
|
- """
|
|
|
- SELECT
|
|
|
- current_hp,
|
|
|
- current_atk,
|
|
|
- current_def,
|
|
|
- current_spd,
|
|
|
- current_crr,
|
|
|
- current_crd,
|
|
|
- current_res,
|
|
|
- current_acc
|
|
|
- FROM units
|
|
|
- WHERE id = ?
|
|
|
- """,
|
|
|
- (
|
|
|
- self.unitId,
|
|
|
- )
|
|
|
- )
|
|
|
- row = cursor.fetchone()
|
|
|
- for i in range(0, 8):
|
|
|
- self.currentStats[i] = int(row[i])
|
|
|
- self.currentStats[9] = math.ceil((((self.currentStats[2] * 3.5) + 1140) * self.currentStats[0]) / 1000)
|
|
|
- self.currentStats[10] = math.ceil((self.currentStats[1] * (100 - self.currentStats[4]) / 100) + ((self.currentStats[1] + (self.currentStats[1] * self.currentStats[5] / 100)) * self.currentStats[4] / 100));
|
|
|
- self.resultSelected(None)
|
|
|
-
|
|
|
- def printResults(self):
|
|
|
- """Populates the results table with the results in the
|
|
|
- currently selected page.
|
|
|
-
|
|
|
- It doesn't change the selcted result. Automaticcaly called
|
|
|
- after changing pages or processing data.
|
|
|
- """
|
|
|
-
|
|
|
- self.pgPrevBt.Enable(True)
|
|
|
- self.pgNextBt.Enable(True)
|
|
|
- if self.totalPages == 1:
|
|
|
- self.pgPrevBt.Enable(False)
|
|
|
- self.pgNextBt.Enable(False)
|
|
|
- elif self.page == 0:
|
|
|
- self.pgPrevBt.Enable(False)
|
|
|
- elif self.page + 1 == self.totalPages:
|
|
|
- self.pgNextBt.Enable(False)
|
|
|
- self.resultsPageIndicator.SetLabel(str(self.page + 1) + "/" + str(self.totalPages))
|
|
|
- #for result in self.data.results:
|
|
|
- for i in range(0, 10):
|
|
|
- rindex = i + (self.linesPerPage * self.page)
|
|
|
- if (len(self.data.results) > rindex):
|
|
|
- self.resultGrid.SetRowLabelValue(row=i, value=str(rindex + 1))
|
|
|
- result = self.data.results[rindex]
|
|
|
- self.resultGrid.SetCellValue(row=i, col=0, s=str(result.rating))
|
|
|
- self.resultGrid.SetCellValue(row=i, col=1, s=str(result.hp))
|
|
|
- self.resultGrid.SetCellValue(row=i, col=2, s=str(result.atk))
|
|
|
- self.resultGrid.SetCellValue(row=i, col=3, s=str(result.dfc))
|
|
|
- self.resultGrid.SetCellValue(row=i, col=4, s=str(result.spd))
|
|
|
- self.resultGrid.SetCellValue(row=i, col=5, s=str(result.crr))
|
|
|
- self.resultGrid.SetCellValue(row=i, col=6, s=str(result.crd))
|
|
|
- self.resultGrid.SetCellValue(row=i, col=7, s=str(result.res))
|
|
|
- self.resultGrid.SetCellValue(row=i, col=8, s=str(result.acc))
|
|
|
- self.resultGrid.SetCellValue(row=i, col=9, s=str(result.ehp))
|
|
|
- self.resultGrid.SetCellValue(row=i, col=10, s=str(result.dmg))
|
|
|
- else:
|
|
|
- self.resultGrid.SetRowLabelValue(row=i, value="")
|
|
|
- for j in range(0, 11):
|
|
|
- self.resultGrid.SetCellValue(row=i, col=j, s="")
|
|
|
-
|
|
|
- def resultSelected(self, event):
|
|
|
- """Populates and shows the runes and effective stats with the
|
|
|
- currently seleced result.
|
|
|
-
|
|
|
- It also enables the apply button.
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- event : wxEvent, optional
|
|
|
- The event that triggered the call (default is None).
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- selectedLine = self.resultGrid.GetSelectedRows()[0]
|
|
|
- self.selectedResultIndex = selectedLine + (self.linesPerPage * self.page)
|
|
|
- self.statGrid.SetCellValue(row=0, col=0, s=str(self.data.results[self.selectedResultIndex].hp) + " ")
|
|
|
- diff = self.data.results[self.selectedResultIndex].hp - self.currentStats[0]
|
|
|
- if (diff < 0):
|
|
|
- self.statGrid.SetCellValue(row=0, col=1, s="- " + str(abs(diff)) + " ")
|
|
|
- self.statGrid.SetCellTextColour(row=0, col=1, colour=wx.Colour(red=255, green=0, blue=0))
|
|
|
- elif (diff > 0):
|
|
|
- self.statGrid.SetCellValue(row=0, col=1, s="+ " + str(diff) + " ")
|
|
|
- self.statGrid.SetCellTextColour(row=0, col=1, colour=wx.Colour(red=0, green=255, blue=0))
|
|
|
- else:
|
|
|
- self.statGrid.SetCellValue(row=0, col=1, s="")
|
|
|
-
|
|
|
- self.statGrid.SetCellValue(row=1, col=0, s=str(self.data.results[self.selectedResultIndex].atk) + " ")
|
|
|
- diff = self.data.results[self.selectedResultIndex].atk - self.currentStats[1]
|
|
|
- if (diff < 0):
|
|
|
- self.statGrid.SetCellValue(row=1, col=1, s="- " + str(abs(diff)) + " ")
|
|
|
- self.statGrid.SetCellTextColour(row=1, col=1, colour=wx.Colour(red=255, green=0, blue=0))
|
|
|
- elif (diff > 0):
|
|
|
- self.statGrid.SetCellValue(row=1, col=1, s="+ " + str(diff) + " ")
|
|
|
- self.statGrid.SetCellTextColour(row=1, col=1, colour=wx.Colour(red=0, green=255, blue=0))
|
|
|
- else:
|
|
|
- self.statGrid.SetCellValue(row=1, col=1, s="")
|
|
|
-
|
|
|
- self.statGrid.SetCellValue(row=2, col=0, s=str(self.data.results[self.selectedResultIndex].dfc) + " ")
|
|
|
- diff = self.data.results[self.selectedResultIndex].atk - self.currentStats[2]
|
|
|
- if (diff < 0):
|
|
|
- self.statGrid.SetCellValue(row=2, col=1, s="- " + str(abs(diff)) + " ")
|
|
|
- self.statGrid.SetCellTextColour(row=1, col=1, colour=wx.Colour(red=255, green=0, blue=0))
|
|
|
- elif (diff > 0):
|
|
|
- self.statGrid.SetCellValue(row=2, col=1, s="+ " + str(diff) + " ")
|
|
|
- self.statGrid.SetCellTextColour(row=2, col=1, colour=wx.Colour(red=0, green=255, blue=0))
|
|
|
- else:
|
|
|
- self.statGrid.SetCellValue(row=2, col=1, s="")
|
|
|
-
|
|
|
- self.statGrid.SetCellValue(row=3, col=0, s=str(self.data.results[self.selectedResultIndex].spd) + " ")
|
|
|
- diff = self.data.results[self.selectedResultIndex].spd - self.currentStats[3]
|
|
|
- if (diff < 0):
|
|
|
- self.statGrid.SetCellValue(row=3, col=1, s="- " + str(abs(diff)) + " ")
|
|
|
- self.statGrid.SetCellTextColour(row=3, col=1, colour=wx.Colour(red=255, green=0, blue=0))
|
|
|
- elif (diff > 0):
|
|
|
- self.statGrid.SetCellValue(row=3, col=1, s="+ " + str(diff) + " ")
|
|
|
- self.statGrid.SetCellTextColour(row=3, col=1, colour=wx.Colour(red=0, green=255, blue=0))
|
|
|
- else:
|
|
|
- self.statGrid.SetCellValue(row=3, col=1, s="")
|
|
|
-
|
|
|
-
|
|
|
- self.statGrid.SetCellValue(row=4, col=0, s=str(self.data.results[self.selectedResultIndex].crr) + "%")
|
|
|
- diff = self.data.results[self.selectedResultIndex].crr - self.currentStats[4]
|
|
|
- if (diff < 0):
|
|
|
- self.statGrid.SetCellValue(row=4, col=1, s="- " + str(abs(diff)) + "%")
|
|
|
- self.statGrid.SetCellTextColour(row=4, col=1, colour=wx.Colour(red=255, green=0, blue=0))
|
|
|
- elif (diff > 0):
|
|
|
- self.statGrid.SetCellValue(row=4, col=1, s="+ " + str(diff) + "%")
|
|
|
- self.statGrid.SetCellTextColour(row=4, col=1, colour=wx.Colour(red=0, green=255, blue=0))
|
|
|
- else:
|
|
|
- self.statGrid.SetCellValue(row=4, col=1, s="")
|
|
|
-
|
|
|
- self.statGrid.SetCellValue(row=5, col=0, s=str(self.data.results[self.selectedResultIndex].crd) + "%")
|
|
|
- diff = self.data.results[self.selectedResultIndex].crd - self.currentStats[5]
|
|
|
- if (diff < 0):
|
|
|
- self.statGrid.SetCellValue(row=5, col=1, s="- " + str(abs(diff)) + "%")
|
|
|
- self.statGrid.SetCellTextColour(row=5, col=1, colour=wx.Colour(red=255, green=0, blue=0))
|
|
|
- elif (diff > 0):
|
|
|
- self.statGrid.SetCellValue(row=5, col=1, s="+ " + str(diff) + "%")
|
|
|
- self.statGrid.SetCellTextColour(row=5, col=1, colour=wx.Colour(red=0, green=255, blue=0))
|
|
|
- else:
|
|
|
- self.statGrid.SetCellValue(row=5, col=1, s="")
|
|
|
-
|
|
|
- self.statGrid.SetCellValue(row=6, col=0, s=str(self.data.results[self.selectedResultIndex].res) + "%")
|
|
|
- diff = self.data.results[self.selectedResultIndex].res - self.currentStats[6]
|
|
|
- if (diff < 0):
|
|
|
- self.statGrid.SetCellValue(row=6, col=1, s="- " + str(abs(diff)) + "%")
|
|
|
- self.statGrid.SetCellTextColour(row=6, col=1, colour=wx.Colour(red=255, green=0, blue=0))
|
|
|
- elif (diff > 0):
|
|
|
- self.statGrid.SetCellValue(row=6, col=1, s="+ " + str(diff) + "%")
|
|
|
- self.statGrid.SetCellTextColour(row=6, col=1, colour=wx.Colour(red=0, green=255, blue=0))
|
|
|
- else:
|
|
|
- self.statGrid.SetCellValue(row=6, col=1, s="")
|
|
|
-
|
|
|
- self.statGrid.SetCellValue(row=7, col=0, s=str(self.data.results[self.selectedResultIndex].acc) + "%")
|
|
|
- diff = self.data.results[self.selectedResultIndex].acc - self.currentStats[7]
|
|
|
- if (diff < 0):
|
|
|
- self.statGrid.SetCellValue(row=7, col=1, s="- " + str(abs(diff)) + "%")
|
|
|
- self.statGrid.SetCellTextColour(row=7, col=1, colour=wx.Colour(red=255, green=0, blue=0))
|
|
|
- elif (diff > 0):
|
|
|
- self.statGrid.SetCellValue(row=7, col=1, s="+ " + str(diff) + "%")
|
|
|
- self.statGrid.SetCellTextColour(row=7, col=1, colour=wx.Colour(red=0, green=255, blue=0))
|
|
|
- else:
|
|
|
- self.statGrid.SetCellValue(row=7, col=1, s="")
|
|
|
-
|
|
|
- self.statGrid.SetCellValue(row=8, col=0, s=str(self.data.results[self.selectedResultIndex].ehp) + " ")
|
|
|
- diff = self.data.results[self.selectedResultIndex].ehp - self.currentStats[8]
|
|
|
- if (diff < 0):
|
|
|
- self.statGrid.SetCellValue(row=8, col=1, s="- " + str(abs(diff)) + " ")
|
|
|
- self.statGrid.SetCellTextColour(row=8, col=1, colour=wx.Colour(red=255, green=0, blue=0))
|
|
|
- elif (diff > 0):
|
|
|
- self.statGrid.SetCellValue(row=8, col=1, s="+ " + str(diff) + " ")
|
|
|
- self.statGrid.SetCellTextColour(row=8, col=1, colour=wx.Colour(red=0, green=255, blue=0))
|
|
|
- else:
|
|
|
- self.statGrid.SetCellValue(row=8, col=1, s="")
|
|
|
-
|
|
|
- self.statGrid.SetCellValue(row=9, col=0, s=str(self.data.results[self.selectedResultIndex].dmg) + " ")
|
|
|
- diff = self.data.results[self.selectedResultIndex].dmg - self.currentStats[9]
|
|
|
- if (diff < 0):
|
|
|
- self.statGrid.SetCellValue(row=9, col=1, s="- " + str(abs(diff)) + " ")
|
|
|
- self.statGrid.SetCellTextColour(row=9, col=1, colour=wx.Colour(red=255, green=0, blue=0))
|
|
|
- elif (diff > 0):
|
|
|
- self.statGrid.SetCellValue(row=9, col=1, s="+ " + str(diff) + " ")
|
|
|
- self.statGrid.SetCellTextColour(row=9, col=1, colour=wx.Colour(red=0, green=255, blue=0))
|
|
|
- else:
|
|
|
- self.statGrid.SetCellValue(row=9, col=1, s="")
|
|
|
-
|
|
|
- self.resultContent.ShowItems(True)
|
|
|
-
|
|
|
- # Clean the runes
|
|
|
- for i in range(0, 5):
|
|
|
- self.runeIds[i].SetLabel("")
|
|
|
- self.runeLocations[i].SetLabel("")
|
|
|
- self.runeSets[i].SetLabel("")
|
|
|
- self.runeMains[i].SetLabel("")
|
|
|
- self.runeInnates[i].SetLabel("")
|
|
|
- for j in range(0, 3):
|
|
|
- self.runeStats[i][j].SetLabel("")
|
|
|
-
|
|
|
- # Display the runes
|
|
|
- cursor = conn.execute(
|
|
|
- """
|
|
|
- SELECT runes.id, runes.slot, runes.type, runes.level, units.id, units.name
|
|
|
- FROM runes LEFT JOIN units ON runes.unit = units.id
|
|
|
- WHERE runes.id IN (?, ?, ?, ?, ?, ?)
|
|
|
- ORDER BY runes.slot;
|
|
|
- """,
|
|
|
- (
|
|
|
- self.data.results[self.selectedResultIndex].runes[0],
|
|
|
- self.data.results[self.selectedResultIndex].runes[1],
|
|
|
- self.data.results[self.selectedResultIndex].runes[2],
|
|
|
- self.data.results[self.selectedResultIndex].runes[3],
|
|
|
- self.data.results[self.selectedResultIndex].runes[4],
|
|
|
- self.data.results[self.selectedResultIndex].runes[5]
|
|
|
- )
|
|
|
- )
|
|
|
- i = 0
|
|
|
- for row in cursor:
|
|
|
- # Rows are 21 charactes width
|
|
|
- self.runeIds[i].SetLabel(("#" + str(row[0])).rjust(21, " "))
|
|
|
- if row[4] == None:
|
|
|
- self.runeLocations[i].SetLabel("Storage")
|
|
|
- else:
|
|
|
- self.runeLocations[i].SetLabel(str(row[5])[0:9].ljust(9, " ") + " #" + str(row[4]) + "")
|
|
|
- self.runeSets[i].SetLabel(set_names[row[2]].ljust(18, " ") + "+" + str(row[3]))
|
|
|
- #print(self.data.results[self.selectedResultIndex].runes[i])
|
|
|
- cursorStats = conn.execute(
|
|
|
- """
|
|
|
- SELECT
|
|
|
- slot, stat, value, grind, enchant
|
|
|
- FROM rune_stats
|
|
|
- WHERE
|
|
|
- rune = ?
|
|
|
- ORDER BY slot;
|
|
|
- """,
|
|
|
- (self.data.results[self.selectedResultIndex].runes[i],)
|
|
|
- )
|
|
|
- for rowStats in cursorStats:
|
|
|
- slot = rowStats[0]
|
|
|
- if rowStats[4] == 1: # if enchanted
|
|
|
- name = (stat_names[rowStats[1]].replace("%", "").replace(" ", "") + " * ").rjust(8, " ")
|
|
|
- else:
|
|
|
- name = (stat_names[rowStats[1]].replace("%", "").replace(" ", "") + " ").rjust(8, " ")
|
|
|
- value = str(rowStats[2])
|
|
|
- if rowStats[1] in [2, 4, 6, 9, 10, 11, 23]:
|
|
|
- value = value + "%"
|
|
|
- else:
|
|
|
- value = value + " "
|
|
|
- value = value.rjust(5)
|
|
|
- if rowStats[3] > 0: # if grinded
|
|
|
- value = value + " + " + str(rowStats[3])
|
|
|
- if rowStats[1] in [2, 4, 6, 9, 10, 11, 23]:
|
|
|
- value = value + "%"
|
|
|
- line = name + value
|
|
|
- if slot == -1: # main
|
|
|
- self.runeMains[i].SetLabel(line)
|
|
|
- elif slot == 0: # innate
|
|
|
- self.runeInnates[i].SetLabel(line)
|
|
|
- else: # normal stats
|
|
|
- self.runeStats[i][slot - 1].SetLabel(line)
|
|
|
- i += 1
|
|
|
-
|
|
|
-
|
|
|
-class RuneOptimizerFrame(wx.Frame):
|
|
|
- """
|
|
|
- The main application window.
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- unitList : wx.ListCtrl
|
|
|
- Selectable unit list with priorities.
|
|
|
- unitContent : wx.BoxSizer
|
|
|
- Holds every widget that is hidden until a unit is selected.
|
|
|
- unitName : wx.StaticText
|
|
|
- Label with the unit name.
|
|
|
- statGrid : wx.Grid.grid
|
|
|
- Table with the unit base and current stats.
|
|
|
- runeList : wx.StaticText[6]
|
|
|
- Labels with all the info about the currently equipped runes.
|
|
|
- minStatSlider : wx.Slider[6]
|
|
|
- List of sliders for the minimum selectors for each stat.
|
|
|
- minStatText : wx.StaticText[6]
|
|
|
- List of text inputs for the minimum selectors for each stat.
|
|
|
- runeSets : wx.Choice[3]
|
|
|
- List of selector to pik rune sets.
|
|
|
- stats : wx.CheckListBox[2]
|
|
|
- Tho selctors to choose stats allowed in optimization.
|
|
|
- level : wx.Choice
|
|
|
- Selector to pick the level for the rune optimization.
|
|
|
- currentStats : int[10]
|
|
|
- The current stats of the unit being optimized. (default is
|
|
|
- [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]).
|
|
|
- filterName : wx.TextCtrl
|
|
|
- Text input to filter units names.
|
|
|
- filterNames : wx.CheckBox
|
|
|
- Checkbox to include or exclude units in storage.
|
|
|
- filterNoRunes : wx.CheckBox
|
|
|
- Checkbox to include or exclude units without runes.
|
|
|
- filterNoTeams : wx.CheckBox
|
|
|
- Checkbox to include or exclude units in no teams.
|
|
|
-
|
|
|
- Methods
|
|
|
- -------
|
|
|
- processResults(jsonData)
|
|
|
- Processes data obtained from RuneOptimizer.
|
|
|
- populateUnitList(event)
|
|
|
- Populates the unit list.
|
|
|
- startOptimization(event)
|
|
|
- Prepares and runs a command optimization.
|
|
|
- minStatChangeBySlider(event)
|
|
|
- Changes text when a slider is changed.
|
|
|
- minStatChangeByTExt(event)
|
|
|
- Changes the slider when the text is changed.
|
|
|
- unitSelected(event)
|
|
|
- Loads a unit info and enables optimizaton options.
|
|
|
- makeMenuBar(event)
|
|
|
- Creates the app menu bar.
|
|
|
- closeApp(event)
|
|
|
- Closes the app.
|
|
|
- showAbout(event)
|
|
|
- Display an About dialog.
|
|
|
- updateFromJson(event)
|
|
|
- Updates data from a JSON file.
|
|
|
- updateFromSwdb(event)
|
|
|
- Updates data from a JSON file.
|
|
|
- updateFromSwarfarm(event)
|
|
|
- Updates data from a JSON file.
|
|
|
- updateFromSqlite(event)
|
|
|
- Updates data from a JSON file.
|
|
|
- showUnimplemented(parent, event)
|
|
|
- Displays a message for unimplemented features.
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- unitList = None
|
|
|
- unitContent = None
|
|
|
- unitName = None
|
|
|
- statGrid = None
|
|
|
- runeList = None
|
|
|
- minStatSlid = None
|
|
|
- minStatText = None
|
|
|
- runeSets = None
|
|
|
- stats = None
|
|
|
- level = None
|
|
|
- currentStats = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
|
- filterName = None
|
|
|
- filterStorage = None
|
|
|
- filterNoRunes = None
|
|
|
- filterNoTeams = None
|
|
|
-
|
|
|
- def __init__(self, *args, **kw):
|
|
|
- """Initializes the class.
|
|
|
-
|
|
|
- Sets upt all the widgets.
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- global conn
|
|
|
- super(RuneOptimizerFrame, self).__init__(*args, **kw)
|
|
|
-
|
|
|
- # Create and configure a
|
|
|
- pnl = wx.Panel(self)
|
|
|
- self.makeMenuBar()
|
|
|
- self.CreateStatusBar()
|
|
|
- self.SetStatusText("Status: Updated, no pending changes")
|
|
|
-
|
|
|
- # Show unit list
|
|
|
- wx.StaticText(parent=pnl, id=-1, label="Name Prio. Sto.", pos=(10, 10), size=(190, 20))
|
|
|
- self.unitList = wx.ListCtrl(parent=pnl, id=-1, pos=(10, 30), size=(190, 490), style=wx.LC_REPORT|wx.LC_NO_HEADER)
|
|
|
- self.unitList.InsertColumn(0, "Name", width=120)
|
|
|
- self.unitList.InsertColumn(1, "Prio.", width=40)
|
|
|
- self.unitList.InsertColumn(2, "Sto.", width=30)
|
|
|
-
|
|
|
- self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.unitSelected, self.unitList)
|
|
|
-
|
|
|
- # List filters
|
|
|
- filterBox = wx.StaticBox(pnl, label="Filters:",id=-1, pos=(10, 520), size=(190, 150))
|
|
|
- wx.StaticText(parent=filterBox, label="Monster name", pos=(5, 5), size=(180, 20))
|
|
|
- self.filterName = wx.TextCtrl(parent=filterBox, id=-1, value="", pos=(5, 25), size=(177, 20), style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB, name="tx0")
|
|
|
- self.Bind(wx.EVT_TEXT_ENTER, self.populateUnitList, self.filterName)
|
|
|
- self.filterStorage = wx.CheckBox(parent=filterBox, id=-1, label="Monsters in storage", pos=(5, 55), size=(180, 20))
|
|
|
- self.filterStorage.SetValue(True)
|
|
|
- self.Bind(wx.EVT_CHECKBOX, self.populateUnitList, self.filterStorage)
|
|
|
- self.filterNoRunes = wx.CheckBox(parent=filterBox, id=-1, label="Monsters without runes", pos=(5, 75), size=(180, 20))
|
|
|
- self.filterNoRunes.SetValue(True)
|
|
|
- self.Bind(wx.EVT_CHECKBOX, self.populateUnitList, self.filterNoRunes)
|
|
|
- self.filterNoTeams = wx.CheckBox(parent=filterBox, id=-1, label="Monsters not in teams", pos=(5, 95), size=(180, 20))
|
|
|
- self.filterNoTeams.SetValue(True)
|
|
|
- self.Bind(wx.EVT_CHECKBOX, self.populateUnitList, self.filterNoTeams)
|
|
|
-
|
|
|
- self.populateUnitList(None)
|
|
|
-
|
|
|
- # Begin with unit-specifica content
|
|
|
- self.unitContent = wx.BoxSizer(wx.VERTICAL)
|
|
|
-
|
|
|
- # Unit name
|
|
|
- self.unitName = wx.StaticText(pnl, label="", pos=(210, 0), size=(200, 20))
|
|
|
- font = self.unitName.GetFont()
|
|
|
- font.PointSize += 2
|
|
|
- font = font.Bold()
|
|
|
- self.unitName.SetFont(font)
|
|
|
- self.unitContent.Add(self.unitName)
|
|
|
-
|
|
|
- # Stats table
|
|
|
- self.statGrid = wx.grid.Grid(parent=pnl, id=-1, pos=(210, 30), size=(165, 220))
|
|
|
- self.statGrid.CreateGrid(numRows=10, numCols=2, selmode=wx.grid.Grid.GridSelectionModes.SelectRowsOrColumns)
|
|
|
- self.statGrid.EnableEditing(False)
|
|
|
- self.statGrid.SetDefaultCellAlignment(horiz=wx.ALIGN_RIGHT, vert=wx.ALIGN_CENTRE)
|
|
|
- monospaceFont = wx.Font(10, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
|
|
|
- self.statGrid.SetDefaultCellFont(monospaceFont)
|
|
|
- self.statGrid.SetColSize(col=0, width=50)
|
|
|
- self.statGrid.SetColLabelValue(col=0, value="Base")
|
|
|
- self.statGrid.SetColSize(col=0, width=50)
|
|
|
- self.statGrid.SetColLabelValue(col=1, value="Current")
|
|
|
- self.statGrid.SetRowLabelSize(width=35)
|
|
|
- self.statGrid.SetColLabelSize(height=20)
|
|
|
- self.statGrid.SetRowSize(row=0, height=20)
|
|
|
- self.statGrid.SetRowSize(row=1, height=20)
|
|
|
- self.statGrid.SetRowSize(row=2, height=20)
|
|
|
- self.statGrid.SetRowSize(row=3, height=20)
|
|
|
- self.statGrid.SetRowSize(row=4, height=20)
|
|
|
- self.statGrid.SetRowSize(row=5, height=20)
|
|
|
- self.statGrid.SetRowSize(row=6, height=20)
|
|
|
- self.statGrid.SetRowSize(row=7, height=20)
|
|
|
- self.statGrid.SetRowSize(row=8, height=20)
|
|
|
- self.statGrid.SetRowSize(row=9, height=20)
|
|
|
- self.statGrid.SetRowLabelValue(row=0, value=" HP")
|
|
|
- self.statGrid.SetRowLabelValue(row=1, value="ATK")
|
|
|
- self.statGrid.SetRowLabelValue(row=2, value="DEF")
|
|
|
- self.statGrid.SetRowLabelValue(row=3, value="SPD")
|
|
|
- self.statGrid.SetRowLabelValue(row=4, value="CRR")
|
|
|
- self.statGrid.SetRowLabelValue(row=5, value="CRD")
|
|
|
- self.statGrid.SetRowLabelValue(row=6, value="RES")
|
|
|
- self.statGrid.SetRowLabelValue(row=7, value="ACC")
|
|
|
- self.statGrid.SetRowLabelValue(row=8, value="EHP")
|
|
|
- self.statGrid.SetRowLabelValue(row=9, value="DMG")
|
|
|
- self.unitContent.Add(self.statGrid)
|
|
|
-
|
|
|
- #Rune set list
|
|
|
- runeListBox = [
|
|
|
- wx.StaticBox(pnl, label="Slot1:",id=-1, pos=(465, 30), size=(80, 115)),
|
|
|
- wx.StaticBox(pnl, label="Slot2:",id=-1, pos=(550, 30), size=(80, 115)),
|
|
|
- wx.StaticBox(pnl, label="Slot3:",id=-1, pos=(550, 150), size=(80, 115)),
|
|
|
- wx.StaticBox(pnl, label="Slot4:",id=-1, pos=(465, 150), size=(80, 115)),
|
|
|
- wx.StaticBox(pnl, label="Slot5:",id=-1, pos=(380, 150), size=(80, 115)),
|
|
|
- wx.StaticBox(pnl, label="Slot6:",id=-1, pos=(380, 30), size=(80, 115)),
|
|
|
- ]
|
|
|
- self.runeList = [
|
|
|
- wx.StaticText(runeListBox[0], label="",id=-1, pos=(0, 0), size=(80, 115)),
|
|
|
- wx.StaticText(runeListBox[1], label="",id=-1, pos=(0, 0), size=(80, 115)),
|
|
|
- wx.StaticText(runeListBox[2], label="",id=-1, pos=(0, 0), size=(80, 115)),
|
|
|
- wx.StaticText(runeListBox[3], label="",id=-1, pos=(0, 0), size=(80, 115)),
|
|
|
- wx.StaticText(runeListBox[4], label="",id=-1, pos=(0, 0), size=(80, 115)),
|
|
|
- wx.StaticText(runeListBox[5], label="",id=-1, pos=(0, 0), size=(80, 115)),
|
|
|
- ]
|
|
|
- monospaceFont.PointSize -= 2
|
|
|
- for i in range(0, 6):
|
|
|
- runeListBox[i].SetFont(monospaceFont)
|
|
|
- self.unitContent.Add(runeListBox[i])
|
|
|
- monospaceFont.PointSize += 2
|
|
|
-
|
|
|
- # Create an update button:
|
|
|
- #btUpdate = wx.Button(parent=pnl, id=-1, label="Update data", pos=(10,10), size=(100,40))
|
|
|
- #btOptimize = wx.Button(parent=pnl, id=-1, label="Optimize unit", pos=(10,60), size=(100,40))
|
|
|
-
|
|
|
- # Line to separate optimization parameters
|
|
|
- optimizationSeparator = wx.StaticLine(parent=pnl, id=-1, pos=(210, 290), size=(650, 3), style=wx.LC_REPORT)
|
|
|
- self.unitContent.Add(optimizationSeparator)
|
|
|
-
|
|
|
- # Min stats
|
|
|
- minStatBox = wx.StaticBox(pnl, label="Min. stats:",id=-1, pos=(220, 300), size=(260, 380))
|
|
|
- wx.StaticText(minStatBox, label="HP",id=-1, pos=(0, 5), size=(30, 25))
|
|
|
- wx.StaticText(minStatBox, label="ATK",id=-1, pos=(0, 35), size=(30, 25))
|
|
|
- wx.StaticText(minStatBox, label="DEF",id=-1, pos=(0, 65), size=(30, 25))
|
|
|
- wx.StaticText(minStatBox, label="SPD",id=-1, pos=(0, 95), size=(30, 25))
|
|
|
- wx.StaticText(minStatBox, label="CRR",id=-1, pos=(0, 125), size=(30, 25))
|
|
|
- wx.StaticText(minStatBox, label="CRD",id=-1, pos=(0, 155), size=(30, 25))
|
|
|
- wx.StaticText(minStatBox, label="RES",id=-1, pos=(0, 185), size=(30, 25))
|
|
|
- wx.StaticText(minStatBox, label="ACC",id=-1, pos=(0, 215), size=(30, 25))
|
|
|
- wx.StaticText(minStatBox, label="EHP",id=-1, pos=(0, 245), size=(30, 25))
|
|
|
- wx.StaticText(minStatBox, label="DMG",id=-1, pos=(0, 275), size=(30, 25))
|
|
|
- self.minStatSlid = [
|
|
|
- wx.Slider(minStatBox, id=-1, pos=(30, 0), size=(150, 30), name="slid0"),
|
|
|
- wx.Slider(minStatBox, id=-1, pos=(30, 30), size=(150, 30), name="slid1"),
|
|
|
- wx.Slider(minStatBox, id=-1, pos=(30, 60), size=(150, 30), name="slid2"),
|
|
|
- wx.Slider(minStatBox, id=-1, pos=(30, 90), size=(150, 30), name="slid3"),
|
|
|
- wx.Slider(minStatBox, id=-1, pos=(30, 120), size=(150, 30), name="slid4"),
|
|
|
- wx.Slider(minStatBox, id=-1, pos=(30, 150), size=(150, 30), name="slid5"),
|
|
|
- wx.Slider(minStatBox, id=-1, pos=(30, 180), size=(150, 30), name="slid6"),
|
|
|
- wx.Slider(minStatBox, id=-1, pos=(30, 210), size=(150, 30), name="slid7"),
|
|
|
- wx.Slider(minStatBox, id=-1, pos=(30, 240), size=(150, 30), name="slid8"),
|
|
|
- wx.Slider(minStatBox, id=-1, pos=(30, 270), size=(150, 30), name="slid9")
|
|
|
- ]
|
|
|
- for i in range(0, 9):
|
|
|
- self.minStatSlid[i].SetMin(0)
|
|
|
- self.minStatSlid[i].SetMax(0)
|
|
|
- self.minStatSlid[i].SetValue(0)
|
|
|
- self.Bind(wx.EVT_SCROLL, self.minStatChangeBySlider, self.minStatSlid[i])
|
|
|
- self.minStatText = [
|
|
|
- wx.TextCtrl(minStatBox, id=-1, value="", pos=(185, 0), size=(65, 25), style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB, name="tx0"),
|
|
|
- wx.TextCtrl(minStatBox, id=-1, value="", pos=(185, 30), size=(65, 25), style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB, name="tx1"),
|
|
|
- wx.TextCtrl(minStatBox, id=-1, value="", pos=(185, 60), size=(65, 25), style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB, name="tx2"),
|
|
|
- wx.TextCtrl(minStatBox, id=-1, value="", pos=(185, 90), size=(65, 25), style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB, name="tx3"),
|
|
|
- wx.TextCtrl(minStatBox, id=-1, value="", pos=(185, 120), size=(65, 25), style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB, name="tx4"),
|
|
|
- wx.TextCtrl(minStatBox, id=-1, value="", pos=(185, 150), size=(65, 25), style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB, name="tx5"),
|
|
|
- wx.TextCtrl(minStatBox, id=-1, value="", pos=(185, 180), size=(65, 25), style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB, name="tx6"),
|
|
|
- wx.TextCtrl(minStatBox, id=-1, value="", pos=(185, 210), size=(65, 25), style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB, name="tx7"),
|
|
|
- wx.TextCtrl(minStatBox, id=-1, value="", pos=(185, 240), size=(65, 25), style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB, name="tx8"),
|
|
|
- wx.TextCtrl(minStatBox, id=-1, value="", pos=(185, 270), size=(65, 25), style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB, name="tx9")
|
|
|
- ]
|
|
|
- for i in range(0, 9):
|
|
|
- self.Bind(wx.EVT_TEXT_ENTER, self.minStatChangeByText, self.minStatText[i])
|
|
|
- minStatsReset = wx.Button(parent=minStatBox, id=-1, pos=(10, 300), size=(100, 40), style=wx.LC_REPORT, label="Reset all")
|
|
|
- minStatsAdapt = wx.Button(parent=minStatBox, id=-1, pos=(120, 300), size=(100, 40), style=wx.LC_REPORT, label="Adapt all")
|
|
|
- # TODO: Add binds
|
|
|
- self.unitContent.Add(minStatBox)
|
|
|
-
|
|
|
- # Rune sets
|
|
|
- names = [
|
|
|
- "", "ENERGY ", "GUARD ", "SWIFT ", "BLADE ", "RAGE ",
|
|
|
- "FOCUS ", "ENDURE ", "FATAL ", "DESPAIR", "VAMPIRE", "VIOLENT",
|
|
|
- "NEMESIS", "WILL ", "SHIELD ", "REVENGE", "DESTROY", "FIGHT ",
|
|
|
- "DETERMI", "ENHANCE", "ACCURAC", "TOLERAN"
|
|
|
- ]
|
|
|
- setBox = wx.StaticBox(pnl, label="Rune Sets:",id=-1, pos=(500, 300), size=(330, 65))
|
|
|
- self.runeSets = [
|
|
|
- wx.Choice(parent=setBox, id=-1, pos=(5, 0), choices=names),
|
|
|
- wx.Choice(parent=setBox, id=-1, pos=(110, 0), choices=names),
|
|
|
- wx.Choice(parent=setBox, id=-1, pos=(215, 0), choices=names)
|
|
|
- ]
|
|
|
- self.unitContent.Add(setBox)
|
|
|
-
|
|
|
- # Allowed main stats for even slots
|
|
|
- names = [
|
|
|
- ["HP ", "HP% ", "ATK ", "ATK%", "DEF ", "DEF%"],
|
|
|
- ["SPD ", "CRR ", "CRD ", "RES ", "ACC "]
|
|
|
- ]
|
|
|
- statBox = wx.StaticBox(pnl, label="Main stats (2, 4, 6):",id=-1, pos=(500, 380), size=(150, 190))
|
|
|
- self.stats = [
|
|
|
- wx.CheckListBox(parent=statBox, id=-1, pos=(5, 5), size=(70, 155), choices=names[0]),
|
|
|
- wx.CheckListBox(parent=statBox, id=-1, pos=(70, 5), size=(70, 155), choices=names[1])
|
|
|
- ]
|
|
|
- self.unitContent.Add(statBox)
|
|
|
-
|
|
|
- levelBox = wx.StaticBox(pnl, label="Rune Level:",id=-1, pos=(700, 380), size=(100, 65))
|
|
|
- self.level = wx.Choice(parent=levelBox, id=-1, pos=(5, 0), choices=["Current", "+ 12", " + 15"])
|
|
|
- self.unitContent.Add(levelBox)
|
|
|
-
|
|
|
- # Button to start
|
|
|
- btOptimize = wx.Button(parent=pnl, id=-1, pos=(700, 480), size=(100, 40), style=wx.LC_REPORT, label="OPTIMIZE")
|
|
|
- self.unitContent.Add(btOptimize)
|
|
|
- self.Bind(wx.EVT_BUTTON, self.startOptimization, btOptimize)
|
|
|
-
|
|
|
-
|
|
|
- self.unitContent.ShowItems(False)
|
|
|
-
|
|
|
- def populateUnitList(self, event):
|
|
|
- """Populates the unit list.
|
|
|
-
|
|
|
- Uses the filters.
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- event : wxEvent, optional
|
|
|
- The event that triggered the call (default is None).
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- # Get units from db
|
|
|
- name = self.filterName.GetValue()
|
|
|
- query = """
|
|
|
- SELECT
|
|
|
- id,
|
|
|
- name,
|
|
|
- (
|
|
|
- SELECT cast(total(teams.priority) as int)
|
|
|
- FROM teams, units_teams
|
|
|
- WHERE teams.id = units_teams.team AND units_teams.unit = units.id
|
|
|
- ) as priority,
|
|
|
- storage
|
|
|
- FROM units
|
|
|
- WHERE
|
|
|
- name LIKE '%""" + name + """%'
|
|
|
- """
|
|
|
- if self.filterStorage.GetValue() == False:
|
|
|
- query += " AND storage = 0 "
|
|
|
- if self.filterNoRunes.GetValue() == False:
|
|
|
- query += " AND id IN (SELECT DISTINCT unit FROM runes) "
|
|
|
- if self.filterNoTeams.GetValue() == False:
|
|
|
- query += " AND id IN (SELECT DISTINCT unit FROM units_teams) "
|
|
|
- query += " ORDER BY priority DESC; ";
|
|
|
- print(query)
|
|
|
- cursor = conn.execute(query)
|
|
|
- i = 0
|
|
|
- self.unitList.DeleteAllItems()
|
|
|
- for row in cursor:
|
|
|
- self.unitList.InsertItem(i, row[1])
|
|
|
- self.unitList.SetItem(i, 1, str(row[2]))
|
|
|
- self.unitList.SetItem(i, 2, "")
|
|
|
- self.unitList.SetItemData(i, int(row[0]))
|
|
|
- if (int(row[3]) == 1):
|
|
|
- self.unitList.SetItem(i, 2, "X")
|
|
|
- else:
|
|
|
- self.unitList.SetItem(i, 2, " ")
|
|
|
- i = i + 1
|
|
|
-
|
|
|
- def startOptimization(self, event):
|
|
|
- """Prepares and runs a command optimization.
|
|
|
-
|
|
|
- Once is done, opens a ResultsFrame.
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- event : wxEvent, optional
|
|
|
- The event that triggered the call (default is None).
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- # Example call:
|
|
|
- # ../RuneOptimizer optimize 7223811472 -l 15 -e rage,blade --stats atk,crr,crd -h 10000 -f 10
|
|
|
- command = "RuneOptimizer optimize "
|
|
|
- #print("StartOptimization...")
|
|
|
- unitId = str(self.unitList.GetItemData(self.unitList.GetFirstSelected()))
|
|
|
- command += unitId
|
|
|
- #print(" Unit ID: " + unitId)
|
|
|
- level = self.level.GetSelection()
|
|
|
- if level == 1:
|
|
|
- level = "12"
|
|
|
- elif level == 2:
|
|
|
- level = "15"
|
|
|
- else:
|
|
|
- level = "current"
|
|
|
- command += (" --level " + level)
|
|
|
- #print(" Rune level: " + level)
|
|
|
- sets = ""
|
|
|
- for i in range (0, 2):
|
|
|
- selected = self.runeSets[i].GetString(self.runeSets[i].GetSelection()).upper().replace(" ", "");
|
|
|
- for j in range(0, 22):
|
|
|
- name = set_names[j].upper()
|
|
|
- if len(name) > 7:
|
|
|
- name = name[0:7]
|
|
|
- #print(selected + " - " + name)
|
|
|
- if selected == name:
|
|
|
- sets += set_names[j].lower() + ","
|
|
|
- if len(sets) > 0:
|
|
|
- sets = sets[:-1]
|
|
|
- # TODO: ELSE ERROR
|
|
|
- command += (" --sets " + sets)
|
|
|
- stats = ""
|
|
|
- selected_stats = self.stats[0].GetCheckedItems() + self.stats[1].GetCheckedItems()
|
|
|
- for s in self.stats[0].GetCheckedItems():
|
|
|
- if s == 0:
|
|
|
- stats += "hpflat,"
|
|
|
- elif s == 1:
|
|
|
- stats += "hp,"
|
|
|
- elif s == 2:
|
|
|
- stats += "atkflat,"
|
|
|
- elif s == 3:
|
|
|
- stats += "atk,"
|
|
|
- elif s == 4:
|
|
|
- stats += "defflat,"
|
|
|
- elif s == 5:
|
|
|
- stats += "def,"
|
|
|
- for s in self.stats[1].GetCheckedItems():
|
|
|
- if s == 0:
|
|
|
- stats += "spd,"
|
|
|
- elif s == 1:
|
|
|
- stats += "crr,"
|
|
|
- elif s == 2:
|
|
|
- stats += "crd,"
|
|
|
- elif s == 3:
|
|
|
- stats += "res,"
|
|
|
- elif s == 4:
|
|
|
- stats += "acc,"
|
|
|
- if len(stats) > 0:
|
|
|
- stats = stats[:-1]
|
|
|
- # TODO: ELSE ERROR
|
|
|
- command += (" --stats " + stats)
|
|
|
- #print(" Main stats: " + stats)
|
|
|
-
|
|
|
- command += (" --min-hp " + str(self.minStatSlid[0].GetValue()))
|
|
|
- command += (" --min-atk " + str(self.minStatSlid[1].GetValue()))
|
|
|
- command += (" --min-def " + str(self.minStatSlid[2].GetValue()))
|
|
|
- command += (" --min-spd " + str(self.minStatSlid[3].GetValue()))
|
|
|
- command += (" --min-crr " + str(self.minStatSlid[4].GetValue()))
|
|
|
- command += (" --min-crd " + str(self.minStatSlid[5].GetValue()))
|
|
|
- command += (" --min-res " + str(self.minStatSlid[6].GetValue()))
|
|
|
- command += (" --min-acc " + str(self.minStatSlid[7].GetValue()))
|
|
|
- command += (" --min-ehp " + str(self.minStatSlid[8].GetValue()))
|
|
|
- command += (" --min-dmg " + str(self.minStatSlid[9].GetValue()))
|
|
|
-
|
|
|
-
|
|
|
- command += (" --gui ")
|
|
|
- print("Command: " + command)
|
|
|
-
|
|
|
- command = "../../" + command
|
|
|
- out = subprocess.check_output(command.split())
|
|
|
- #print ("---- OUTPUT ------------------------------------------------------------------------------------------")
|
|
|
- #print(out)
|
|
|
- #print ("------------------------------------------------------------------------------------------------------")
|
|
|
-
|
|
|
- resultsFrame = ResultsFrame(None, title='Options for Lushen (DEBUG)', pos=(100, 50), size=(900, 680))
|
|
|
- resultsFrame.unitId = unitId
|
|
|
- resultsFrame.unitName = self.unitNameValue
|
|
|
- resultsFrame.currentStats = self.currentStats
|
|
|
- resultsFrame.processResults(bytes.decode(out))
|
|
|
- resultsFrame.Show()
|
|
|
-
|
|
|
- def minStatChangeBySlider(self, event):
|
|
|
- """Changes text when a slider is changed.
|
|
|
-
|
|
|
- Doesn't do validation.
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- event : wxEvent, optional
|
|
|
- The event that triggered the call (default is None).
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- slidId = int(event.GetEventObject().GetName().replace("slid", ""))
|
|
|
- self.minStatText[slidId].SetValue(str(event.GetEventObject().GetValue()))
|
|
|
-
|
|
|
- def minStatChangeByText(self, event):
|
|
|
- """Changes the slider when the text is changed.
|
|
|
-
|
|
|
- Validates the text value.
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- event : wxEvent, optional
|
|
|
- The event that triggered the call (default is None).
|
|
|
-
|
|
|
- """
|
|
|
- textId = int(event.GetEventObject().GetName().replace("tx", ""))
|
|
|
- if event.GetEventObject().GetValue().isdigit() == False:
|
|
|
- event.GetEventObject().SetValue(str(self.minStatSlid[textId].GetValue()))
|
|
|
- value = int(event.GetEventObject().GetValue())
|
|
|
- minValue = self.minStatSlid[textId].GetMin()
|
|
|
- maxValue = self.minStatSlid[textId].GetMax()
|
|
|
- if value < minValue:
|
|
|
- value = minValue
|
|
|
- event.GetEventObject().SetValue(str(value))
|
|
|
- elif value > maxValue:
|
|
|
- value = maxValue
|
|
|
- event.GetEventObject().SetValue(str(value))
|
|
|
- self.minStatSlid[textId].SetValue(value)
|
|
|
-
|
|
|
- def unitSelected(self, event):
|
|
|
- """Loads a unit info and enables optimizaton options.
|
|
|
-
|
|
|
- Called when a unit is selected from the list.
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- event : wxEvent, optional
|
|
|
- The event that triggered the call (default is None).
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- id = str(event.GetEventObject().GetItemData(event.GetEventObject().GetFirstSelected()))
|
|
|
-
|
|
|
- # First, set sliders max values
|
|
|
- self.minStatSlid[0].SetMax(50000) #HP
|
|
|
- self.minStatSlid[1].SetMax(5000) #ATK
|
|
|
- self.minStatSlid[2].SetMax(5000) #DEF
|
|
|
- self.minStatSlid[3].SetMax(500) #SPD
|
|
|
- self.minStatSlid[4].SetMax(100) #CRR
|
|
|
- self.minStatSlid[5].SetMax(500) #CRD
|
|
|
- self.minStatSlid[6].SetMax(100) #RES
|
|
|
- self.minStatSlid[7].SetMax(85) #ACC
|
|
|
- self.minStatSlid[8].SetMax(250000) #EHP
|
|
|
- self.minStatSlid[9].SetMax(8000) #DMG
|
|
|
-
|
|
|
- cursor = conn.execute("""
|
|
|
- SELECT
|
|
|
- base_hp,
|
|
|
- base_atk,
|
|
|
- base_def,
|
|
|
- base_spd,
|
|
|
- base_crr,
|
|
|
- base_crd,
|
|
|
- base_res,
|
|
|
- base_acc,
|
|
|
- current_hp,
|
|
|
- current_atk,
|
|
|
- current_def,
|
|
|
- current_spd,
|
|
|
- current_crr,
|
|
|
- current_crd,
|
|
|
- current_res,
|
|
|
- current_acc,
|
|
|
- id,
|
|
|
- name
|
|
|
- FROM units
|
|
|
- WHERE
|
|
|
- id = """ + id + """;
|
|
|
- """)
|
|
|
- row = cursor.fetchone()
|
|
|
- self.unitContent.ShowItems(True)
|
|
|
- self.unitNameValue = str(row[17])
|
|
|
- self.unitName.SetLabel(str(row[17]) + " (# " + str(row[16]) + ")")
|
|
|
- for i in range(0, 8):
|
|
|
- value = str(row[i])
|
|
|
- self.minStatSlid[i].SetMin(int(value))
|
|
|
- if i > 3:
|
|
|
- value = value + "%"
|
|
|
- else:
|
|
|
- value = value + " "
|
|
|
- self.statGrid.SetCellValue(row=i, col=0, s=value)
|
|
|
- for i in range(0, 8):
|
|
|
- value = str(row[8 + i])
|
|
|
- self.minStatSlid[i].SetValue(int(value))
|
|
|
- self.minStatText[i].SetValue(value)
|
|
|
- self.currentStats[i] = int(value)
|
|
|
- if i > 3:
|
|
|
- value = value + "%"
|
|
|
- else:
|
|
|
- value = value + " "
|
|
|
- self.statGrid.SetCellValue(row=i, col=1, s=value)
|
|
|
- # Galculate EHP and DMG
|
|
|
- baseHp = int(self.statGrid.GetCellValue(row=0, col=0))
|
|
|
- baseDef = int(self.statGrid.GetCellValue(row=2, col=0).replace("%", ""))
|
|
|
- baseEhp = math.ceil((((baseDef * 3.5) + 1140) * baseHp) / 1000)
|
|
|
- self.statGrid.SetCellValue(row=8, col=0, s=str(baseEhp))
|
|
|
- self.minStatSlid[8].SetMin(baseEhp)
|
|
|
- currentHp = int(self.statGrid.GetCellValue(row=0, col=1))
|
|
|
- currentDef = int(self.statGrid.GetCellValue(row=2, col=1).replace("%", ""))
|
|
|
- currentEhp = math.ceil((((currentDef * 3.5) + 1140) * currentHp) / 1000)
|
|
|
- self.statGrid.SetCellValue(row=8, col=1, s=str(currentEhp))
|
|
|
- self.minStatSlid[8].SetValue(currentEhp)
|
|
|
- self.minStatText[8].SetValue(str(currentEhp))
|
|
|
- baseAtk = int(self.statGrid.GetCellValue(row=1, col=0))
|
|
|
- baseCrr = int(self.statGrid.GetCellValue(row=4, col=0).replace("%", ""))
|
|
|
- baseCrd = int(self.statGrid.GetCellValue(row=5, col=0).replace("%", ""))
|
|
|
- if (baseCrr > 100):
|
|
|
- # Dont use crit rate over 100
|
|
|
- baseCrr = 100
|
|
|
- baseDmg = math.ceil((baseAtk * (100 - baseCrr) / 100) + ((baseAtk + (baseAtk * baseCrd / 100)) * baseCrr / 100));
|
|
|
- self.statGrid.SetCellValue(row=9, col=0, s=str(baseDmg))
|
|
|
- self.minStatSlid[9].SetMin(baseDmg)
|
|
|
- currentAtk = int(self.statGrid.GetCellValue(row=1, col=1))
|
|
|
- currentCrr = int(self.statGrid.GetCellValue(row=4, col=0).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));
|
|
|
- self.statGrid.SetCellValue(row=9, col=1, s=str(currentDmg))
|
|
|
- self.minStatSlid[9].SetValue(currentDmg)
|
|
|
- self.minStatText[9].SetValue(str(currentDmg))
|
|
|
-
|
|
|
- # Populate the runes
|
|
|
- for i in range(0, 6):
|
|
|
- self.runeList[i].SetLabel("")
|
|
|
- cursor = conn.execute("""
|
|
|
- SELECT
|
|
|
- id, slot, type
|
|
|
- FROM runes
|
|
|
- WHERE
|
|
|
- unit = """ + id + """
|
|
|
- ORDER BY slot;
|
|
|
- """)
|
|
|
- i = 0
|
|
|
- for row in cursor:
|
|
|
- label = ""
|
|
|
- label = label + set_names[row[2]] + "\n"
|
|
|
- # Get all stats
|
|
|
- cursorStats = conn.execute("""
|
|
|
- SELECT
|
|
|
- slot, stat, value, grind, enchant
|
|
|
- FROM rune_stats
|
|
|
- WHERE
|
|
|
- rune = """ + row[0] + """
|
|
|
- ORDER BY slot;
|
|
|
- """)
|
|
|
- j = -1
|
|
|
- for rowStats in cursorStats:
|
|
|
- while (j != rowStats[0]):
|
|
|
- label = label + "\n"
|
|
|
- j = j + 1;
|
|
|
- label = label + stat_names[rowStats[1]] + str(rowStats[2]).rjust(4) + ""
|
|
|
- if rowStats[3] > 0:
|
|
|
- label = label + " +" + str(rowStats[3])
|
|
|
- self.runeList[i].SetLabel(label)
|
|
|
- i = i + 1
|
|
|
-
|
|
|
- def makeMenuBar(self):
|
|
|
- """Sets up the application menu.
|
|
|
- """
|
|
|
-
|
|
|
- updateMenu = wx.Menu()
|
|
|
- updateJson = updateMenu.Append(
|
|
|
- -1,
|
|
|
- "&Update from JSON file\tCtrl-J",
|
|
|
- "Updates the database from a profile JSON file."
|
|
|
- );
|
|
|
- updateSwdb = updateMenu.Append(
|
|
|
- -1,
|
|
|
- "&Update from SWDB\tCtrl-W",
|
|
|
- "Updates the database from data retrieved from a SWDB instance."
|
|
|
- );
|
|
|
- updateSwarfarm = updateMenu.Append(
|
|
|
- -1,
|
|
|
- "&Update from Sarfarm\tCtrl-F",
|
|
|
- "Updates the database from data retrieved from Swarfarm."
|
|
|
- );
|
|
|
- updateSqlite = updateMenu.Append(
|
|
|
- -1,
|
|
|
- "&Update from a sqlite database\tCtrl-Q",
|
|
|
- "Updates the database from a SWDB sqlite database."
|
|
|
- );
|
|
|
-
|
|
|
- # Make a file menu with Hello and Exit items
|
|
|
- fileMenu = wx.Menu()
|
|
|
- # The "\t..." syntax defines an accelerator key that also triggers
|
|
|
- # the same event
|
|
|
- aboutItem = fileMenu.Append(wx.ID_ABOUT)
|
|
|
- fileMenu.AppendSeparator()
|
|
|
- # When using a stock ID we don't need to specify the menu item's
|
|
|
- # label
|
|
|
- exitItem = fileMenu.Append(wx.ID_EXIT)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- # Make the menu bar and add the two menus to it. The '&' defines
|
|
|
- # that the next letter is the "mnemonic" for the menu item. On the
|
|
|
- # platforms that support it those letters are underlined and can be
|
|
|
- # triggered from the keyboard.
|
|
|
- menuBar = wx.MenuBar()
|
|
|
- menuBar.Append(fileMenu, "&File")
|
|
|
- menuBar.Append(updateMenu, "&Update")
|
|
|
-
|
|
|
- # Give the menu bar to the frame
|
|
|
- self.SetMenuBar(menuBar)
|
|
|
-
|
|
|
- # Finally, associate a handler function with the EVT_MENU event for
|
|
|
- # each of the menu items. That means that when that menu item is
|
|
|
- # activated then the associated handler function will be called.
|
|
|
- #self.Bind(wx.EVT_MENU, self.OnHello, helloItem)
|
|
|
- self.Bind(wx.EVT_MENU, self.closeApp, exitItem)
|
|
|
- self.Bind(wx.EVT_MENU, self.showAbout, aboutItem)
|
|
|
- self.Bind(wx.EVT_MENU, self.updateFromJson, updateJson)
|
|
|
- self.Bind(wx.EVT_MENU, self.updateFromSwdb, updateSwdb)
|
|
|
- self.Bind(wx.EVT_MENU, self.updateFromSwarfarm, updateSwarfarm)
|
|
|
- self.Bind(wx.EVT_MENU, self.updateFromSqlite, updateSqlite)
|
|
|
-
|
|
|
- def closeApp(self, event):
|
|
|
- """Closes the app.
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- event : wxEvent, optional
|
|
|
- The event that triggered the call (default is None).
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- self.Close(True)
|
|
|
-
|
|
|
- def showAbout(self, event):
|
|
|
- """Display an About dialog.
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- event : wxEvent, optional
|
|
|
- The event that triggered the call (default is None).
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- wx.MessageBox("RuneOptimizerAbout", wx.OK | wx.ICON_INFORMATION)
|
|
|
-
|
|
|
- def updateFromJson(self, event):
|
|
|
- """Updates data from a JSON file.
|
|
|
-
|
|
|
- TODO
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- event : wxEvent, optional
|
|
|
- The event that triggered the call (default is None).
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- self.showUnimplemented(wx.EVT_MENU)
|
|
|
-
|
|
|
- def updateFromSwdb(self, event):
|
|
|
- """Updates data from a SWDB instance.
|
|
|
-
|
|
|
- TODO
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- event : wxEvent, optional
|
|
|
- The event that triggered the call (default is None).
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- self.showUnimplemented()
|
|
|
-
|
|
|
- def updateFromSwarfarm(self, event):
|
|
|
- """Updates data from Swarfarm.
|
|
|
-
|
|
|
- TODO
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- event : wxEvent, optional
|
|
|
- The event that triggered the call (default is None).
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- self.showUnimplemented()
|
|
|
-
|
|
|
- def updateFromSqlite(self, event):
|
|
|
- """Updates data from a Sqlite file.
|
|
|
-
|
|
|
- TODO
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- event : wxEvent, optional
|
|
|
- The event that triggered the call (default is None).
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- self.showUnimplemented()
|
|
|
-
|
|
|
- def showUnimplemented(self, event):
|
|
|
- """Displays a message for unimplemented features.
|
|
|
-
|
|
|
- Parameters
|
|
|
- ----------
|
|
|
- event : wxEvent, optional
|
|
|
- The event that triggered the call (default is None).
|
|
|
-
|
|
|
- """
|
|
|
-
|
|
|
- wx.MessageBox(parent=self, message="This functionality is not yet implemented", caption="Unimplemented")
|
|
|
|
|
|
def recalculteStatsOfModifiedUnits():
|
|
|
+ """Recalculates the stats of all the units marked aas modified.
|
|
|
+ """
|
|
|
global conn
|
|
|
unitCursor = conn.execute("""
|
|
|
SELECT
|