Rework various RR-related functionality to use new API

This commit is contained in:
DarkPhoenix
2019-08-16 23:58:07 +03:00
parent 4594f57961
commit ae1a5f4e44
6 changed files with 84 additions and 132 deletions

View File

@@ -69,7 +69,6 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
self.__charge = None
self.__baseVolley = None
self.__baseRRAmount = None
self.__baseRemoteReps = None
self.__miningyield = None
self.__itemModifiedAttributes = ModifiedAttributeDict()
self.__itemModifiedAttributes.original = self.__item.attributes
@@ -191,47 +190,36 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
armorAmount = self.getModifiedItemAttr("armorDamageAmount", 0)
shieldAmount = self.getModifiedItemAttr("shieldBonus", 0)
if shieldAmount:
self.__baseRRAmount[0] = RRTypes(shield=shieldAmount, armor=0, hull=0, capacitor=0)
self.__baseRRAmount[0] = RRTypes(
shield=shieldAmount * self.amountActive,
armor=0, hull=0, capacitor=0)
if armorAmount or hullAmount:
self.__baseRRAmount[self.cycleTime] = RRTypes(shield=shieldAmount, armor=0, hull=0, capacitor=0)
self.__baseRRAmount[self.cycleTime] = RRTypes(
shield=0, armor=armorAmount * self.amountActive,
hull=hullAmount * self.amountActive, capacitor=0)
return self.__baseRRAmount
def getRemoteReps(self, ignoreState=False):
rrDuringCycle = RRTypes(0, 0, 0, 0)
cycleParams = self.getCycleParameters()
if cycleParams is None:
return rrDuringCycle
repAmountParams = self.getRepAmountParameters()
avgCycleTime = cycleParams.averageTime
if len(repAmountParams) == 0 or avgCycleTime == 0:
return rrDuringCycle
for rrAmount in repAmountParams.values():
rrDuringCycle += rrAmount
rrFactor = 1 / (avgCycleTime / 1000)
rrDuringCycle *= rrFactor
return rrDuringCycle
def getCycleParameters(self, reloadOverride=None):
cycleTime = self.cycleTime
if cycleTime == 0:
return None
return CycleInfo(self.cycleTime, 0, math.inf)
def getRemoteReps(self, ignoreState=False):
if self.amountActive <= 0 and not ignoreState:
return (None, 0)
if self.__baseRemoteReps is None:
rrShield = self.getModifiedItemAttr("shieldBonus", 0)
rrArmor = self.getModifiedItemAttr("armorDamageAmount", 0)
rrHull = self.getModifiedItemAttr("structureDamageAmount", 0)
if rrShield:
rrType = "Shield"
rrAmount = rrShield
elif rrArmor:
rrType = "Armor"
rrAmount = rrArmor
elif rrHull:
rrType = "Hull"
rrAmount = rrHull
else:
rrType = None
rrAmount = 0
if rrAmount:
droneAmount = self.amount if ignoreState else self.amountActive
cycleParams = self.getCycleParameters()
if cycleParams is None:
rrType = None
rrAmount = 0
else:
rrAmount *= droneAmount / (cycleParams.averageTime / 1000)
self.__baseRemoteReps = (rrType, rrAmount)
return self.__baseRemoteReps
@property
def miningStats(self):
if self.__miningyield is None:
@@ -292,7 +280,7 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
def clear(self):
self.__baseVolley = None
self.__baseRemoteReps = None
self.__baseRRAmount = None
self.__miningyield = None
self.itemModifiedAttributes.clear()
self.chargeModifiedAttributes.clear()

View File

