From f3bcffe2f96d399d4b22f9232176c5853046ba07 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Wed, 15 Apr 2020 15:23:49 +0300 Subject: [PATCH] Implement fax cap booster limit --- eos/effects.py | 18 ++++++++++++++++++ gui/fitCommands/calc/module/localAdd.py | 12 +++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/eos/effects.py b/eos/effects.py index 066d53345..172538e03 100644 --- a/eos/effects.py +++ b/eos/effects.py @@ -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) diff --git a/gui/fitCommands/calc/module/localAdd.py b/gui/fitCommands/calc/module/localAdd.py index e029fbeea..0425b25cb 100644 --- a/gui/fitCommands/calc/module/localAdd.py +++ b/gui/fitCommands/calc/module/localAdd.py @@ -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