Add 2 functions which calculate how many drones ship can release / store
This commit is contained in:
@@ -250,6 +250,17 @@ class Item(EqBase):
|
||||
|
||||
return self.__attributes
|
||||
|
||||
@property
|
||||
def attribsWithOverrides(self):
|
||||
overrides = self.overrides
|
||||
attribs = {}
|
||||
for aname, attr in self.attributes.items():
|
||||
if aname in overrides:
|
||||
attribs[aname] = overrides[aname]
|
||||
else:
|
||||
attribs[aname] = attr
|
||||
return attribs
|
||||
|
||||
def getAttribute(self, key, default=None):
|
||||
if key in self.attributes:
|
||||
return self.attributes[key].value
|
||||
|
||||
@@ -1507,6 +1507,21 @@ class Fit(object):
|
||||
|
||||
return True
|
||||
|
||||
def howManyDronesRelease(self, item):
|
||||
if not item.isDrone:
|
||||
return 0
|
||||
bw = round(self.ship.getModifiedItemAttr("droneBandwidth"))
|
||||
volume = round(item.attribsWithOverrides['volume'])
|
||||
return int(bw / volume)
|
||||
|
||||
def howManyDronesStore(self, item):
|
||||
if not item.isDrone:
|
||||
return 0
|
||||
bayTotal = round(self.ship.getModifiedItemAttr("droneCapacity"))
|
||||
bayUsed = round(self.droneBayUsed)
|
||||
volume = item.attribsWithOverrides['volume']
|
||||
return int((bayTotal - bayUsed) / volume)
|
||||
|
||||
def __deepcopy__(self, memo=None):
|
||||
fitCopy = Fit()
|
||||
# Character and owner are not copied
|
||||
|
||||
@@ -31,9 +31,10 @@ class CalcAddLocalDroneCommand(wx.Command):
|
||||
# with enough space for new drones and use it
|
||||
if not self.forceNewStack and self.droneInfo.amountActive == 0:
|
||||
for drone in fit.drones.find(item):
|
||||
maxStack = max(5, fit.extraAttributes["maxActiveDrones"])
|
||||
if (
|
||||
drone is not None and drone.amountActive == 0 and
|
||||
drone.amount + self.droneInfo.amount) <= max(5, fit.extraAttributes["maxActiveDrones"]
|
||||
drone.amount + self.droneInfo.amount <= maxStack
|
||||
):
|
||||
self.savedDroneInfo = DroneInfo.fromDrone(drone)
|
||||
self.savedPosition = fit.drones.index(drone)
|
||||
|
||||
@@ -346,35 +346,6 @@ class Fit(FitDeprecated):
|
||||
eos.db.commit()
|
||||
return mutator.value
|
||||
|
||||
@deprecated
|
||||
def addDrone(self, fitID, itemID, numDronesToAdd=1, recalc=True):
|
||||
pyfalog.debug("Adding {0} drones ({1}) to fit ID: {2}", numDronesToAdd, itemID, fitID)
|
||||
if fitID is None:
|
||||
return False
|
||||
|
||||
fit = eos.db.getFit(fitID)
|
||||
item = eos.db.getItem(itemID, eager=("attributes", "group.category"))
|
||||
if item.category.name == "Drone":
|
||||
drone = None
|
||||
for d in fit.drones.find(item):
|
||||
if d is not None and d.amountActive == 0 and d.amount < max(5, fit.extraAttributes["maxActiveDrones"]):
|
||||
drone = d
|
||||
break
|
||||
|
||||
if drone is None:
|
||||
drone = es_Drone(item)
|
||||
if drone.fits(fit) is True:
|
||||
fit.drones.append(drone)
|
||||
else:
|
||||
return False
|
||||
drone.amount += numDronesToAdd
|
||||
eos.db.commit()
|
||||
if recalc:
|
||||
self.recalc(fit)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def toggleRestrictionIgnore(self, fitID):
|
||||
pyfalog.debug("Toggling restriction ignore for fit ID: {0}", fitID)
|
||||
fit = eos.db.getFit(fitID)
|
||||
|
||||
Reference in New Issue
Block a user