@@ -36,7 +36,7 @@ from eos.saveddata.character import Character
from eos.saveddata.citadel import Citadel
from eos.saveddata.module import Module
from eos.saveddata.ship import Ship
from eos.utils.stats import DmgTypes
from eos.utils.stats import DmgTypes, RRTypes
pyfalog = Logger(__name__)
@@ -1291,21 +1291,13 @@ class Fit:
def getRemoteReps(self, spoolOptions=None):
if spoolOptions not in self.__remoteRepMap:
remoteReps = {}
remoteReps = RRTypes(0, 0, 0, 0)
for module in self.modules:
rrType, rrAmount = module.getRemoteReps(spoolOptions=spoolOptions)
if rrType:
if rrType not in remoteReps:
remoteReps[rrType] = 0
remoteReps[rrType] += rrAmount
remoteReps += module.getRemoteReps(spoolOptions=spoolOptions)
for drone in self.drones:
rrType, rrAmount = drone.getRemoteReps()
if rrType:
if rrType not in remoteReps:
remoteReps[rrType] = 0
remoteReps[rrType] += rrAmount
remoteReps += drone.getRemoteReps()
self.__remoteRepMap[spoolOptions] = remoteReps

View File

@@ -135,7 +135,6 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
self.__baseVolley = None
self.__baseRRAmount = None
self.__baseRemoteReps = None
self.__miningyield = None
self.__reloadTime = None
self.__reloadForce = None
@@ -539,56 +538,19 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
return adjustedRRAmount
def getRemoteReps(self, spoolOptions=None, ignoreState=False):
if self.isEmpty or (self.state < FittingModuleState.ACTIVE and not ignoreState):
return None, 0
def getBaseRemoteReps(module):
remoteModuleGroups = {
"Remote Armor Repairer": "Armor",
"Ancillary Remote Armor Repairer": "Armor",
"Mutadaptive Remote Armor Repairer": "Armor",
"Remote Hull Repairer": "Hull",
"Remote Shield Booster": "Shield",
"Ancillary Remote Shield Booster": "Shield",
"Remote Capacitor Transmitter": "Capacitor"}
rrType = remoteModuleGroups.get(module.item.group.name, None)
if not rrType:
return None, 0
if rrType == "Hull":
rrAmount = module.getModifiedItemAttr("structureDamageAmount", 0)
elif rrType == "Armor":
rrAmount = module.getModifiedItemAttr("armorDamageAmount", 0)
elif rrType == "Shield":
rrAmount = module.getModifiedItemAttr("shieldBonus", 0)
elif rrType == "Capacitor":
rrAmount = module.getModifiedItemAttr("powerTransferAmount", 0)
else:
return None, 0
return rrType, rrAmount
if self.__baseRemoteReps is None:
self.__baseRemoteReps = getBaseRemoteReps(self)
rrType, rrAmount = self.__baseRemoteReps
if rrAmount:
cycleParams = self.getCycleParameters()
if cycleParams is None:
return None, 0
rrAmount *= 1 / (cycleParams.averageTime / 1000)
if self.item.group.name == "Ancillary Remote Armor Repairer" and self.charge:
rrAmount *= self.getModifiedItemAttr("chargedArmorDamageMultiplier", 1)
if rrType and rrAmount and self.item.group.name == "Mutadaptive Remote Armor Repairer":
spoolType, spoolAmount = resolveSpoolOptions(spoolOptions, self)
spoolBoost = calculateSpoolup(
self.getModifiedItemAttr("repairMultiplierBonusMax", 0),
self.getModifiedItemAttr("repairMultiplierBonusPerCycle", 0),
self.rawCycleTime / 1000, spoolType, spoolAmount)[0]
rrAmount *= (1 + spoolBoost)
return rrType, rrAmount
rrDuringCycle = RRTypes(0, 0, 0, 0)
cycleParams = self.getCycleParameters()
if cycleParams is None:
return rrDuringCycle
repAmountParams = self.getRepAmountParameters(spoolOptions=spoolOptions, ignoreState=ignoreState)
avgCycleTime = cycleParams.averageTime
if len(repAmountParams) == 0 or avgCycleTime == 0:
return rrDuringCycle
for rrAmount in repAmountParams.values():
rrDuringCycle += rrAmount
rrFactor = 1 / (avgCycleTime / 1000)
rrDuringCycle *= rrFactor
return rrDuringCycle
def getSpoolData(self, spoolOptions=None):
weaponMultMax = self.getModifiedItemAttr("damageMultiplierBonusMax", 0)
@@ -846,7 +808,6 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
def clear(self):
self.__baseVolley = None
self.__baseRRAmount = None
self.__baseRemoteReps = None
self.__miningyield = None
self.__reloadTime = None
self.__reloadForce = None