fix: case-insensitive dead-vehicle matching for TSS scoreboard

Spectra sends events.kills[].offended_unit with uppercase roman
numerals (V/VI) while players[].units[].unit uses lowercase (v/vi).
85% of TSS games are affected — dead-vehicle strikethrough on the
Discord scoreboard never triggered because  was
case-sensitive.

Normalize both sides to lowercase before comparing.
This commit is contained in:
deploy
2026-06-30 14:03:44 +00:00
parent 6d251be97c
commit c417226e9e
+3 -3
View File
@@ -60,14 +60,14 @@ def _build_units(units: list[dict[str, Any]], translate, dead: set[str] | None =
Prefer an explicit per-unit ``dead``/``died`` flag if Spectra provides one; otherwise
fall back to the ``dead`` set cross-referenced from ``events.kills`` (see ``_dead_units_by_uid``).
"""
dead = dead or set()
dead_lc = {s.lower() for s in (dead or set())}
out: list[dict[str, Any]] = []
for u in units or []:
internal = strip_model_prefix(u.get("unit"))
if not internal:
continue
flag = u.get("dead", u.get("died"))
is_dead = bool(flag) if flag is not None else internal in dead
is_dead = bool(flag) if flag is not None else internal.lower() in dead_lc
out.append({
"internal": internal,
"name": translate(internal) or u.get("unit_normalized") or internal,
@@ -88,7 +88,7 @@ def _dead_units_by_uid(game: dict[str, Any]) -> dict[str, set[str]]:
uid = str(k.get("offended_uid") or "")
unit = strip_model_prefix(k.get("offended_unit"))
if uid and unit:
out.setdefault(uid, set()).add(unit)
out.setdefault(uid, set()).add(unit.lower())
return out