fix(hud): correct cost calculation using weapon decay from Nexus API
- Use actual weapon decay (PEC) from API instead of broken DPP calculation - Add decay and ammo_burn to weapon stats passed from Gear Selector - Cost per shot = decay (in PEC) / 100 = PED
This commit is contained in:
parent
0a12b22498
commit
3a3e389f05
|
|
@ -292,8 +292,13 @@ class GearSelectorDialog(QDialog):
|
||||||
if self.gear_type == "weapon":
|
if self.gear_type == "weapon":
|
||||||
w = self.selected_gear
|
w = self.selected_gear
|
||||||
self.gear_selected.emit("weapon", w.name, {
|
self.gear_selected.emit("weapon", w.name, {
|
||||||
'id': w.id, 'item_id': w.item_id, 'dpp': float(w.dpp),
|
'id': w.id,
|
||||||
'cost_per_hour': float(w.cost_per_hour), 'total_damage': float(w.total_damage),
|
'item_id': w.item_id,
|
||||||
|
'dpp': float(w.dpp),
|
||||||
|
'cost_per_hour': float(w.cost_per_hour),
|
||||||
|
'total_damage': float(w.total_damage),
|
||||||
|
'decay': float(w.decay) if w.decay else 0,
|
||||||
|
'ammo_burn': w.ammo_burn or 0,
|
||||||
})
|
})
|
||||||
elif self.gear_type == "armor":
|
elif self.gear_type == "armor":
|
||||||
a = self.selected_gear
|
a = self.selected_gear
|
||||||
|
|
|
||||||
|
|
@ -1006,17 +1006,15 @@ class MainWindow(QMainWindow):
|
||||||
damage = event.data.get('damage', 0)
|
damage = event.data.get('damage', 0)
|
||||||
self.hud.on_damage_dealt(float(damage))
|
self.hud.on_damage_dealt(float(damage))
|
||||||
|
|
||||||
# Estimate cost per shot based on weapon stats
|
# Track weapon decay cost per shot
|
||||||
|
# Only count as one shot fired per damage event
|
||||||
if self._selected_weapon_stats:
|
if self._selected_weapon_stats:
|
||||||
dpp = self._selected_weapon_stats.get('dpp', 0)
|
# Get decay per shot from weapon stats (in PEC)
|
||||||
if dpp and dpp > 0:
|
decay = self._selected_weapon_stats.get('decay', 0)
|
||||||
# Cost per shot in PEC = damage / DPP
|
if decay:
|
||||||
# Convert to Decimal for precision
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
damage_dec = Decimal(str(damage))
|
# Convert PEC to PED
|
||||||
dpp_dec = Decimal(str(dpp))
|
cost_ped = Decimal(str(decay)) / Decimal('100')
|
||||||
cost_pec = damage_dec / dpp_dec
|
|
||||||
cost_ped = cost_pec / Decimal('100') # Convert to PED
|
|
||||||
self.hud.update_cost(cost_ped)
|
self.hud.update_cost(cost_ped)
|
||||||
|
|
||||||
def on_critical_hit(event):
|
def on_critical_hit(event):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue