feat: füge Unterstützung für importierte Spielplan-Teams hinzu und verbessere Teamfilter-Logik
This commit is contained in:
@@ -39,6 +39,38 @@ function isErwachsenenTeam(teamKey) {
|
||||
return teamKey === 'erwachsene' || teamKey.startsWith('erwachsene_')
|
||||
}
|
||||
|
||||
function romanToNumber(value) {
|
||||
const roman = String(value || '').toUpperCase()
|
||||
if (!/^[IVX]+$/.test(roman)) return null
|
||||
|
||||
const values = { I: 1, V: 5, X: 10 }
|
||||
let total = 0
|
||||
for (let index = 0; index < roman.length; index += 1) {
|
||||
const current = values[roman[index]] || 0
|
||||
const next = values[roman[index + 1]] || 0
|
||||
total += current < next ? -current : current
|
||||
}
|
||||
return total || null
|
||||
}
|
||||
|
||||
function parseJugendTeamKey(teamKey) {
|
||||
const match = String(teamKey || '').match(/^jugend_?j?(\d{1,2})(?:_([ivx]+|\d+))?$/i)
|
||||
if (!match) return null
|
||||
|
||||
const teamNumber = match[2]
|
||||
? (Number(match[2]) || romanToNumber(match[2]))
|
||||
: null
|
||||
|
||||
return { age: match[1], teamNumber: teamNumber ? String(teamNumber) : '' }
|
||||
}
|
||||
|
||||
function sideMatchesJugendTeam({ isHarheimer, ageClass, teamNumber }, team) {
|
||||
if (!isHarheimer) return false
|
||||
const agePattern = new RegExp(`(?:jugend\\s*|j)${team.age}\\b`, 'i')
|
||||
if (!agePattern.test(ageClass)) return false
|
||||
return !team.teamNumber || String(teamNumber || '').trim() === team.teamNumber
|
||||
}
|
||||
|
||||
export function rowMatchesWettbewerbFilter(row, rawWettbewerb) {
|
||||
const wettbewerb = normalizeText(rawWettbewerb || 'punktrunde')
|
||||
const runde = normalizeText(row?.Runde)
|
||||
@@ -79,6 +111,19 @@ export function rowMatchesTeamFilter(row, rawTeam) {
|
||||
return isJugendHeim || isJugendGast
|
||||
}
|
||||
|
||||
const jugendTeam = parseJugendTeamKey(teamKey)
|
||||
if (jugendTeam) {
|
||||
return sideMatchesJugendTeam({
|
||||
isHarheimer: isHarheimerHeim,
|
||||
ageClass: heimAltersklasse,
|
||||
teamNumber: row?.HeimMannschaftNr
|
||||
}, jugendTeam) || sideMatchesJugendTeam({
|
||||
isHarheimer: isHarheimerGast,
|
||||
ageClass: gastAltersklasse,
|
||||
teamNumber: row?.GastMannschaftNr
|
||||
}, jugendTeam)
|
||||
}
|
||||
|
||||
const csvVariants = MANNSCHAFT_MAPPING[teamKey] || []
|
||||
if (csvVariants.length === 0) {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user