Merge pull request #1626 from WatchMeCalculate/Issue-#1519
Issue #1519, on fitting restriction toggle, accurately keep valid modules
This commit is contained in:
@@ -1016,6 +1016,16 @@ class Fit(object):
|
||||
def getNumSlots(self, type):
|
||||
return self.ship.getModifiedItemAttr(self.slots[type]) or 0
|
||||
|
||||
def getHardpointsFree(self, type):
|
||||
if type == Hardpoint.NONE:
|
||||
return 1
|
||||
elif type == Hardpoint.TURRET:
|
||||
return self.ship.getModifiedItemAttr('turretSlotsLeft') - self.getHardpointsUsed(Hardpoint.TURRET)
|
||||
elif type == Hardpoint.MISSILE:
|
||||
return self.ship.getModifiedItemAttr('launcherSlotsLeft') - self.getHardpointsUsed(Hardpoint.MISSILE)
|
||||
else:
|
||||
raise ValueError("%d is not a valid value for Hardpoint Enum", type)
|
||||
|
||||
@property
|
||||
def calibrationUsed(self):
|
||||
return self.getItemAttrOnlineSum(self.modules, 'upgradeCost')
|
||||
|
||||
@@ -472,7 +472,8 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
if max is not None:
|
||||
current = 0 # if self.owner != fit else -1 # Disabled, see #1278
|
||||
for mod in fit.modules:
|
||||
if mod.item and mod.item.groupID == self.item.groupID:
|
||||
if (mod.item and mod.item.groupID == self.item.groupID and
|
||||
self.modPosition != mod.modPosition):
|
||||
current += 1
|
||||
|
||||
if current >= max:
|
||||
@@ -480,12 +481,8 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
|
||||
# Check this only if we're told to do so
|
||||
if hardpointLimit:
|
||||
if self.hardpoint == Hardpoint.TURRET:
|
||||
if fit.ship.getModifiedItemAttr('turretSlotsLeft') - fit.getHardpointsUsed(Hardpoint.TURRET) < 1:
|
||||
return False
|
||||
elif self.hardpoint == Hardpoint.MISSILE:
|
||||
if fit.ship.getModifiedItemAttr('launcherSlotsLeft') - fit.getHardpointsUsed(Hardpoint.MISSILE) < 1:
|
||||
return False
|
||||
if fit.getHardpointsFree(self.hardpoint) < 1:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user