Skip to content

Commit e1aa714

Browse files
198-Bug update TBD slot display with source match score and teams
1 parent 962dd5b commit e1aa714

1 file changed

Lines changed: 29 additions & 8 deletions

File tree

features/tourney/matcherino.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def get_team_info(entrant_dict):
272272
if not entrant_dict:
273273
return {"name": "TBD", "score": 0, "players": []}
274274
e_id = entrant_dict.get("entrantId", 0)
275-
score = entrant_dict.get("score", 0)
275+
score = entrant_dict.get("score") or 0
276276
info = entrant_map.get(e_id, {"name": "TBD", "players": []})
277277
return {"name": info["name"], "score": score, "players": info["players"]}
278278

@@ -325,6 +325,10 @@ def resolve_name(entrant_dict, source_entry, depth=0):
325325
src_eb = find_src(src.get("entrantB"), src.get("entrantA"), srcs, 1)
326326
a = resolve_name(src.get("entrantA"), src_ea, depth + 1)
327327
b = resolve_name(src.get("entrantB"), src_eb, depth + 1)
328+
if "Waiting on" not in a and "Waiting on" not in b:
329+
a_score = src.get("entrantA", {}).get("score") or 0
330+
b_score = src.get("entrantB", {}).get("score") or 0
331+
return f"Waiting on Match #{v_src} ({a} {a_score} - {b_score} {b})"
328332
return f"Waiting on Match #{v_src} ({a} vs {b})"
329333

330334
def build_tbd_chain(source_entry):
@@ -345,7 +349,9 @@ def build_tbd_chain(source_entry):
345349
a_name = resolve_name(src_match.get("entrantA"), src_ea, depth=1)
346350
b_name = resolve_name(src_match.get("entrantB"), src_eb, depth=1)
347351
if "Waiting on" not in a_name and "Waiting on" not in b_name:
348-
return [f"→ Match #{v_src}: {a_name} vs {b_name}"]
352+
a_score = src_match.get("entrantA", {}).get("score") or 0
353+
b_score = src_match.get("entrantB", {}).get("score") or 0
354+
return [f"→ Match #{v_src}: {a_name} {a_score} - {b_score} {b_name}"]
349355
return [
350356
f"→ Match #{v_src} [A]: {a_name}",
351357
f"→ Match #{v_src} [B]: {b_name}",
@@ -365,21 +371,36 @@ def build_tbd_chain(source_entry):
365371
team_a_is_tbd = team_a["name"] in ("TBD", "BYE")
366372
team_b_is_tbd = team_b["name"] in ("TBD", "BYE")
367373

374+
def tbd_label(src_entry):
375+
if not src_entry:
376+
return "TBD"
377+
raw = src_entry.get("matchNum")
378+
v = raw_to_visual.get(raw, raw)
379+
src_m = visual_match_map.get(v)
380+
if not src_m:
381+
return f"Waiting on Match #{v}"
382+
srcs_m = src_m.get("entrantSources") or []
383+
src_mea = find_src(src_m.get("entrantA"), src_m.get("entrantB"), srcs_m, 0)
384+
src_meb = find_src(src_m.get("entrantB"), src_m.get("entrantA"), srcs_m, 1)
385+
a_name = resolve_name(src_m.get("entrantA"), src_mea)
386+
b_name = resolve_name(src_m.get("entrantB"), src_meb)
387+
a_sc = src_m.get("entrantA", {}).get("score") or 0
388+
b_sc = src_m.get("entrantB", {}).get("score") or 0
389+
return f"Waiting on Match #{v} [{a_name} {a_sc} - {b_sc} {b_name}]"
390+
368391
if team_a_is_tbd:
369392
src_a = find_src(
370393
current_match.get("entrantA"), current_match.get("entrantB"), sources, 0
371394
)
372-
if src_a:
373-
raw = src_a.get("matchNum")
374-
team_a["name"] = f"Waiting on Match #{raw_to_visual.get(raw, raw)}"
395+
team_a["name"] = tbd_label(src_a)
396+
team_a["score"] = None
375397

376398
if team_b_is_tbd:
377399
src_b = find_src(
378400
current_match.get("entrantB"), current_match.get("entrantA"), sources, 1
379401
)
380-
if src_b:
381-
raw = src_b.get("matchNum")
382-
team_b["name"] = f"Waiting on Match #{raw_to_visual.get(raw, raw)}"
402+
team_b["name"] = tbd_label(src_b)
403+
team_b["score"] = None
383404

384405
match_status = current_match.get("status", "unknown")
385406

0 commit comments

Comments
 (0)