Refactor checking if Hardpoints has free spots into a function fit can use
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')
|
||||
|
||||
@@ -480,12 +480,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