feat: add classement match system

This commit is contained in:
2026-02-05 21:29:27 +01:00
parent e2197d0712
commit 89d9e04a6f
24 changed files with 678 additions and 127 deletions

View File

@@ -104,8 +104,13 @@ function scorePrint(s1) {
return String(s1);
}
}
function scoreToString(score) {
return score.map(o => scorePrint(o.at(0)) + "-" + scorePrint(o.at(1))).join(" | ");
if (score.length === 0)
return "";
if (score.at(0) instanceof Array)
return score.map(s => scorePrint(s.at(0)) + "-" + scorePrint(s.at(1))).join(" | ");
return score.map(o => scorePrint(o.s1) + "-" + scorePrint(o.s2)).join(" | ");
}
function dateToString(date) {
@@ -129,7 +134,7 @@ function dateToString(date) {
return date_.toLocaleDateString();
}
function buildPouleMenu(isPoule, change_view) {
function buildPouleMenu(isPoule, change_view, isClassement = false) {
const menuDiv = document.createElement('div');
menuDiv.id = 'menu';
menuDiv.style.borderBottom = '1px solid #9EA0A1';
@@ -188,7 +193,7 @@ function buildPouleMenu(isPoule, change_view) {
change_view(true);
});
ul.appendChild(li1);
const li2 = createTab(i18next.t('tournois'), !isPoule, function () {
const li2 = createTab(isClassement ? i18next.t('classement') : i18next.t('tournois'), !isPoule, function () {
change_view(false);
});
ul.appendChild(li2);
@@ -262,7 +267,7 @@ function buildRankArray(rankArray) {
}
function buildTree(treeData) {
return drawGraph(initTree(treeData))
return drawGraph(initTree(treeData.filter(d => d.data.level >= 0)))
}
function poulePage(location) {
@@ -310,7 +315,7 @@ function poulePage(location) {
dataContainer.append(buildTree(poule['trees']));
} else {
const change_view = (isPoule) => {
dataContainer.replaceChildren(buildPouleMenu(isPoule, change_view));
dataContainer.replaceChildren(buildPouleMenu(isPoule, change_view, poule['treeIsClassement']));
if (isPoule) {
for (const g in poule.matchs) {
@@ -325,6 +330,19 @@ function poulePage(location) {
}
} else {
dataContainer.append(buildTree(poule['trees']));
if (poule['treeIsClassement'] && poule['trees'].some(d => d.data.level <= -10)) {
dataContainer.append(buildMatchArray(
poule['trees'].filter(d => d.data.level < 0).reverse().map(d => ({
red: d.data.c1FullName,
blue: d.data.c2FullName,
score: d.data.scores,
end: d.data.end,
red_w: d.data.win > 0,
blue_w: d.data.win < 0,
eq: d.data.win === 0,
date: d.data.date,
}))));
}
}
location[2] = isPoule ? 1 : 2;
@@ -392,10 +410,10 @@ function buildCombView(comb) {
<h3>${i18next.t('statistique')} :</h3>
<ul>
<li>${i18next.t('tauxDeVictoire2', {
nb: comb.matchs.length === 0 ? "---" : (comb.totalWin / comb.matchs.filter(m => m.end).length * 100).toFixed(0),
victoires: comb.totalWin,
matchs: comb.matchs.filter(m => m.end).length
})}
nb: comb.matchs.length === 0 ? "---" : (comb.totalWin / comb.matchs.filter(m => m.end).length * 100).toFixed(0),
victoires: comb.totalWin,
matchs: comb.matchs.filter(m => m.end).length
})}
</li>
<li>${i18next.t('pointsMarqués2', {nb: comb.pointMake})}</li>
<li>${i18next.t('pointsReçus2', {nb: comb.pointTake})}</li>