From 877ee96bcc938523c66c86e72ff64cfa230a23cc Mon Sep 17 00:00:00 2001 From: LemonNexus Date: Mon, 9 Feb 2026 21:06:39 +0000 Subject: [PATCH] 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 --- ui/loadout_manager.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ui/loadout_manager.py b/ui/loadout_manager.py index 830148e..556c87a 100644 --- a/ui/loadout_manager.py +++ b/ui/loadout_manager.py @@ -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" )