Skip to content

Commit 01eb7e3

Browse files
committed
Add minAttributeID processing
1 parent c07f8d8 commit 01eb7e3

3 files changed

Lines changed: 44 additions & 17 deletions

File tree

eos/db/gamedata/attribute.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
Column("attributeID", Integer, primary_key=True),
3434
Column("attributeName", String),
3535
Column("defaultValue", Float),
36+
Column("minAttributeID", Integer, ForeignKey("dgmattribs.attributeID")),
3637
Column("maxAttributeID", Integer, ForeignKey("dgmattribs.attributeID")),
3738
Column("description", Unicode),
3839
Column("published", Boolean),

eos/modifiedAttributeDict.py

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929

3030

3131
defaultValuesCache = {}
32-
cappingAttrKeyCache = {}
32+
minLimitAttrKeyCache = {}
33+
maxLimitAttrKeyCache = {}
3334
resistanceCache = {}
3435

3536

@@ -307,34 +308,57 @@ def __len__(self):
307308

308309
def __calculateValue(self, key, extraMultipliers=None, preIncAdj=None, multAdj=None, postIncAdj=None, ignorePenMult=None):
309310
# It's possible that various attributes are capped by other attributes,
310-
# it's defined by reference maxAttributeID
311+
# it's defined by reference min/maxAttributeID
312+
# Min
311313
try:
312-
cappingKey = cappingAttrKeyCache[key]
314+
minLimitKey = minLimitAttrKeyCache[key]
313315
except KeyError:
314316
attrInfo = getAttributeInfo(key)
315317
if attrInfo is None:
316-
cappingId = cappingAttrKeyCache[key] = None
318+
cappingId = minLimitAttrKeyCache[key] = None
319+
else:
320+
cappingId = attrInfo.minAttributeID
321+
if cappingId is None:
322+
minLimitKey = None
323+
else:
324+
cappingAttrInfo = getAttributeInfo(cappingId)
325+
minLimitKey = None if cappingAttrInfo is None else cappingAttrInfo.name
326+
minLimitAttrKeyCache[key] = minLimitKey
327+
if minLimitKey:
328+
minLimitValue = self[minLimitKey]
329+
minLimitValue = minLimitValue.value if hasattr(minLimitValue, "value") else minLimitValue
330+
else:
331+
minLimitValue = None
332+
# Max
333+
try:
334+
maxLimitKey = maxLimitAttrKeyCache[key]
335+
except KeyError:
336+
attrInfo = getAttributeInfo(key)
337+
if attrInfo is None:
338+
cappingId = maxLimitAttrKeyCache[key] = None
317339
else:
318340
cappingId = attrInfo.maxAttributeID
319341
if cappingId is None:
320-
cappingKey = None
342+
maxLimitKey = None
321343
else:
322344
cappingAttrInfo = getAttributeInfo(cappingId)
323-
cappingKey = None if cappingAttrInfo is None else cappingAttrInfo.name
324-
cappingAttrKeyCache[key] = cappingKey
345+
maxLimitKey = None if cappingAttrInfo is None else cappingAttrInfo.name
346+
maxLimitAttrKeyCache[key] = maxLimitKey
325347

326-
if cappingKey:
327-
cappingValue = self[cappingKey]
328-
cappingValue = cappingValue.value if hasattr(cappingValue, "value") else cappingValue
348+
if maxLimitKey:
349+
maxLimitValue = self[maxLimitKey]
350+
maxLimitValue = maxLimitValue.value if hasattr(maxLimitValue, "value") else maxLimitValue
329351
else:
330-
cappingValue = None
352+
maxLimitValue = None
331353

332354
# If value is forced, we don't have to calculate anything,
333355
# just return forced value instead
334356
force = self.__forced[key] if key in self.__forced else None
335357
if force is not None:
336-
if cappingValue is not None:
337-
force = min(force, cappingValue)
358+
if minLimitValue is not None:
359+
force = max(force, minLimitValue)
360+
if maxLimitValue is not None:
361+
force = min(force, maxLimitValue)
338362
if key in ("cpu", "power", "cpuOutput", "powerOutput"):
339363
force = round(force, 2)
340364
return force
@@ -409,8 +433,10 @@ def __calculateValue(self, key, extraMultipliers=None, preIncAdj=None, multAdj=N
409433
val += postIncAdj
410434

411435
# Cap value if we have cap defined
412-
if cappingValue is not None:
413-
val = min(val, cappingValue)
436+
if minLimitValue is not None:
437+
val = max(val, minLimitValue)
438+
if maxLimitValue is not None:
439+
val = min(val, maxLimitValue)
414440
if key in ("cpu", "power", "cpuOutput", "powerOutput"):
415441
val = round(val, 2)
416442
return val

eos/saveddata/ship.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import eos.db
2323
from eos.effectHandlerHelpers import HandledItem
24-
from eos.modifiedAttributeDict import ModifiedAttributeDict, ItemAttrShortcut, cappingAttrKeyCache
24+
from eos.modifiedAttributeDict import ModifiedAttributeDict, ItemAttrShortcut, maxLimitAttrKeyCache
2525
from eos.saveddata.mode import Mode
2626

2727
pyfalog = Logger(__name__)
@@ -55,7 +55,7 @@ def __init__(self, item, owner=None):
5555
self.__itemModifiedAttributes.overrides = self.item.overrides
5656

5757
if "maximumRangeCap" in self.__itemModifiedAttributes.original:
58-
cappingAttrKeyCache["maxTargetRange"] = "maximumRangeCap"
58+
maxLimitAttrKeyCache["maxTargetRange"] = "maximumRangeCap"
5959

6060
self.owner = owner
6161
self.commandBonus = 0

0 commit comments

Comments
 (0)