From 1e3b1b6ed97f0add9c3f8c6f26cc1330f756fb27 Mon Sep 17 00:00:00 2001 From: Tim Wheeler Date: Tue, 14 Jul 2026 14:37:02 +0100 Subject: [PATCH] Fix extra-time and penalty results in World Cup match data streams MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The match data streams read only score.ft (the 90-minute score) from the openfootball feed, so knockout matches decided in extra time or on penalties showed the wrong result — most visibly for England (e.g. the 2026 QF vs Norway, won 2-1 in extra time, shown as 1-1 and a Draw). matches.js, knockout.js and last-match.js now prefer score.et over score.ft and append the penalty shootout result, e.g. "1-1 (4-3 pens)". last-match.js also decides Win/Loss/Draw from the shootout when present. Bumps worldcup2026 to 1.2.2. Co-Authored-By: Claude Opus 4.8 --- .../v1/dataStreams/scripts/knockout.js | 9 +++++++-- .../v1/dataStreams/scripts/last-match.js | 20 +++++++++++++++---- .../v1/dataStreams/scripts/matches.js | 9 +++++++-- plugins/WorldCup2026/v1/metadata.json | 2 +- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/plugins/WorldCup2026/v1/dataStreams/scripts/knockout.js b/plugins/WorldCup2026/v1/dataStreams/scripts/knockout.js index f713f989..47c97285 100644 --- a/plugins/WorldCup2026/v1/dataStreams/scripts/knockout.js +++ b/plugins/WorldCup2026/v1/dataStreams/scripts/knockout.js @@ -12,8 +12,13 @@ var stageMap = { result = matches.filter(function(m) { return !m.group; }).map(function(m) { var score = '-'; var status = 'Upcoming'; - if (m.score && m.score.ft) { - score = m.score.ft[0] + '-' + m.score.ft[1]; + if (m.score && (m.score.et || m.score.ft)) { + // Prefer the score after extra time; fall back to the 90-minute (ft) score. + var base = m.score.et || m.score.ft; + score = base[0] + '-' + base[1]; + if (m.score.p) { + score += ' (' + m.score.p[0] + '-' + m.score.p[1] + ' pens)'; + } status = 'Finished'; } diff --git a/plugins/WorldCup2026/v1/dataStreams/scripts/last-match.js b/plugins/WorldCup2026/v1/dataStreams/scripts/last-match.js index 0feb1b6f..074515d1 100644 --- a/plugins/WorldCup2026/v1/dataStreams/scripts/last-match.js +++ b/plugins/WorldCup2026/v1/dataStreams/scripts/last-match.js @@ -25,15 +25,27 @@ if (played.length === 0) { var last = played[0]; var isHome = last.team1 === teamName; var opponent = isHome ? last.team2 : last.team1; - var myScore = isHome ? last.score.ft[0] : last.score.ft[1]; - var oppScore = isHome ? last.score.ft[1] : last.score.ft[0]; - var matchResult = myScore > oppScore ? 'Win' : myScore < oppScore ? 'Loss' : 'Draw'; + // Prefer the score after extra time; fall back to the 90-minute (ft) score. + var base = last.score.et || last.score.ft; + var myScore = isHome ? base[0] : base[1]; + var oppScore = isHome ? base[1] : base[0]; + var score = myScore + '-' + oppScore; + var matchResult; + if (last.score.p) { + // Match went to a penalty shootout — the winner is decided on penalties. + var myPens = isHome ? last.score.p[0] : last.score.p[1]; + var oppPens = isHome ? last.score.p[1] : last.score.p[0]; + score += ' (' + myPens + '-' + oppPens + ' pens)'; + matchResult = myPens > oppPens ? 'Win' : 'Loss'; + } else { + matchResult = myScore > oppScore ? 'Win' : myScore < oppScore ? 'Loss' : 'Draw'; + } result = [{ date: last.date, home_away: isHome ? 'Home' : 'Away', opponent: opponent, - score: myScore + '-' + oppScore, + score: score, result: matchResult, stage: last.group ? 'Group Stage' : (knockoutStageMap[last.round] || last.round), sourceId: sourceId diff --git a/plugins/WorldCup2026/v1/dataStreams/scripts/matches.js b/plugins/WorldCup2026/v1/dataStreams/scripts/matches.js index 0d7d0e1f..45621bd2 100644 --- a/plugins/WorldCup2026/v1/dataStreams/scripts/matches.js +++ b/plugins/WorldCup2026/v1/dataStreams/scripts/matches.js @@ -21,8 +21,13 @@ filtered.sort(function(a, b) { result = filtered.map(function(m) { var score = '-'; var status = 'Upcoming'; - if (m.score && m.score.ft) { - score = m.score.ft[0] + '-' + m.score.ft[1]; + if (m.score && (m.score.et || m.score.ft)) { + // Prefer the score after extra time; fall back to the 90-minute (ft) score. + var base = m.score.et || m.score.ft; + score = base[0] + '-' + base[1]; + if (m.score.p) { + score += ' (' + m.score.p[0] + '-' + m.score.p[1] + ' pens)'; + } status = 'Finished'; } diff --git a/plugins/WorldCup2026/v1/metadata.json b/plugins/WorldCup2026/v1/metadata.json index 307afe0b..71bb24d0 100644 --- a/plugins/WorldCup2026/v1/metadata.json +++ b/plugins/WorldCup2026/v1/metadata.json @@ -1,7 +1,7 @@ { "name": "worldcup2026", "displayName": "FIFA World Cup 2026", - "version": "1.2.1", + "version": "1.2.2", "author": { "name": "@TimWheeler-SQUP", "type": "community"