fix: track highest loot per-kill (sum of all items from one mob)

- Use time-based grouping: loot within 2 seconds = same kill
- Sum all items from a kill to calculate total loot value
- Update highest_loot when a kill is complete (gap > 2 sec)
- Initialize kill tracking fields on session start
- Check final kill on session stop
This commit is contained in:
LemonNexus 2026-02-09 23:05:05 +00:00
parent ad3003b808
commit e5c6878c6a
1 changed files with 38 additions and 5 deletions

View File

@ -113,7 +113,11 @@ class HUDStats:
loot_other: Decimal = Decimal('0.0') # Non-shrapnel loot
# Session records
highest_loot: Decimal = Decimal('0.0') # Highest single loot
highest_loot: Decimal = Decimal('0.0') # Highest total loot from single kill
# Kill tracking buffer
_current_kill_loot: Decimal = Decimal('0.0')
_last_loot_time: Optional[datetime] = None
# Cost metrics (core)
cost_per_shot: Decimal = Decimal('0.0')
@ -669,6 +673,11 @@ class HUDOverlay(QWidget):
self._stats.cost_per_shot = cost_per_shot
self._stats.cost_per_hit = cost_per_hit
self._stats.cost_per_heal = cost_per_heal
# Initialize kill tracking
self._stats._current_kill_loot = Decimal('0.0')
self._stats._last_loot_time = None
self.session_active = True
self._timer.start(1000)
@ -682,6 +691,11 @@ class HUDOverlay(QWidget):
def stop_session(self) -> None:
"""Stop the current session."""
# Check if current kill is highest before stopping
if self._stats._current_kill_loot > self._stats.highest_loot:
self._stats.highest_loot = self._stats._current_kill_loot
self._refresh_display()
self.session_active = False
self._timer.stop()
self.status_label.setText("● Stopped")
@ -772,15 +786,34 @@ class HUDOverlay(QWidget):
# === Public Update Methods ===
def update_loot(self, value_ped: Decimal, is_shrapnel: bool = False):
"""Update loot value."""
"""Update loot value - tracks per-kill totals for highest loot."""
if self.session_active:
now = datetime.now()
# Check if this is a new kill (gap of >2 seconds since last loot)
if self._stats._last_loot_time is not None:
time_since_last = (now - self._stats._last_loot_time).total_seconds()
if time_since_last > 2.0:
# Previous kill is complete, check if it was highest
if self._stats._current_kill_loot > self._stats.highest_loot:
self._stats.highest_loot = self._stats._current_kill_loot
# Start new kill
self._stats._current_kill_loot = value_ped
else:
# Same kill, add to current
self._stats._current_kill_loot += value_ped
else:
# First loot of session
self._stats._current_kill_loot = value_ped
self._stats._last_loot_time = now
# Add to totals
if is_shrapnel:
self._stats.shrapnel_total += value_ped
else:
self._stats.loot_other += value_ped
# Track highest single loot
if value_ped > self._stats.highest_loot:
self._stats.highest_loot = value_ped
self._stats.recalculate()
self._refresh_display()