diff --git a/ui/main_window.py b/ui/main_window.py index dc4a626..d0d1936 100644 --- a/ui/main_window.py +++ b/ui/main_window.py @@ -1008,13 +1008,16 @@ class MainWindow(QMainWindow): # Estimate cost per shot based on weapon stats if self._selected_weapon_stats: - # Rough estimate: if we know DPP and damage, we can estimate cost dpp = self._selected_weapon_stats.get('dpp', 0) - if dpp > 0: + if dpp and dpp > 0: # Cost per shot in PEC = damage / DPP - cost_pec = damage / dpp - cost_ped = cost_pec / 100 # Convert to PED - self.hud.update_cost(Decimal(str(cost_ped))) + # Convert to Decimal for precision + from decimal import Decimal + damage_dec = Decimal(str(damage)) + dpp_dec = Decimal(str(dpp)) + cost_pec = damage_dec / dpp_dec + cost_ped = cost_pec / Decimal('100') # Convert to PED + self.hud.update_cost(cost_ped) def on_critical_hit(event): """Handle critical hit - same as damage dealt."""