Implement fax cap booster limit

This commit is contained in:
DarkPhoenix
2020-04-15 15:23:49 +03:00
parent bc5786d099
commit f3bcffe2f9
2 changed files with 27 additions and 3 deletions

View File

@@ -36395,3 +36395,21 @@ class Effect8026(BaseEffect):
fit.modules.filteredChargeBoost(
lambda mod: mod.charge.requiresSkill('Missile Launcher Operation'),
'aoeVelocity', implant.getModifiedItemAttr('hydraMissileExplosionVelocityBonus'), **kwargs)
class Effect8029(BaseEffect):
"""
roleBonus7CapBoosterGroupRestriction
Used by:
Ships from group: Force Auxiliary (6 of 6)
"""
type = 'passive'
@staticmethod
def handler(fit, ship, context, projectionRange, **kwargs):
for attr in ('maxGroupOnline', 'maxGroupFitted'):
fit.modules.filteredItemForce(
lambda mod: mod.item.group.name == 'Capacitor Booster',
attr, ship.getModifiedItemAttr('shipBonusRole7'), **kwargs)

View File

@@ -40,9 +40,6 @@ class CalcAddLocalModuleCommand(wx.Command):
position=fit.modules.index(oldMod),
newModInfo=self.newModInfo)
return self.subsystemCmd.Do()
if not newMod.fits(fit):
pyfalog.warning('Module does not fit')
return False
fit.modules.append(newMod)
if newMod not in fit.modules:
pyfalog.warning('Failed to append to list')
@@ -52,6 +49,15 @@ class CalcAddLocalModuleCommand(wx.Command):
# relationship via .owner attribute, which is handled by SQLAlchemy
eos.db.flush()
sFit.recalc(fit)
# fits() sometimes relies on recalculated on-item attributes, such as fax cap
# booster limitation, so we have to check it after recalculating and remove the
# module if the check has failed
if not newMod.fits(fit):
pyfalog.warning('Module does not fit')
from .localRemove import CalcRemoveLocalModulesCommand
cmd = CalcRemoveLocalModulesCommand(fitID=self.fitID, positions=[self.savedPosition], recalc=False)
cmd.Do()
return False
self.savedStateCheckChanges = sFit.checkStates(fit, newMod)
return True