diff --git a/core/nexus_full_api.py b/core/nexus_full_api.py index 5b958a2..b40f935 100644 --- a/core/nexus_full_api.py +++ b/core/nexus_full_api.py @@ -265,28 +265,44 @@ class NexusArmorSet(NexusItem): def from_api(cls, data: Dict[str, Any]) -> "NexusArmorSet": """Create from API response.""" props = data.get('Properties', {}) - pieces = data.get('Pieces', []) or [] - - # Calculate total protection from pieces - protection = ProtectionProfile() - for piece_data in pieces: - prot = piece_data.get('Protection', {}) - protection.impact += safe_decimal(prot.get('Impact')) - protection.cut += safe_decimal(prot.get('Cut')) - protection.stab += safe_decimal(prot.get('Stab')) - protection.burn += safe_decimal(prot.get('Burn')) - protection.cold += safe_decimal(prot.get('Cold')) - protection.acid += safe_decimal(prot.get('Acid')) - protection.electric += safe_decimal(prot.get('Electric')) + + # Get pieces from 'Armors' field (array of arrays) + armors_data = data.get('Armors', []) or [] + pieces = [] + for armor_group in armors_data: + if isinstance(armor_group, list): + for armor in armor_group: + pieces.append(armor.get('Name', '')) + elif isinstance(armor_group, dict): + pieces.append(armor_group.get('Name', '')) + + # Get total protection from 'Defense' field + 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( id=data.get('Id', 0), name=data.get('Name', 'Unknown'), item_id=str(data.get('Id', 0)), category='armorset', - pieces=[p.get('Name', '') for p in pieces], + pieces=pieces, total_protection=protection, - set_bonus=props.get('SetBonus'), + set_bonus=set_bonus, )