fix(api): correct NexusArmorSet parser for actual API structure
- Fixed field name: API uses 'Armors' not 'Pieces' - Fixed protection location: API uses 'Defense' not per-piece protection - Armors is array of arrays, now properly flattened - Added set bonus parsing from EffectsOnSetEquip
This commit is contained in:
parent
f2d1162d27
commit
4375a00f0f
|
|
@ -265,28 +265,44 @@ class NexusArmorSet(NexusItem):
|
||||||
def from_api(cls, data: Dict[str, Any]) -> "NexusArmorSet":
|
def from_api(cls, data: Dict[str, Any]) -> "NexusArmorSet":
|
||||||
"""Create from API response."""
|
"""Create from API response."""
|
||||||
props = data.get('Properties', {})
|
props = data.get('Properties', {})
|
||||||
pieces = data.get('Pieces', []) or []
|
|
||||||
|
# Get pieces from 'Armors' field (array of arrays)
|
||||||
# Calculate total protection from pieces
|
armors_data = data.get('Armors', []) or []
|
||||||
protection = ProtectionProfile()
|
pieces = []
|
||||||
for piece_data in pieces:
|
for armor_group in armors_data:
|
||||||
prot = piece_data.get('Protection', {})
|
if isinstance(armor_group, list):
|
||||||
protection.impact += safe_decimal(prot.get('Impact'))
|
for armor in armor_group:
|
||||||
protection.cut += safe_decimal(prot.get('Cut'))
|
pieces.append(armor.get('Name', ''))
|
||||||
protection.stab += safe_decimal(prot.get('Stab'))
|
elif isinstance(armor_group, dict):
|
||||||
protection.burn += safe_decimal(prot.get('Burn'))
|
pieces.append(armor_group.get('Name', ''))
|
||||||
protection.cold += safe_decimal(prot.get('Cold'))
|
|
||||||
protection.acid += safe_decimal(prot.get('Acid'))
|
# Get total protection from 'Defense' field
|
||||||
protection.electric += safe_decimal(prot.get('Electric'))
|
defense = props.get('Defense', {})
|
||||||
|
protection = ProtectionProfile(
|
||||||
|
impact=safe_decimal(defense.get('Impact')),
|
||||||
|
cut=safe_decimal(defense.get('Cut')),
|
||||||
|
stab=safe_decimal(defense.get('Stab')),
|
||||||
|
burn=safe_decimal(defense.get('Burn')),
|
||||||
|
cold=safe_decimal(defense.get('Cold')),
|
||||||
|
acid=safe_decimal(defense.get('Acid')),
|
||||||
|
electric=safe_decimal(defense.get('Electric')),
|
||||||
|
)
|
||||||
|
|
||||||
|
# Get set bonus from EffectsOnSetEquip
|
||||||
|
set_bonus = None
|
||||||
|
effects = data.get('EffectsOnSetEquip', [])
|
||||||
|
if effects:
|
||||||
|
# Join all effects into a string
|
||||||
|
set_bonus = "; ".join([str(e) for e in effects])
|
||||||
|
|
||||||
return cls(
|
return cls(
|
||||||
id=data.get('Id', 0),
|
id=data.get('Id', 0),
|
||||||
name=data.get('Name', 'Unknown'),
|
name=data.get('Name', 'Unknown'),
|
||||||
item_id=str(data.get('Id', 0)),
|
item_id=str(data.get('Id', 0)),
|
||||||
category='armorset',
|
category='armorset',
|
||||||
pieces=[p.get('Name', '') for p in pieces],
|
pieces=pieces,
|
||||||
total_protection=protection,
|
total_protection=protection,
|
||||||
set_bonus=props.get('SetBonus'),
|
set_bonus=set_bonus,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue