diff --git a/.agents/project-memory.md b/.agents/project-memory.md index 4d51a91..5b72618 100644 --- a/.agents/project-memory.md +++ b/.agents/project-memory.md @@ -180,6 +180,11 @@ Static web app showing the FIFA World Cup 2026 (Mexico/USA/Canada, 48 teams) — ## Patterns for future changes +### Match stats no modal (2026-06-14) +- **Campo opcional `stats` em `results.json`** por jogo: `{ possession: {home,away}, shots: {home,away}, cards: {home,away} }` (`home`/`away` seguem `homeTeam`/`awayTeam` de `matches.json`; valores = posse em %, finalizações totais, cartões amarelos). Primeiro preenchido no jogo 6 (BRA 1–1 MAR) como teste do deploy: posse 51/49, finalizações 12/14, cartões 2/0 (fontes ESPN/Opta/Sofascore). +- **`modal.js` renderiza stats reais quando `result.stats` existe**; senão mantém o placeholder com `—` + nota `modal.statsSoon` (backward-compatível, verificado nos jogos 6 com stats e 4 sem). `statRow(home, label, away)` agora recebe valores; antes só o label. +- Reusa as chaves i18n já existentes: `modal.possession` / `modal.shots` / `modal.cards`. Adicionar stats a mais jogos = só editar `results.json`, nenhum código muda. + ### How to update real-world data (scores, schedule) Follow `how-refresh-data.md` (project root). In short: 1. Edit `data/results.json` (scores/status) or `data/matches.json` (schedule, rare). diff --git a/assets/js/modal.js b/assets/js/modal.js index 83d84ea..9c31d19 100644 --- a/assets/js/modal.js +++ b/assets/js/modal.js @@ -49,6 +49,7 @@ function renderContent(matchId) { if (!match) return; const result = resultByMatchId.get(matchId); const status = result?.status ?? 'scheduled'; + const s = result?.stats; const stadium = stadiumByName.get(match.stadium); const slots = resolveBracketTeams(match); const numberFmt = new Intl.NumberFormat(getLocale()); @@ -87,10 +88,10 @@ function renderContent(matchId) { `; } -// placeholder row — real values will replace the dashes when stats data exists -function statRow(label) { +// stat row — shows real home/away values, or "—" when no stats data exists +function statRow(home, label, away) { return ` `; } diff --git a/data/results.json b/data/results.json index 700b300..67a875b 100644 --- a/data/results.json +++ b/data/results.json @@ -33,7 +33,12 @@ "matchId": 6, "homeScore": 1, "awayScore": 1, - "status": "finished" + "status": "finished", + "stats": { + "possession": { "home": 51, "away": 49 }, + "shots": { "home": 12, "away": 14 }, + "cards": { "home": 2, "away": 0 } + } }, { "matchId": 7,