fix: correct kill counting logic
- Remove separate update_kills() call from on_loot handler - Let update_loot() handle kill counting internally - Only increment kills when >2 second gap since last loot - Add is_new_kill flag to track new mobs vs multi-item drops - Add debug logging for kill counting
This commit is contained in:
parent
4db34c2c2c
commit
fe0858ebfa
|
|
@ -854,6 +854,7 @@ class HUDOverlay(QWidget):
|
||||||
logger.debug(f"[HUD] update_loot called: value={value_ped}, is_shrapnel={is_shrapnel}, session_active={self.session_active}")
|
logger.debug(f"[HUD] update_loot called: value={value_ped}, is_shrapnel={is_shrapnel}, session_active={self.session_active}")
|
||||||
if self.session_active:
|
if self.session_active:
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
|
is_new_kill = False
|
||||||
|
|
||||||
# Check if this is a new kill (gap of >2 seconds since last loot)
|
# Check if this is a new kill (gap of >2 seconds since last loot)
|
||||||
if self._stats._last_loot_time is not None:
|
if self._stats._last_loot_time is not None:
|
||||||
|
|
@ -864,15 +865,22 @@ class HUDOverlay(QWidget):
|
||||||
self._stats.highest_loot = self._stats._current_kill_loot
|
self._stats.highest_loot = self._stats._current_kill_loot
|
||||||
# Start new kill
|
# Start new kill
|
||||||
self._stats._current_kill_loot = value_ped
|
self._stats._current_kill_loot = value_ped
|
||||||
|
is_new_kill = True
|
||||||
else:
|
else:
|
||||||
# Same kill, add to current
|
# Same kill, add to current
|
||||||
self._stats._current_kill_loot += value_ped
|
self._stats._current_kill_loot += value_ped
|
||||||
else:
|
else:
|
||||||
# First loot of session
|
# First loot of session - this is a new kill
|
||||||
self._stats._current_kill_loot = value_ped
|
self._stats._current_kill_loot = value_ped
|
||||||
|
is_new_kill = True
|
||||||
|
|
||||||
self._stats._last_loot_time = now
|
self._stats._last_loot_time = now
|
||||||
|
|
||||||
|
# Only count kill if it's a new mob
|
||||||
|
if is_new_kill:
|
||||||
|
self._stats.kills += 1
|
||||||
|
logger.debug(f"[HUD] New kill counted! Total kills: {self._stats.kills}")
|
||||||
|
|
||||||
# Add to totals
|
# Add to totals
|
||||||
if is_shrapnel:
|
if is_shrapnel:
|
||||||
self._stats.shrapnel_total += value_ped
|
self._stats.shrapnel_total += value_ped
|
||||||
|
|
@ -880,8 +888,8 @@ class HUDOverlay(QWidget):
|
||||||
self._stats.loot_other += value_ped
|
self._stats.loot_other += value_ped
|
||||||
|
|
||||||
self._stats.recalculate()
|
self._stats.recalculate()
|
||||||
# Emit signal to refresh on main thread instead of calling directly
|
|
||||||
self._request_refresh()
|
self._request_refresh()
|
||||||
|
logger.debug(f"[HUD] update_loot complete: kills={self._stats.kills}, shrapnel={self._stats.shrapnel_total}, other={self._stats.loot_other}")
|
||||||
logger.debug(f"[HUD] update_loot complete: shrapnel={self._stats.shrapnel_total}, other={self._stats.loot_other}")
|
logger.debug(f"[HUD] update_loot complete: shrapnel={self._stats.shrapnel_total}, other={self._stats.loot_other}")
|
||||||
|
|
||||||
def update_shrapnel(self, amount: Decimal):
|
def update_shrapnel(self, amount: Decimal):
|
||||||
|
|
|
||||||
|
|
@ -1075,11 +1075,7 @@ class MainWindow(QMainWindow):
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Update kill count (each loot event = 1 kill)
|
# Update loot value - this also handles kill counting internally
|
||||||
logger.debug(f"[HUD] update_kills(1)")
|
|
||||||
self.hud.update_kills(1)
|
|
||||||
|
|
||||||
# Update loot value
|
|
||||||
is_shrapnel = 'shrapnel' in item_name.lower()
|
is_shrapnel = 'shrapnel' in item_name.lower()
|
||||||
logger.debug(f"[HUD] update_loot({value_ped}, is_shrapnel={is_shrapnel})")
|
logger.debug(f"[HUD] update_loot({value_ped}, is_shrapnel={is_shrapnel})")
|
||||||
self.hud.update_loot(value_ped, is_shrapnel=is_shrapnel)
|
self.hud.update_loot(value_ped, is_shrapnel=is_shrapnel)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue