fix: add new armor fields to LoadoutConfig and fix label references

- Added current_armor_set_name, current_armor_pieces, current_armor_protection, current_armor_decay to LoadoutConfig
- Fixed armor_set_label reference to use armor_summary_label
- Added hasattr checks for backward compatibility with old save files
This commit is contained in:
LemonNexus 2026-02-09 21:06:39 +00:00
parent 67eaf2d6a7
commit 877ee96bcc
1 changed files with 10 additions and 4 deletions

View File

@ -158,6 +158,12 @@ class LoadoutConfig:
# Format: {tier_number: enhancer}
enhancers: Dict[int, 'NexusEnhancer'] = field(default_factory=dict)
# New Armor System (API-based)
current_armor_set_name: str = "None"
current_armor_pieces: List[Any] = field(default_factory=list)
current_armor_protection: ProtectionProfile = field(default_factory=ProtectionProfile)
current_armor_decay: Decimal = Decimal("0")
# Settings
shots_per_hour: int = 3600
hits_per_hour: int = 720
@ -214,7 +220,7 @@ class LoadoutConfig:
def get_armor_decay_per_hit(self) -> Decimal:
"""Calculate armor decay cost per hit taken (in PED)."""
# Use new armor system if available
if self.current_armor_decay > 0:
if hasattr(self, 'current_armor_decay') and self.current_armor_decay > 0:
return self.current_armor_decay
# Legacy fallback
@ -287,7 +293,7 @@ class LoadoutConfig:
def get_total_protection(self) -> ProtectionProfile:
"""Get total protection from equipped armor."""
# Use new armor system if available
if self.current_armor_protection.get_total() > 0:
if hasattr(self, 'current_armor_protection') and self.current_armor_protection.get_total() > 0:
return self.current_armor_protection
# Legacy fallback
@ -1672,7 +1678,7 @@ class LoadoutManagerDialog(QDialog):
self.current_armor_decay = data['total_decay_per_hit']
# Update UI
self.armor_set_label.setText(f"{data['name']}")
self.armor_summary_label.setText(f"{data['name']}")
self.protection_summary_label.setText(
f"Total: {data['total_protection'].get_total():.1f} | Decay: {data['total_decay_per_hit']:.4f}/hit"
)
@ -1701,7 +1707,7 @@ class LoadoutManagerDialog(QDialog):
self.current_armor_decay = total_decay
# Update UI
self.armor_set_label.setText(f"✓ Custom ({len(pieces)} pieces)")
self.armor_summary_label.setText(f"✓ Custom ({len(pieces)} pieces)")
self.protection_summary_label.setText(
f"Total: {total_prot.get_total():.1f} | Decay: {total_decay:.4f}/hit"
)