Annule la refonte du chrono
This commit is contained in:
73
app.js
73
app.js
@@ -209,20 +209,10 @@ function initChronoPage() {
|
||||
blackHint: document.querySelector("#blackHintChrono"),
|
||||
whiteButton: document.querySelector("#whiteMoveButton"),
|
||||
blackButton: document.querySelector("#blackMoveButton"),
|
||||
whiteAction: document.querySelector("#whiteActionChrono"),
|
||||
blackAction: document.querySelector("#blackActionChrono"),
|
||||
whiteDisplayClock: document.querySelector("#whiteDisplayClock"),
|
||||
blackDisplayClock: document.querySelector("#blackDisplayClock"),
|
||||
whiteDisplayMeta: document.querySelector("#whiteDisplayMeta"),
|
||||
blackDisplayMeta: document.querySelector("#blackDisplayMeta"),
|
||||
whiteQuota: document.querySelector("#whiteQuotaChrono"),
|
||||
blackQuota: document.querySelector("#blackQuotaChrono"),
|
||||
whiteZone: document.querySelector("#whiteZone"),
|
||||
blackZone: document.querySelector("#blackZone"),
|
||||
openArbiterButton: document.querySelector("#openArbiterButton"),
|
||||
closeArbiterButton: document.querySelector("#closeArbiterButton"),
|
||||
primaryLabel: document.querySelector("#primaryChronoLabel"),
|
||||
quickResetButton: document.querySelector("#quickResetChronoButton"),
|
||||
arbiterModal: document.querySelector("#arbiterModal"),
|
||||
arbiterStatus: document.querySelector("#arbiterStatus"),
|
||||
arbiterPauseButton: document.querySelector("#arbiterPauseButton"),
|
||||
@@ -250,15 +240,6 @@ function initChronoPage() {
|
||||
refs.whiteButton?.addEventListener("click", () => handleChronoTap("white"));
|
||||
refs.blackButton?.addEventListener("click", () => handleChronoTap("black"));
|
||||
refs.primaryButton?.addEventListener("click", handlePrimaryChronoAction);
|
||||
refs.quickResetButton?.addEventListener("click", () => {
|
||||
const shouldReset = window.confirm("Reinitialiser le match en cours et revenir a l'accueil ?");
|
||||
if (!shouldReset) {
|
||||
return;
|
||||
}
|
||||
|
||||
clearMatch();
|
||||
replaceTo(SETUP_PAGE);
|
||||
});
|
||||
|
||||
refs.arbiterPauseButton?.addEventListener("click", () => {
|
||||
syncRunningState(match);
|
||||
@@ -390,36 +371,28 @@ function initChronoPage() {
|
||||
const moves = isWhite ? refs.whiteMoves : refs.blackMoves;
|
||||
const clock = isWhite ? refs.whiteClock : refs.blackClock;
|
||||
const hint = isWhite ? refs.whiteHint : refs.blackHint;
|
||||
const action = isWhite ? refs.whiteAction : refs.blackAction;
|
||||
const displayClock = isWhite ? refs.whiteDisplayClock : refs.blackDisplayClock;
|
||||
const displayMeta = isWhite ? refs.whiteDisplayMeta : refs.blackDisplayMeta;
|
||||
const quota = isWhite ? refs.whiteQuota : refs.blackQuota;
|
||||
const zone = isWhite ? refs.whiteZone : refs.blackZone;
|
||||
const actorName = playerName(match, color);
|
||||
const active = match.currentTurn === color;
|
||||
const display = renderChronoZoneDisplay(match, color, active);
|
||||
|
||||
name.textContent = actorName;
|
||||
moves.textContent = `${match.moves[color]} / ${match.quota}`;
|
||||
clock.textContent = match.clocks
|
||||
? `Chrono ${formatSignedClock(match.clocks[color])}`
|
||||
: `Dernier cube ${renderLastCube(match, color)}`;
|
||||
displayClock.textContent = display.time;
|
||||
displayMeta.textContent = display.label;
|
||||
quota.textContent = `${match.moves[color]} / ${match.quota}`;
|
||||
|
||||
button.classList.toggle("active-turn", active && !match.result);
|
||||
zone.classList.toggle("active-zone", active && !match.result);
|
||||
|
||||
if (match.result) {
|
||||
action.textContent = resultText(match);
|
||||
button.textContent = resultText(match);
|
||||
button.disabled = true;
|
||||
hint.textContent = "Le match est termine.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!match.running) {
|
||||
action.textContent = "Partie en pause";
|
||||
button.textContent = "Partie en pause";
|
||||
button.disabled = true;
|
||||
hint.textContent = active
|
||||
? "La partie n'a pas encore demarre ou a ete mise en pause."
|
||||
@@ -428,27 +401,27 @@ function initChronoPage() {
|
||||
}
|
||||
|
||||
if (!active) {
|
||||
action.textContent = "Attends";
|
||||
button.textContent = "Attends";
|
||||
button.disabled = true;
|
||||
hint.textContent = `${playerName(match, match.currentTurn)} est en train de jouer.`;
|
||||
return;
|
||||
}
|
||||
|
||||
if (match.doubleCoup.step === 1) {
|
||||
action.textContent = "1er coup gratuit";
|
||||
button.textContent = "1er coup gratuit";
|
||||
button.disabled = false;
|
||||
hint.textContent = "Ce coup ne compte pas et ne doit pas donner echec.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (match.doubleCoup.step === 2) {
|
||||
action.textContent = "2e coup du double";
|
||||
button.textContent = "2e coup du double";
|
||||
button.disabled = false;
|
||||
hint.textContent = "Ce coup compte dans le quota et l'echec redevient autorise.";
|
||||
return;
|
||||
}
|
||||
|
||||
action.textContent = "J'ai fini mon coup";
|
||||
button.textContent = "J'ai fini mon coup";
|
||||
button.disabled = false;
|
||||
hint.textContent = "Tape des que ton coup est joue sur l'echiquier.";
|
||||
}
|
||||
@@ -476,10 +449,7 @@ function initChronoPage() {
|
||||
refs.spineLabel.textContent = "Termine";
|
||||
refs.spineHeadline.textContent = resultText(match);
|
||||
refs.spineText.textContent = "Retournez a la configuration pour lancer une nouvelle rencontre.";
|
||||
refs.primaryLabel.textContent = "Retour a l'accueil";
|
||||
refs.primaryButton.dataset.state = "home";
|
||||
refs.primaryButton.setAttribute("aria-label", "Retour a l'accueil");
|
||||
refs.primaryButton.title = "Retour a l'accueil";
|
||||
refs.primaryButton.textContent = "Retour a l'accueil";
|
||||
refs.arbiterStatus.textContent = "Le match est termine. Vous pouvez revenir a l'accueil ou reinitialiser.";
|
||||
} else if (match.running) {
|
||||
refs.centerLabel.textContent = "Trait";
|
||||
@@ -488,10 +458,7 @@ function initChronoPage() {
|
||||
refs.spineHeadline.textContent = `Partie ${match.blockNumber} active`;
|
||||
refs.spineText.textContent =
|
||||
"Chaque joueur tape sur sa grande zone quand son coup est termine. La page cube s'ouvrira automatiquement a la fin de la phase chess.";
|
||||
refs.primaryLabel.textContent = "Pause arbitre";
|
||||
refs.primaryButton.dataset.state = "pause";
|
||||
refs.primaryButton.setAttribute("aria-label", "Mettre la partie en pause");
|
||||
refs.primaryButton.title = "Mettre la partie en pause";
|
||||
refs.primaryButton.textContent = "Pause arbitre";
|
||||
refs.arbiterStatus.textContent = `Partie en cours. Joueur au trait : ${playerName(match, match.currentTurn)}.`;
|
||||
} else {
|
||||
refs.centerLabel.textContent = "Trait";
|
||||
@@ -500,10 +467,7 @@ function initChronoPage() {
|
||||
refs.spineHeadline.textContent = `Partie ${match.blockNumber}`;
|
||||
refs.spineText.textContent =
|
||||
"Demarrez la partie, puis laissez uniquement les deux grandes zones aux joueurs. La page cube prendra automatiquement le relais.";
|
||||
refs.primaryLabel.textContent = "Demarrer la partie";
|
||||
refs.primaryButton.dataset.state = "play";
|
||||
refs.primaryButton.setAttribute("aria-label", "Demarrer la partie");
|
||||
refs.primaryButton.title = "Demarrer la partie";
|
||||
refs.primaryButton.textContent = "Demarrer la partie";
|
||||
refs.arbiterStatus.textContent = `Partie prete. ${playerName(match, match.currentTurn)} commencera.`;
|
||||
}
|
||||
|
||||
@@ -1372,25 +1336,6 @@ function renderModeContext(storedMatch) {
|
||||
return "Le gagnant du cube ouvrira la prochaine partie";
|
||||
}
|
||||
|
||||
function renderChronoZoneDisplay(storedMatch, color, active) {
|
||||
if (storedMatch.clocks) {
|
||||
return {
|
||||
time: formatSignedClock(storedMatch.clocks[color]),
|
||||
label: active ? "Chrono actif" : "Chrono joueur",
|
||||
};
|
||||
}
|
||||
|
||||
return active
|
||||
? {
|
||||
time: formatClock(storedMatch.moveRemainingMs),
|
||||
label: "Temps coup",
|
||||
}
|
||||
: {
|
||||
time: formatClock(storedMatch.blockRemainingMs),
|
||||
label: "Temps partie",
|
||||
};
|
||||
}
|
||||
|
||||
function renderLastCube(storedMatch, color) {
|
||||
const last = storedMatch.cube.history.at(-1);
|
||||
if (!last) {
|
||||
|
||||
Reference in New Issue
Block a user