diff --git a/gui/builtinAdditionPanes/boosterView.py b/gui/builtinAdditionPanes/boosterView.py index a68e4ff3a..1d487d2ad 100644 --- a/gui/builtinAdditionPanes/boosterView.py +++ b/gui/builtinAdditionPanes/boosterView.py @@ -157,7 +157,7 @@ class BoosterView(d.Display): col = self.getColumn(event.Position) if col == self.getColIndex(State): fitID = self.mainFrame.getActiveFit() - self.mainFrame.command.Submit(cmd.GuiToggleImplantCommand(fitID, row)) + self.mainFrame.command.Submit(cmd.GuiToggleBoosterCommand(fitID, row)) def scheduleMenu(self, event): event.Skip() diff --git a/gui/builtinAdditionPanes/droneView.py b/gui/builtinAdditionPanes/droneView.py index 264b07183..4200f1046 100644 --- a/gui/builtinAdditionPanes/droneView.py +++ b/gui/builtinAdditionPanes/droneView.py @@ -228,9 +228,7 @@ class DroneView(Display): def removeDrone(self, drone): fitID = self.mainFrame.getActiveFit() - sFit = Fit.getInstance() - sFit.removeDrone(fitID, self.original.index(drone)) - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) + self.mainFrame.command.Submit(cmd.GuiRemoveDroneCommand(fitID, self.original.index(drone))) def click(self, event): event.Skip() diff --git a/gui/builtinContextMenus/amount.py b/gui/builtinContextMenus/amount.py index eec575f29..e5416ede6 100644 --- a/gui/builtinContextMenus/amount.py +++ b/gui/builtinContextMenus/amount.py @@ -42,15 +42,18 @@ class ChangeAmount(ContextMenu): return sFit = Fit.getInstance() + fit = sFit.getFit(fitID) cleanInput = re.sub(r'[^0-9.]', '', dlg.input.GetLineText(0).strip()) if isinstance(thing, es_Cargo): - self.mainFrame.command.Submit(cmd.GuiAddCargoCommand(fitID, thing.item.ID, int(float(cleanInput)), replace=True)) + self.mainFrame.command.Submit(cmd.GuiChangeCargoQty(fitID, fit.cargo.index(thing), int(float(cleanInput)))) return # no need for post event here elif isinstance(thing, es_Fit): - sFit.changeAmount(fitID, thing, int(float(cleanInput))) + self.mainFrame.command.Submit(cmd.GuiChangeProjectedFitQty(fitID, thing.ID, int(float(cleanInput)))) + return elif isinstance(thing, es_Fighter): - sFit.changeActiveFighters(fitID, thing, int(float(cleanInput))) + self.mainFrame.command.Submit(cmd.GuiChangeFighterQty(fitID, fit.fighters.index(thing), int(float(cleanInput)))) + return wx.PostEvent(mainFrame, GE.FitChanged(fitID=fitID)) diff --git a/gui/builtinContextMenus/droneRemoveStack.py b/gui/builtinContextMenus/droneRemoveStack.py index c7dae1e03..5af373e41 100644 --- a/gui/builtinContextMenus/droneRemoveStack.py +++ b/gui/builtinContextMenus/droneRemoveStack.py @@ -5,6 +5,7 @@ import wx import gui.globalEvents as GE from service.fit import Fit from service.settings import ContextMenuSettings +import gui.fitCommands as cmd class ItemRemove(ContextMenu): @@ -27,9 +28,7 @@ class ItemRemove(ContextMenu): fit = sFit.getFit(fitID) idx = fit.drones.index(selection[0]) - sFit.removeDrone(fitID, idx, numDronesToRemove=fit.drones[idx].amount) - - wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) + self.mainFrame.command.Submit(cmd.GuiRemoveDroneCommand(fitID, idx, fit.drones[idx].amount)) ItemRemove.register() diff --git a/gui/builtinContextMenus/droneSplit.py b/gui/builtinContextMenus/droneSplit.py index ec52db3f8..9701cc10f 100644 --- a/gui/builtinContextMenus/droneSplit.py +++ b/gui/builtinContextMenus/droneSplit.py @@ -5,6 +5,7 @@ from service.fit import Fit # noinspection PyPackageRequirements import wx from service.settings import ContextMenuSettings +import re class DroneSplit(ContextMenu): @@ -23,14 +24,94 @@ class DroneSplit(ContextMenu): def activate(self, fullContext, selection, i): srcContext = fullContext[0] - dlg = DroneSpinner(self.mainFrame, selection[0], srcContext) - dlg.ShowModal() - dlg.Destroy() + drone = selection[0] + dlg = DroneStackSplit(self.mainFrame, drone.amount) + + if dlg.ShowModal() == wx.ID_OK: + + if dlg.input.GetLineText(0).strip() == '': + return + + sFit = Fit.getInstance() + cleanInput = re.sub(r'[^0-9.]', '', dlg.input.GetLineText(0).strip()) + fitID = self.mainFrame.getActiveFit() + + if srcContext == "droneItem": + sFit.splitDroneStack(fitID, drone, int(float(cleanInput))) + else: + sFit.splitProjectedDroneStack(fitID, drone, int(float(cleanInput))) + + wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) + + # if isinstance(thing, es_Cargo): + # self.mainFrame.command.Submit( + # cmd.GuiAddCargoCommand(fitID, thing.item.ID, int(float(cleanInput)), replace=True)) + # return # no need for post event here + # elif isinstance(thing, es_Fit): + # sFit.changeAmount(fitID, thing, int(float(cleanInput))) + # elif isinstance(thing, es_Fighter): + # sFit.changeActiveFighters(fitID, thing, int(float(cleanInput))) + # + # wx.PostEvent(mainFrame, GE.FitChanged(fitID=fitID)) + # + # dlg = DroneSpinner(self.mainFrame, selection[0], srcContext) + # dlg.ShowModal() + # dlg.Destroy() DroneSplit.register() +class DroneStackSplit(wx.Dialog): + def __init__(self, parent, value): + wx.Dialog.__init__(self, parent, title="Split Drone Stack") + self.SetMinSize((346, 156)) + + bSizer1 = wx.BoxSizer(wx.VERTICAL) + + bSizer2 = wx.BoxSizer(wx.VERTICAL) + text = wx.StaticText(self, wx.ID_ANY, "New Amount:") + bSizer2.Add(text, 0) + + bSizer1.Add(bSizer2, 0, wx.ALL, 10) + + self.input = wx.TextCtrl(self, wx.ID_ANY, style=wx.TE_PROCESS_ENTER) + self.input.SetValue(str(value)) + self.input.SelectAll() + + bSizer1.Add(self.input, 0, wx.LEFT | wx.RIGHT | wx.EXPAND, 15) + + bSizer3 = wx.BoxSizer(wx.VERTICAL) + bSizer3.Add(wx.StaticLine(self, wx.ID_ANY), 0, wx.BOTTOM | wx.EXPAND, 15) + + bSizer3.Add(self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL), 0, wx.EXPAND) + bSizer1.Add(bSizer3, 0, wx.ALL | wx.EXPAND, 10) + + self.input.SetFocus() + self.input.Bind(wx.EVT_CHAR, self.onChar) + self.input.Bind(wx.EVT_TEXT_ENTER, self.processEnter) + self.SetSizer(bSizer1) + self.CenterOnParent() + self.Fit() + + def processEnter(self, evt): + self.EndModal(wx.ID_OK) + + # checks to make sure it's valid number + @staticmethod + def onChar(event): + key = event.GetKeyCode() + + acceptable_characters = "1234567890" + acceptable_keycode = [3, 22, 13, 8, 127] # modifiers like delete, copy, paste + if key in acceptable_keycode or key >= 255 or (key < 255 and chr(key) in acceptable_characters): + event.Skip() + return + else: + return False + + + class DroneSpinner(wx.Dialog): def __init__(self, parent, drone, context): wx.Dialog.__init__(self, parent, title="Select Amount", size=wx.Size(220, 60)) diff --git a/gui/builtinContextMenus/itemRemove.py b/gui/builtinContextMenus/itemRemove.py index 65094c7a4..cbae19145 100644 --- a/gui/builtinContextMenus/itemRemove.py +++ b/gui/builtinContextMenus/itemRemove.py @@ -40,8 +40,10 @@ class ItemRemove(ContextMenu): return # the command takes care of the PostEvent elif srcContext in ("fittingCharge", "projectedCharge"): self.mainFrame.command.Submit(cmd.GuiModuleAddChargeCommand(fitID, None, selection)) + return elif srcContext == "droneItem": - sFit.removeDrone(fitID, fit.drones.index(selection[0])) + self.mainFrame.command.Submit(cmd.GuiRemoveDroneCommand(fitID, fit.drones.index(selection[0]))) + return elif srcContext == "fighterItem": self.mainFrame.command.Submit(cmd.GuiRemoveFighterCommand(fitID, fit.fighters.index(selection[0]))) return # the command takes care of the PostEvent diff --git a/gui/fitCommands/__init__.py b/gui/fitCommands/__init__.py index 5394dafa0..b708d153a 100644 --- a/gui/fitCommands/__init__.py +++ b/gui/fitCommands/__init__.py @@ -22,5 +22,9 @@ from .guiRemoveFighter import GuiRemoveFighterCommand from .guiMetaSwap import GuiMetaSwapCommand from .guiToggleFighter import GuiToggleFighterCommand from .guiToggleImplant import GuiToggleImplantCommand -from .guiToggleBooster import GuiToggleImplantCommand -from .guiAddDrone import GuiAddDroneCommand \ No newline at end of file +from .guiToggleBooster import GuiToggleBoosterCommand +from .guiAddDrone import GuiAddDroneCommand +from .guiRemoveDrone import GuiRemoveDroneCommand +from .guiChangeFighterQty import GuiChangeFighterQty +from .guiChangeCargoQty import GuiChangeCargoQty +from .guiChangeProjectedFitQty import GuiChangeProjectedFitQty \ No newline at end of file diff --git a/gui/fitCommands/calc/fitAddDrone.py b/gui/fitCommands/calc/fitAddDrone.py index 59e01b807..c92f9fa78 100644 --- a/gui/fitCommands/calc/fitAddDrone.py +++ b/gui/fitCommands/calc/fitAddDrone.py @@ -20,6 +20,7 @@ class FitAddDroneCommand(wx.Command): self.itemID = itemID self.amount = amount # add x amount. If this goes over amount, removes stack self.replace = replace # if this is false, we increment. + self.index = None def Do(self): pyfalog.debug("Adding {0} drones ({1}) to fit ID: {2}", self.amount, self.itemID, self.fitID) @@ -44,10 +45,10 @@ class FitAddDroneCommand(wx.Command): drone.amount += self.amount eos.db.commit() + self.index = fit.drones.index(drone) return True def Undo(self): - from .fitRemoveCargo import FitRemoveCargoCommand # Avoid circular import - cmd = FitRemoveCargoCommand(self.fitID, self.itemID, self.amount) - cmd.Do() - return True + from .fitRemoveDrone import FitRemoveDroneCommand # Avoid circular import + cmd = FitRemoveDroneCommand(self.fitID, self.index, self.amount) + return cmd.Do() diff --git a/gui/fitCommands/calc/fitChangeCargoQty.py b/gui/fitCommands/calc/fitChangeCargoQty.py new file mode 100644 index 000000000..c737f3c22 --- /dev/null +++ b/gui/fitCommands/calc/fitChangeCargoQty.py @@ -0,0 +1,33 @@ +import wx +from service.fit import Fit + +import gui.mainFrame +from gui import globalEvents as GE +#from .helpers import ModuleInfoCache +from eos.saveddata.module import Module, State +import eos.db +from logbook import Logger +pyfalog = Logger(__name__) +from eos.saveddata.drone import Drone + +class FitChangeCargoQty(wx.Command): + def __init__(self, fitID, position, amount=1): + wx.Command.__init__(self, True, "Drone add") + self.fitID = fitID + self.position = position + self.amount = amount # add x amount. If this goes over amount, removes stack + self.old_amount = None + + def Do(self): + pyfalog.debug("Changing cargo ({0}) for fit ({1}) to amount: {2}", self.position, self.fitID, self.amount) + fit = eos.db.getFit(self.fitID) + cargo = fit.cargo[self.position] + self.old_amount = cargo.amount + cargo.amount = self.amount + + eos.db.commit() + return True + + def Undo(self): + cmd = FitChangeCargoQty(self.fitID, self.position, self.old_amount) + return cmd.Do() diff --git a/gui/fitCommands/calc/fitChangeFighterQty.py b/gui/fitCommands/calc/fitChangeFighterQty.py new file mode 100644 index 000000000..d8c2af274 --- /dev/null +++ b/gui/fitCommands/calc/fitChangeFighterQty.py @@ -0,0 +1,36 @@ +import wx +from service.fit import Fit + +import gui.mainFrame +from gui import globalEvents as GE +#from .helpers import ModuleInfoCache +from eos.saveddata.module import Module, State +import eos.db +from logbook import Logger +pyfalog = Logger(__name__) +from eos.saveddata.drone import Drone + +class FitChangeFighterQty(wx.Command): + """" + from sFit.changeActiveFighters + """ + def __init__(self, fitID, position, amount=1): + wx.Command.__init__(self, True, "Drone add") + self.fitID = fitID + self.position = position + self.amount = amount # add x amount. If this goes over amount, removes stack + self.old_amount = None + + def Do(self): + pyfalog.debug("Changing active fighters ({0}) for fit ({1}) to amount: {2}", self.position, self.fitID, self.amount) + fit = eos.db.getFit(self.fitID) + fighter = fit.fighters[self.position] + self.old_amount = fighter.amountActive + fighter.amountActive = self.amount + + eos.db.commit() + return True + + def Undo(self): + cmd = FitChangeFighterQty(self.fitID, self.position, self.old_amount) + return cmd.Do() diff --git a/gui/fitCommands/calc/fitChangeProjectedFitQty.py b/gui/fitCommands/calc/fitChangeProjectedFitQty.py new file mode 100644 index 000000000..e379ec883 --- /dev/null +++ b/gui/fitCommands/calc/fitChangeProjectedFitQty.py @@ -0,0 +1,42 @@ +import wx +from service.fit import Fit + +import gui.mainFrame +from gui import globalEvents as GE +#from .helpers import ModuleInfoCache +from eos.saveddata.module import Module, State +import eos.db +from logbook import Logger +pyfalog = Logger(__name__) + +class FitChangeProjectedFitQty(wx.Command): + """" + from sFit.changeAmount + """ + def __init__(self, fitID, pfitID, amount=1): + wx.Command.__init__(self, True, "Drone add") + self.fitID = fitID + self.pfitID = pfitID + self.amount = amount + self.old_amount = None + + def Do(self): + fit = eos.db.getFit(self.fitID) + pfit = eos.db.getFit(self.pfitID) + + if not pfit: # fit was deleted + return False + + amount = min(20, max(1, self.amount)) # 1 <= a <= 20 + + projectionInfo = pfit.getProjectionInfo(self.fitID) + if projectionInfo: + self.old_amount = projectionInfo.amount + projectionInfo.amount = amount + + eos.db.commit() + return True + + def Undo(self): + cmd = FitChangeProjectedFitQty(self.fitID, self.pfitID, self.old_amount) + return cmd.Do() diff --git a/gui/fitCommands/calc/fitRemoveDrone.py b/gui/fitCommands/calc/fitRemoveDrone.py new file mode 100644 index 000000000..13e96d435 --- /dev/null +++ b/gui/fitCommands/calc/fitRemoveDrone.py @@ -0,0 +1,49 @@ +import wx +from service.fit import Fit + +import gui.mainFrame +from gui import globalEvents as GE +#from .helpers import ModuleInfoCache +from eos.saveddata.module import Module, State +import eos.db +from logbook import Logger +pyfalog = Logger(__name__) +from eos.saveddata.drone import Drone + +class FitRemoveDroneCommand(wx.Command): + """" + from sFit.addDrone + """ + def __init__(self, fitID, position, amount=1): + wx.Command.__init__(self, True, "Drone add") + self.fitID = fitID + self.position = position + self.amount = amount # add x amount. If this goes over amount, removes stack + self.removed_item = None + + def Do(self): + pyfalog.debug("Removing {0} drones for fit ID: {1}", self.amount, self.fitID) + fit = eos.db.getFit(self.fitID) + d = fit.drones[self.position] + d.amount -= self.amount + if d.amountActive > 0: + d.amountActive -= self.amount + + if d.amount == 0: + self.removed_item = d.itemID + del fit.drones[self.position] + + eos.db.commit() + return True + + def Undo(self): + if self.removed_item: + from .fitAddDrone import FitAddDroneCommand # Avoid circular import + cmd = FitAddDroneCommand(self.fitID, self.removed_item, self.amount) + return cmd.Do() + else: + fit = eos.db.getFit(self.fitID) + d = fit.drones[self.position] + d.amount += self.amount + eos.db.commit() + return True diff --git a/gui/fitCommands/guiChangeCargoQty.py b/gui/fitCommands/guiChangeCargoQty.py new file mode 100644 index 000000000..b8a6c8873 --- /dev/null +++ b/gui/fitCommands/guiChangeCargoQty.py @@ -0,0 +1,38 @@ +import wx +import eos.db +import gui.mainFrame +from service.fit import Fit +from gui import globalEvents as GE +from .calc.fitAddModule import FitAddModuleCommand +from .calc.fitReplaceModule import FitReplaceModuleCommand +from .calc.fitChangeCargoQty import FitChangeCargoQty +from service.fit import Fit +from logbook import Logger +pyfalog = Logger(__name__) + + +class GuiChangeCargoQty(wx.Command): + def __init__(self, fitID, position, amount=1): + wx.Command.__init__(self, True, "") + self.mainFrame = gui.mainFrame.MainFrame.getInstance() + self.sFit = Fit.getInstance() + self.fitID = fitID + self.position = position + self.amount = amount + self.internal_history = wx.CommandProcessor() + + def Do(self): + cmd = FitChangeCargoQty(self.fitID, self.position, self.amount) + if self.internal_history.Submit(cmd): + self.sFit.recalc(self.fitID) + wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + return True + return False + + + def Undo(self): + for _ in self.internal_history.Commands: + self.internal_history.Undo() + self.sFit.recalc(self.fitID) + wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + return True diff --git a/gui/fitCommands/guiChangeFighterQty.py b/gui/fitCommands/guiChangeFighterQty.py new file mode 100644 index 000000000..063c6cda5 --- /dev/null +++ b/gui/fitCommands/guiChangeFighterQty.py @@ -0,0 +1,39 @@ +import wx +import eos.db +import gui.mainFrame +from service.fit import Fit +from gui import globalEvents as GE +from .calc.fitAddModule import FitAddModuleCommand +from .calc.fitReplaceModule import FitReplaceModuleCommand +from .calc.fitChangeFighterQty import FitChangeFighterQty +from service.fit import Fit +from logbook import Logger +pyfalog = Logger(__name__) + + +class GuiChangeFighterQty(wx.Command): + def __init__(self, fitID, position, amount=1): + wx.Command.__init__(self, True, "") + self.mainFrame = gui.mainFrame.MainFrame.getInstance() + self.sFit = Fit.getInstance() + self.fitID = fitID + self.position = position + self.amount = amount + self.internal_history = wx.CommandProcessor() + + def Do(self): + cmd = FitChangeFighterQty(self.fitID, self.position, self.amount) + if self.internal_history.Submit(cmd): + self.sFit.recalc(self.fitID) + wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + return True + return False + + + def Undo(self): + pyfalog.debug("{} Undo()".format(self)) + for _ in self.internal_history.Commands: + self.internal_history.Undo() + self.sFit.recalc(self.fitID) + wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + return True diff --git a/gui/fitCommands/guiChangeProjectedFitQty.py b/gui/fitCommands/guiChangeProjectedFitQty.py new file mode 100644 index 000000000..006876077 --- /dev/null +++ b/gui/fitCommands/guiChangeProjectedFitQty.py @@ -0,0 +1,39 @@ +import wx +import eos.db +import gui.mainFrame +from service.fit import Fit +from gui import globalEvents as GE +from .calc.fitAddModule import FitAddModuleCommand +from .calc.fitReplaceModule import FitReplaceModuleCommand +from .calc.fitChangeProjectedFitQty import FitChangeProjectedFitQty +from service.fit import Fit +from logbook import Logger +pyfalog = Logger(__name__) + + +class GuiChangeProjectedFitQty(wx.Command): + def __init__(self, fitID, pfitID, amount=1): + wx.Command.__init__(self, True, "") + self.mainFrame = gui.mainFrame.MainFrame.getInstance() + self.sFit = Fit.getInstance() + self.fitID = fitID + self.pfitID = pfitID + self.amount = amount + self.internal_history = wx.CommandProcessor() + + def Do(self): + cmd = FitChangeProjectedFitQty(self.fitID, self.pfitID, self.amount) + if self.internal_history.Submit(cmd): + self.sFit.recalc(self.fitID) + wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + return True + return False + + + def Undo(self): + pyfalog.debug("{} Undo()".format(self)) + for _ in self.internal_history.Commands: + self.internal_history.Undo() + self.sFit.recalc(self.fitID) + wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + return True diff --git a/gui/fitCommands/guiRemoveDrone.py b/gui/fitCommands/guiRemoveDrone.py new file mode 100644 index 000000000..252adc2af --- /dev/null +++ b/gui/fitCommands/guiRemoveDrone.py @@ -0,0 +1,31 @@ +import wx +from service.fit import Fit + +import gui.mainFrame +from gui import globalEvents as GE +from .calc.fitRemoveDrone import FitRemoveDroneCommand + +class GuiRemoveDroneCommand(wx.Command): + def __init__(self, fitID, position, amount=1): + wx.Command.__init__(self, True, "Cargo Add") + self.mainFrame = gui.mainFrame.MainFrame.getInstance() + self.sFit = Fit.getInstance() + self.internal_history = wx.CommandProcessor() + self.fitID = fitID + self.position = position + self.amount = amount + + def Do(self): + cmd = FitRemoveDroneCommand(self.fitID, self.position, self.amount) + if self.internal_history.Submit(cmd): + self.sFit.recalc(self.fitID) + wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + return True + return False + + def Undo(self): + for _ in self.internal_history.Commands: + self.internal_history.Undo() + wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID)) + return True + diff --git a/gui/fitCommands/guiToggleBooster.py b/gui/fitCommands/guiToggleBooster.py index 7d5016dc5..166ad9648 100644 --- a/gui/fitCommands/guiToggleBooster.py +++ b/gui/fitCommands/guiToggleBooster.py @@ -5,7 +5,7 @@ import gui.mainFrame from gui import globalEvents as GE from .calc.fitToggleBooster import FitToggleBoosterCommand -class GuiToggleImplantCommand(wx.Command): +class GuiToggleBoosterCommand(wx.Command): def __init__(self, fitID, position): wx.Command.__init__(self, True, "") self.mainFrame = gui.mainFrame.MainFrame.getInstance() diff --git a/service/fit.py b/service/fit.py index 0b9e73ed0..6ed79829d 100644 --- a/service/fit.py +++ b/service/fit.py @@ -369,25 +369,6 @@ class Fit(FitDeprecated): self.recalc(fit) - def changeAmount(self, fitID, projected_fit, amount): - """Change amount of projected fits""" - pyfalog.debug("Changing fit ({0}) for projected fit ({1}) to new amount: {2}", fitID, projected_fit.getProjectionInfo(fitID), amount) - fit = eos.db.getFit(fitID) - amount = min(20, max(1, amount)) # 1 <= a <= 20 - projectionInfo = projected_fit.getProjectionInfo(fitID) - if projectionInfo: - projectionInfo.amount = amount - - eos.db.commit() - self.recalc(fit) - - def changeActiveFighters(self, fitID, fighter, amount): - pyfalog.debug("Changing active fighters ({0}) for fit ({1}) to amount: {2}", fighter.itemID, fitID, amount) - fit = eos.db.getFit(fitID) - fighter.amountActive = amount - - eos.db.commit() - self.recalc(fit) def changeMutatedValue(self, mutator, value): @@ -513,6 +494,7 @@ class Fit(FitDeprecated): fit = eos.db.getFit(fitID) self.splitDrones(fit, d, amount, fit.drones) + @deprecated def removeDrone(self, fitID, i, numDronesToRemove=1, recalc=True): pyfalog.debug("Removing {0} drones for fit ID: {1}", numDronesToRemove, fitID) fit = eos.db.getFit(fitID) diff --git a/service/fitDeprecated.py b/service/fitDeprecated.py index 8593930a3..165d929eb 100644 --- a/service/fitDeprecated.py +++ b/service/fitDeprecated.py @@ -35,6 +35,30 @@ pyfalog = Logger(__name__) class FitDeprecated(object): + + @deprecated + def changeAmount(self, fitID, projected_fit, amount): + """Change amount of projected fits""" + pyfalog.debug("Changing fit ({0}) for projected fit ({1}) to new amount: {2}", fitID, + projected_fit.getProjectionInfo(fitID), amount) + fit = eos.db.getFit(fitID) + amount = min(20, max(1, amount)) # 1 <= a <= 20 + projectionInfo = projected_fit.getProjectionInfo(fitID) + if projectionInfo: + projectionInfo.amount = amount + + eos.db.commit() + self.recalc(fit) + + @deprecated + def changeActiveFighters(self, fitID, fighter, amount): + pyfalog.debug("Changing active fighters ({0}) for fit ({1}) to amount: {2}", fighter.itemID, fitID, amount) + fit = eos.db.getFit(fitID) + fighter.amountActive = amount + + eos.db.commit() + self.recalc(fit) + @deprecated def addDrone(self, fitID, itemID, numDronesToAdd=1, recalc=True): pyfalog.debug("Adding {0} drones ({1}) to fit ID: {2}", numDronesToAdd, itemID, fitID)