fix(hud): fix Decimal/float division error in cost calculation

- Convert both damage and dpp to Decimal before division
- Proper Decimal arithmetic for precision
This commit is contained in:
LemonNexus 2026-02-08 23:28:44 +00:00
parent 445d0bb6f3
commit 0a12b22498
1 changed files with 8 additions and 5 deletions

View File

@ -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."""