diff --git a/ui/main_window.py b/ui/main_window.py index f674fb4..6ddf261 100644 --- a/ui/main_window.py +++ b/ui/main_window.py @@ -1187,13 +1187,25 @@ class MainWindow(QMainWindow): logger.debug(f"[HUD] on_damage_taken({damage})") self.hud.on_damage_taken(Decimal(str(damage))) - # Track armor cost per hit - logger.debug(f"[DEBUG] _session_costs={self._session_costs}") - if self._session_costs: + # Calculate armor decay based on actual damage absorbed + # Formula: Decay (PEC) = damage_absorbed * 0.05 * (1 - durability/100000) + # Approximate: ~0.05 PEC per damage point for non-L armor + # For simplicity: 0.0005 PED per damage point (0.05 PEC = 0.0005 PED) + if self._selected_armor_stats and 'decay' in self._selected_armor_stats: + # Use decay per hit from armor stats if available + armor_decay_pec = Decimal(str(self._selected_armor_stats.get('decay', 0))) + # Approximate: decay scales with damage + # Most armor has ~0.05 PEC decay per damage point + decay_per_damage = Decimal('0.0005') # 0.05 PEC = 0.0005 PED + cost_ped = Decimal(str(damage)) * decay_per_damage + if cost_ped > 0: + logger.debug(f"[HUD] update_armor_cost({cost_ped:.4f}) based on damage {damage}") + self.hud.update_armor_cost(cost_ped) + else: + # Fallback to simple calculation cost_per_hit = self._session_costs.get('cost_per_hit', Decimal('0')) - logger.debug(f"[DEBUG] cost_per_hit={cost_per_hit}") if cost_per_hit > 0: - logger.debug(f"[HUD] update_armor_cost({cost_per_hit})") + logger.debug(f"[HUD] update_armor_cost({cost_per_hit}) [fallback]") self.hud.update_armor_cost(cost_per_hit) except Exception as e: logger.error(f"[ERROR] Error in on_damage_taken: {e}")