Support changing variation for drones #1773
This commit is contained in:
@@ -124,6 +124,10 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
def dps(self):
|
||||
return self.damageStats()
|
||||
|
||||
def changeType(self, typeID):
|
||||
self.itemID = typeID
|
||||
self.init()
|
||||
|
||||
def damageStats(self, targetResists=None):
|
||||
if self.__dps is None:
|
||||
self.__volley = 0
|
||||
|
||||
39
gui/fitCommands/calc/fitChangeDroneVariation.py
Normal file
39
gui/fitCommands/calc/fitChangeDroneVariation.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
class FitChangeDroneVariationCommand(wx.Command):
|
||||
""""
|
||||
Fitting command that changes an existing drone into another variation.
|
||||
"""
|
||||
def __init__(self, fitID, position, itemID):
|
||||
wx.Command.__init__(self, True, "Change Module")
|
||||
|
||||
self.fitID = fitID
|
||||
self.itemID = itemID
|
||||
self.position = position
|
||||
self.old_drone = None
|
||||
|
||||
def Do(self):
|
||||
return self.change_drone(self.fitID, self.position, self.itemID)
|
||||
|
||||
def Undo(self):
|
||||
self.change_drone(self.fitID, self.position, self.old_drone)
|
||||
return True
|
||||
|
||||
def change_drone(self, fitID, position, itemID):
|
||||
fit = eos.db.getFit(self.fitID)
|
||||
drone = fit.drones[self.position]
|
||||
|
||||
if itemID == drone.itemID:
|
||||
return False
|
||||
|
||||
self.old_drone = drone.itemID
|
||||
|
||||
drone.changeType(itemID)
|
||||
eos.db.commit()
|
||||
# todo: ensure that, whatever type we send in, is actually a variation of the original drone. If not, return False
|
||||
return True
|
||||
@@ -12,6 +12,7 @@ from .calc.fitAddCargo import FitAddCargoCommand
|
||||
from .calc.fitReplaceModule import FitReplaceModuleCommand
|
||||
from .calc.fitAddFighter import FitAddFighterCommand
|
||||
from .calc.fitRemoveFighter import FitRemoveFighterCommand
|
||||
from .calc.fitChangeDroneVariation import FitChangeDroneVariationCommand
|
||||
|
||||
|
||||
class GuiMetaSwapCommand(wx.Command):
|
||||
@@ -44,7 +45,9 @@ class GuiMetaSwapCommand(wx.Command):
|
||||
for x in selection:
|
||||
self.data.append(((FitRemoveFighterCommand, fitID, fit.fighters.index(x)), (FitAddFighterCommand, fitID, itemID)))
|
||||
elif context == 'droneItem':
|
||||
raise NotImplementedError()
|
||||
for x in selection:
|
||||
self.data.append(((FitChangeDroneVariationCommand, fitID, fit.drones.index(x), itemID),),)
|
||||
|
||||
|
||||
def Do(self):
|
||||
for cmds in self.data:
|
||||
|
||||
Reference in New Issue
Block a user