MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / getExtended

Method getExtended

eos/modifiedAttributeDict.py:209–259  ·  view source on GitHub ↗

Here we consider couple of parameters. If they affect final result, we do not store result, and if they are - we do.

(self, key, extraMultipliers=None, ignoreAfflictors=None, default=0)

Source from the content-addressed store, hash-verified

207 return self.getOriginal(key)
208
209 def getExtended(self, key, extraMultipliers=None, ignoreAfflictors=None, default=0):
210 """
211 Here we consider couple of parameters. If they affect final result, we do
212 not store result, and if they are - we do.
213 """
214 # Here we do not have support for preAssigns/forceds, as doing them would
215 # mean that we have to store all of them in a list which increases memory use,
216 # and we do not actually need those operators atm
217 preIncreaseAdjustment = 0
218 multiplierAdjustment = 1
219 ignorePenalizedMultipliers = {}
220 postIncreaseAdjustment = 0
221 for fit, afflictors in self.getAfflictions(key).items():
222 for afflictor, operator, stackingGroup, preResAmount, postResAmount, used in afflictors:
223 if afflictor in ignoreAfflictors:
224 if operator == Operator.MULTIPLY:
225 if stackingGroup is None:
226 multiplierAdjustment /= postResAmount
227 else:
228 ignorePenalizedMultipliers.setdefault(stackingGroup, []).append(postResAmount)
229 elif operator == Operator.PREINCREASE:
230 preIncreaseAdjustment -= postResAmount
231 elif operator == Operator.POSTINCREASE:
232 postIncreaseAdjustment -= postResAmount
233
234 # If we apply no customizations - use regular getter
235 if (
236 not extraMultipliers and
237 preIncreaseAdjustment == 0 and multiplierAdjustment == 1 and
238 postIncreaseAdjustment == 0 and len(ignorePenalizedMultipliers) == 0
239 ):
240 return self.get(key, default=default)
241
242 # Try to calculate custom values
243 val = self.__calculateValue(
244 key, extraMultipliers=extraMultipliers, preIncAdj=preIncreaseAdjustment, multAdj=multiplierAdjustment,
245 postIncAdj=postIncreaseAdjustment, ignorePenMult=ignorePenalizedMultipliers)
246 if val is not None:
247 return val
248
249 # Then the same fallbacks as in regular getter
250 if self.__intermediary:
251 val = self.__intermediary.get(key)
252 else:
253 val = None
254 if val is not None:
255 return val
256 val = self.getOriginal(key)
257 if val is not None:
258 return val
259 return default
260
261 def __delitem__(self, key):
262 if key in self.__modified:

Calls 6

getAfflictionsMethod · 0.95
__calculateValueMethod · 0.95
getOriginalMethod · 0.95
itemsMethod · 0.80
appendMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected