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:
parent
445d0bb6f3
commit
0a12b22498
|
|
@ -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."""
|
||||
|
|
|
|||
Loading…
Reference in New Issue