fix(api): use armor set's total protection for each piece

- API returns 0 protection for individual armor pieces
- Protection values are only at the armor set level (Defense field)
- Now each piece gets the full set protection values assigned
- Removed equip_full_set call with wrong type (NexusArmorSet vs ArmorSet)
- Individual pieces now have correct protection for calculations
This commit is contained in:
LemonNexus 2026-02-09 19:16:55 +00:00
parent 437f6b3027
commit 22b4e6e8bb
1 changed files with 18 additions and 11 deletions

View File

@ -1660,6 +1660,9 @@ class LoadoutManagerDialog(QDialog):
pieces_found = 0
pieces_not_found = []
# Store the full set for protection calculations
self.current_armor_set = armor_set
# Try to find each piece in the set
for piece_name in armor_set.pieces:
# Find the armor in the API results
@ -1704,19 +1707,22 @@ class LoadoutManagerDialog(QDialog):
if slot_widget:
# Create ArmorPiece from NexusArmor
# Use the SET'S protection values, not individual piece (which are 0 in API)
from core.armor_system import ArmorPiece
piece = ArmorPiece(
item_id=matching_armor.item_id,
name=matching_armor.name,
slot=self._get_slot_from_type(armor_type) if armor_type in slot_mapping else self._get_slot_from_name(piece_name),
# Use armor set's total protection for each piece
# In EU, protection comes from the full set, not individual pieces
protection=ProtectionProfile(
impact=matching_armor.protection_impact,
cut=matching_armor.protection_cut,
stab=matching_armor.protection_stab,
burn=matching_armor.protection_burn,
cold=matching_armor.protection_cold,
acid=matching_armor.protection_acid,
electric=matching_armor.protection_electric,
impact=armor_set.total_protection.impact,
cut=armor_set.total_protection.cut,
stab=armor_set.total_protection.stab,
burn=armor_set.total_protection.burn,
cold=armor_set.total_protection.cold,
acid=armor_set.total_protection.acid,
electric=armor_set.total_protection.electric,
),
durability=matching_armor.durability,
decay_per_hp=Decimal("0.05") * (Decimal(1) - Decimal(matching_armor.durability) / Decimal("100000"))
@ -2181,9 +2187,10 @@ class LoadoutManagerDialog(QDialog):
equipped.equip_piece(piece_copy)
# Set full set if all pieces match
if self.current_armor_set:
equipped.equip_full_set(self.current_armor_set)
# Note: We don't call equip_full_set here because:
# 1. current_armor_set is a NexusArmorSet (API type), not ArmorSet (core type)
# 2. Individual pieces already have the full set protection values stored on them
# 3. The EquippedArmor.get_total_protection() will sum up pieces correctly
return LoadoutConfig(
name=self.loadout_name_edit.text().strip() or "Unnamed",