Merge pull request #1 from pyfa-org/master

Pull from upstream.
This commit is contained in:
Traian Nedelea
2018-10-15 05:59:27 -05:00
committed by GitHub
4 changed files with 50 additions and 3 deletions

View File

@@ -5,5 +5,6 @@
type = "active"
def handler(fit, src, context):
pass
def handler(fit, module, context):
fit.ship.boostItemAttr("signatureRadius", module.getModifiedItemAttr("signatureRadiusBonusPercent"),
stackingPenalties=True)

View File

@@ -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

View 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

View File

@@ -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: