Get rid of drone variation command
This commit is contained in:
@@ -178,10 +178,6 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
self.__baseRemoteReps = (rrType, rrAmount)
|
||||
return self.__baseRemoteReps
|
||||
|
||||
def changeType(self, typeID):
|
||||
self.itemID = typeID
|
||||
self.init()
|
||||
|
||||
@property
|
||||
def miningStats(self):
|
||||
if self.__miningyield is None:
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
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
|
||||
@@ -2,7 +2,8 @@ import wx
|
||||
|
||||
from logbook import Logger
|
||||
|
||||
import eos.db
|
||||
from service.fit import Fit
|
||||
from service.market import Market
|
||||
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
@@ -10,22 +11,30 @@ pyfalog = Logger(__name__)
|
||||
|
||||
class FitRebaseItemCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, containerName, position, newTypeID):
|
||||
wx.Command.__init__(self, True, "Rebase Item")
|
||||
def __init__(self, fitID, containerName, position, itemID):
|
||||
wx.Command.__init__(self, True, 'Rebase Item')
|
||||
self.fitID = fitID
|
||||
self.containerName = containerName
|
||||
self.position = position
|
||||
self.newTypeID = newTypeID
|
||||
self.oldTypeID = None
|
||||
self.itemID = itemID
|
||||
self.savedItemID = None
|
||||
|
||||
def Do(self):
|
||||
fit = eos.db.getFit(self.fitID)
|
||||
pyfalog.debug('Doing rebase of item in {} at position {} to {}'.format(self.containerName, self.position, self.itemID))
|
||||
fit = Fit.getInstance().getFit(self.fitID)
|
||||
obj = getattr(fit, self.containerName)[self.position]
|
||||
self.oldTypeID = getattr(obj.item, "ID", None)
|
||||
newItem = eos.db.getItem(self.newTypeID)
|
||||
self.savedItemID = getattr(obj.item, 'ID', None)
|
||||
if self.savedItemID is None:
|
||||
pyfalog.warning('Unable to get old item ID')
|
||||
return False
|
||||
newItem = Market.getInstance().getItem(self.itemID)
|
||||
if newItem is None:
|
||||
pyfalog.warning('Unable to fetch new item')
|
||||
return False
|
||||
obj.rebase(newItem)
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
cmd = FitRebaseItemCommand(self.fitID, self.containerName, self.position, self.oldTypeID)
|
||||
pyfalog.debug('Undoing rebase of item in {} at position {} to {}'.format(self.containerName, self.position, self.itemID))
|
||||
cmd = FitRebaseItemCommand(self.fitID, self.containerName, self.position, self.savedItemID)
|
||||
return cmd.Do()
|
||||
|
||||
@@ -13,6 +13,7 @@ from .calc.fitReplaceModule import FitReplaceModuleCommand
|
||||
from .calc.fitAddFighter import FitAddFighterCommand
|
||||
from .calc.fitRemoveFighter import FitRemoveFighterCommand
|
||||
from .calc.fitChangeDroneVariation import FitChangeDroneVariationCommand
|
||||
from .calc.fitRebaseItem import FitRebaseItemCommand
|
||||
|
||||
|
||||
class GuiMetaSwapCommand(wx.Command):
|
||||
@@ -51,7 +52,7 @@ class GuiMetaSwapCommand(wx.Command):
|
||||
self.data.append(((FitRemoveFighterCommand, fitID, fit.fighters.index(x)), (FitAddFighterCommand, fitID, fighterInfo)))
|
||||
elif context == 'droneItem':
|
||||
for x in selection:
|
||||
self.data.append(((FitChangeDroneVariationCommand, fitID, fit.drones.index(x), itemID),),)
|
||||
self.data.append(((FitRebaseItemCommand, fitID, 'drones', fit.drones.index(x), itemID),),)
|
||||
|
||||
def Do(self):
|
||||
for cmds in self.data:
|
||||
|
||||
Reference in New Issue
Block a user