Rank the third place game winner instead of leaving them in contention #137
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "claude/third-place-game-elimination"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
On the FIFA World Cup bracket, setting the Third Place Game result left the winner displayed under In Contention. They should take 3rd place points and then be done.
Cause
The scoring side was already correct —
TEMPLATE_ROUND_CONFIG.fifa_48finalizes the 3PG winner atfinalPosition = 3withisPartialScore = false, so the 50 points were being awarded.The bug was display-only.
PlayoffBracketre-derives rankings from match records rather than participant results, and only ever ranks losers. The 3PG winner lost the semifinal but was correctly excluded there by the double-chance guard (they appear in a later round), then won the 3PG — so they were never a loser in any match, never ranked, and fell through into the active list.Also fixed
The same code double-counted positions 3–4 when labelling ranks:
Approach
Rankings now go through
computeRankedEntries, which resolves a consolation round at its feeder round: the winner takes the top of the tier the feeder's losers would otherwise share, the loser the next position, and the consolation round itself consumes none. Positions are derived rather than hardcoded to 3/4, so a consolation round hanging off a different feeder lands correctly too.Only matches that can be placed exactly are withheld from the loser-driven walk, so an incomplete or partially hydrated consolation match falls back to the old path rather than being silently dropped.
loserFeedsIntois set on exactly one round in the templates (fifa_48Semifinals), so NCAA / NBA / AFL / CFP / tennis brackets are unaffected. This fixesmode="rankings"as well, which shared the derivation.Testing
32 tests in
PlayoffBracket.test.tsx, up from 22 — covering the 3PG winner/loser placement, rank ordering, the pre-game state, a consolation round in a non-3rd/4th position, score lookup by slot, and fallback cases. Two assert against the rendered DOM, not just the helper.Each fix has a negative control: reverting any one of them individually makes tests fail. Full suite 2855/2855 green, typecheck and lint clean.
Not yet verified
This has not been driven against real World Cup data in a running app — the coverage is unit plus rendered-DOM. Worth a look at the actual page before merging.
Known limitation (unchanged, not in scope)
Third-place handling is still coupled to the
fifa_48template id in two places on the scoring side (TEMPLATE_ROUND_CONFIGinscoring-calculator.tsandDISTINCT_34_TEMPLATE_IDSinscoring-rules.ts), and genericROUND_CONFIGhas no"Third Place Game"entry. A future template adding one would fall into the "unrecognized round" branch and get a T5–T8 floor instead of 3rd.🤖 Generated with Claude Code