Add drones and fighters to fit optimization

This commit is contained in:
DarkPhoenix
2019-03-03 10:00:23 +03:00
parent d96146034a
commit 647c093451
3 changed files with 19 additions and 1 deletions

View File

@@ -296,6 +296,13 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
copy.amountActive = self.amountActive
return copy
def rebase(self, item):
amount = self.amount
amountActive = self.amountActive
Drone.__init__(self, item)
self.amount = amount
self.amountActive = amountActive
def fits(self, fit):
fitDroneGroupLimits = set()
for i in range(1, 3):

View File

@@ -355,6 +355,17 @@ class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
copyAbility.active = ability.active
return copy
def rebase(self, item):
amount = self.amount
active = self.active
abilityEffectStates = {a.effectID: a.active for a in self.abilities}
Fighter.__init__(self, item)
self.amount = amount
self.active = active
for ability in self.abilities:
if ability.effectID in abilityEffectStates:
ability.active = abilityEffectStates[ability.effectID]
def fits(self, fit):
# If ships doesn't support this type of fighter, don't add it
if fit.getNumSlots(self.slot) == 0:

View File

@@ -234,7 +234,7 @@ class Price:
def cb(replacementMap):
changes = False
for container in (fit.modules,):
for container in (fit.modules, fit.drones, fit.fighters):
for obj in container:
charge = getattr(obj, 'charge', None)
if charge is not None and charge in replacementMap: