fix(gauntlet): fix loss_max=0 falsy-zero trap in recap marker logic
All checks were successful
Ruff Lint / lint (pull_request) Successful in 19s

`(loss_max or 99)` treats `loss_max=0` as 99, so 10-1 runs showed 
instead of  for perfect-run rewards. Fix uses explicit None check.
Tighten test to assert  presence rather than just absence of .

Addresses review feedback on PR #165.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-04-10 12:32:10 -05:00
parent 0b8beda8b5
commit cc72827dad
2 changed files with 9 additions and 3 deletions

View File

@ -2472,7 +2472,13 @@ def build_gauntlet_recap_embed(
if loss_max is not None
else wins >= win_num
)
marker = "" if earned else "" if losses > (loss_max or 99) else ""
marker = (
""
if earned
else ""
if losses > (loss_max if loss_max is not None else 99)
else ""
)
reward = r.get("reward", {})
if reward.get("money"):

View File

@ -204,11 +204,11 @@ class TestBuildGauntletRecapEmbed:
make_run(wins=10, losses=1), make_event(), make_main_team(), make_rewards()
)
prize_field = next(f for f in embed.fields if f.name == "Prize Distribution")
# The 10-0 bonus line must appear without ✅ (either ❌ or ⬜)
# The 10-0 bonus line must be marked ❌ — ineligible, not pending (⬜)
lines = prize_field.value.split("\n")
bonus_line = next((line for line in lines if "10-0" in line), None)
assert bonus_line is not None, "Expected a '10-0' line in prizes"
assert "" not in bonus_line
assert "" in bonus_line
def test_empty_rewards_list_omits_prize_field(self):
"""When rewards is an empty list the Prize Distribution field must be omitted.