fix: strip tag decorators from winner/loser before guild_squadron comparison
guild_squadron is the clean short name from SQUADRONS.json (e.g. DSPLA) but winning_team_squadron in the replay is the raw tagged value (-DSPLA-). They never matched for dash/underscore-tagged squads so bar_color was always not_involved instead of win/loss on the guild's own scoreboard. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+9
-3
@@ -971,11 +971,17 @@ async def process_session(
|
||||
logging.error(f"Replay file for session ID {session_id} is invalid: {e}")
|
||||
return
|
||||
|
||||
# Extract winner/loser/draw
|
||||
# Extract winner/loser/draw — strip tag decorators so bare short names
|
||||
# (e.g. "DSPLA" stored in SQUADRONS.json) match raw replay values like "-DSPLA-".
|
||||
def _strip_tag(s: Optional[str]) -> Optional[str]:
|
||||
if s is None:
|
||||
return None
|
||||
return re.sub(r'^[^A-Za-z0-9]+|[^A-Za-z0-9]+$', '', s) or s
|
||||
|
||||
squadrons = replay_data.get("squadrons", [])
|
||||
winner = replay_data.get("winning_team_squadron")
|
||||
winner = _strip_tag(replay_data.get("winning_team_squadron"))
|
||||
is_draw = replay_data.get("draw", False)
|
||||
loser_candidates = [sq for sq in squadrons if sq != winner]
|
||||
loser_candidates = [_strip_tag(sq) for sq in squadrons if _strip_tag(sq) != winner]
|
||||
loser = loser_candidates[0] if loser_candidates else None
|
||||
# Guild-specific squadron (short name)
|
||||
guild_data = squadrons_data.get(str(guild_id), {})
|
||||
|
||||
Reference in New Issue
Block a user