fix(api): correct healing tools parser to use MaxHeal/MinHeal fields
API uses MaxHeal and MinHeal directly in Properties (not nested Heal object). Parser now correctly reads heal amounts and calculates economy. Also added type detection for chips vs FAPs based on item name.
This commit is contained in:
parent
09e07984a0
commit
cdadb7f081
|
|
@ -215,13 +215,28 @@ class NexusHealingTool(NexusItem):
|
|||
def from_api(cls, data: Dict[str, Any]) -> "NexusHealingTool":
|
||||
"""Create from API response."""
|
||||
props = data.get('Properties', {})
|
||||
economy = props.get('Economy', {})
|
||||
heal = props.get('Heal', {})
|
||||
|
||||
economy = props.get('Economy', {}) or {}
|
||||
|
||||
decay = safe_decimal(economy.get('Decay'))
|
||||
heal_amount = safe_decimal(heal.get('Amount'))
|
||||
# API uses MaxHeal/MinHeal directly in Properties, not nested Heal object
|
||||
max_heal = safe_decimal(props.get('MaxHeal'))
|
||||
min_heal = safe_decimal(props.get('MinHeal'))
|
||||
# Use average of min/max heal, or max if min is 0
|
||||
heal_amount = (max_heal + min_heal) / 2 if min_heal > 0 else max_heal
|
||||
if heal_amount == 0:
|
||||
heal_amount = max_heal # Fallback to max heal
|
||||
|
||||
heal_per_pec = heal_amount / decay if decay > 0 else Decimal('0')
|
||||
|
||||
|
||||
# Determine type based on name or properties
|
||||
name = data.get('Name', '').lower()
|
||||
if 'chip' in name or 'restoration' in name:
|
||||
tool_type = 'chip'
|
||||
elif 'pack' in name or 'fap' in name:
|
||||
tool_type = 'pack'
|
||||
else:
|
||||
tool_type = 'fap'
|
||||
|
||||
return cls(
|
||||
id=data.get('Id', 0),
|
||||
name=data.get('Name', 'Unknown'),
|
||||
|
|
@ -230,7 +245,7 @@ class NexusHealingTool(NexusItem):
|
|||
heal_amount=heal_amount,
|
||||
decay=decay,
|
||||
heal_per_pec=heal_per_pec,
|
||||
type=props.get('Type', 'fap'),
|
||||
type=tool_type,
|
||||
profession_level=int(props.get('RequiredLevel', 0) or 0),
|
||||
is_limited='(L)' in data.get('Name', ''),
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue