parser corrections

This commit is contained in:
2026-06-29 14:26:57 -05:00
parent 7c910e9199
commit 40618d2953

View File

@@ -752,13 +752,25 @@ export function attachKOLiveData(matches: Match[], teams: Team[], koGames: Wc26G
// Parst worldcup26-Scorer-String: "{\"Casemiro 56'\"}" oder "{\"Player 12'\",\"Other 34'\"}"
function parseScorers(raw: string, team: "home" | "away", out: GoalEvent[]): void {
if (!raw || raw === "{}") return;
const cleaned = raw.replace(/[{}"\\]/g, "").trim();
if (!cleaned) return;
const parts = cleaned.split(",");
for (const p of parts) {
const m = /^(.+?)\s+(\d+)'?\s*$/.exec(p.trim());
const m = /^(.+?)\s+([0-9+]+)'?(?:\s*\(.*?\))?\s*$/.exec(p.trim());
if (m) {
out.push({ scorer: m[1].trim(), minute: parseInt(m[2], 10), team });
const name = m[1].trim();
const minStr = m[2];
let minute = 0;
const plusIdx = minStr.indexOf("+");
if (plusIdx >= 0) {
minute = parseInt(minStr.slice(0, plusIdx), 10) + parseInt(minStr.slice(plusIdx + 1), 10);
} else {
minute = parseInt(minStr, 10);
}
if (!isNaN(minute)) {
out.push({ scorer: name, minute, team });
}
}
}
}