Merge pull request #1885 from pyfa-org/issue1870
Implement fixes for #1870 - undo the Module.toDummy that happens when…
This commit is contained in:
@@ -384,6 +384,32 @@ class Fit(object):
|
||||
else:
|
||||
return val
|
||||
|
||||
def canFit(self, item):
|
||||
# Whereas Module.fits() deals with current state of the fit in order to determine if somethign fits (for example maxGroupFitted which can be modified by effects),
|
||||
# this function should be used against Items to see if the item is even allowed on the fit with rules that don't change
|
||||
|
||||
fitsOnType = set()
|
||||
fitsOnGroup = set()
|
||||
|
||||
shipType = item.attributes.get("fitsToShipType", None)
|
||||
if shipType is not None:
|
||||
fitsOnType.add(shipType.value)
|
||||
|
||||
fitsOnType.update([item.attributes[attr].value for attr in item.attributes if attr.startswith("canFitShipType")])
|
||||
fitsOnGroup.update([item.attributes[attr].value for attr in item.attributes if attr.startswith("canFitShipGroup")])
|
||||
|
||||
if (len(fitsOnGroup) > 0 or len(fitsOnType) > 0) \
|
||||
and self.ship.item.group.ID not in fitsOnGroup \
|
||||
and self.ship.item.ID not in fitsOnType:
|
||||
return False
|
||||
|
||||
# Citadel modules are now under a new category, so we can check this to ensure only structure modules can fit on a citadel
|
||||
if isinstance(self.ship, Citadel) and item.category.name != "Structure Module" or \
|
||||
not isinstance(self.ship, Citadel) and item.category.name == "Structure Module":
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def clear(self, projected=False, command=False):
|
||||
self.__effectiveTank = None
|
||||
self.__weaponDpsMap = {}
|
||||
|
||||
@@ -539,34 +539,8 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
return fits
|
||||
|
||||
def __fitRestrictions(self, fit, hardpointLimit=True):
|
||||
# Check ship type restrictions
|
||||
fitsOnType = set()
|
||||
fitsOnGroup = set()
|
||||
|
||||
shipType = self.getModifiedItemAttr("fitsToShipType", None)
|
||||
if shipType is not None:
|
||||
fitsOnType.add(shipType)
|
||||
|
||||
for attr in list(self.itemModifiedAttributes.keys()):
|
||||
if attr.startswith("canFitShipType"):
|
||||
shipType = self.getModifiedItemAttr(attr, None)
|
||||
if shipType is not None:
|
||||
fitsOnType.add(shipType)
|
||||
|
||||
for attr in list(self.itemModifiedAttributes.keys()):
|
||||
if attr.startswith("canFitShipGroup"):
|
||||
shipGroup = self.getModifiedItemAttr(attr, None)
|
||||
if shipGroup is not None:
|
||||
fitsOnGroup.add(shipGroup)
|
||||
|
||||
if (len(fitsOnGroup) > 0 or len(fitsOnType) > 0) \
|
||||
and fit.ship.item.group.ID not in fitsOnGroup \
|
||||
and fit.ship.item.ID not in fitsOnType:
|
||||
return False
|
||||
|
||||
# Citadel modules are now under a new category, so we can check this to ensure only structure modules can fit on a citadel
|
||||
if isinstance(fit.ship, Citadel) and self.item.category.name != "Structure Module" or \
|
||||
not isinstance(fit.ship, Citadel) and self.item.category.name == "Structure Module":
|
||||
if not fit.canFit(self.item):
|
||||
return False
|
||||
|
||||
# EVE doesn't let capital modules be fit onto subcapital hulls. Confirmed by CCP Larrikin that this is dictated
|
||||
|
||||
Reference in New Issue
Block a user