-
-
- Phase chrono
-diff --git a/app.js b/app.js index 7ab7594..9e31160 100644 --- a/app.js +++ b/app.js @@ -209,10 +209,20 @@ 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"), @@ -240,6 +250,15 @@ 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); @@ -371,28 +390,36 @@ 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) { - button.textContent = resultText(match); + action.textContent = resultText(match); button.disabled = true; hint.textContent = "Le match est termine."; return; } if (!match.running) { - button.textContent = "Partie en pause"; + action.textContent = "Partie en pause"; button.disabled = true; hint.textContent = active ? "La partie n'a pas encore demarre ou a ete mise en pause." @@ -401,27 +428,27 @@ function initChronoPage() { } if (!active) { - button.textContent = "Attends"; + action.textContent = "Attends"; button.disabled = true; hint.textContent = `${playerName(match, match.currentTurn)} est en train de jouer.`; return; } if (match.doubleCoup.step === 1) { - button.textContent = "1er coup gratuit"; + action.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) { - button.textContent = "2e coup du double"; + action.textContent = "2e coup du double"; button.disabled = false; hint.textContent = "Ce coup compte dans le quota et l'echec redevient autorise."; return; } - button.textContent = "J'ai fini mon coup"; + action.textContent = "J'ai fini mon coup"; button.disabled = false; hint.textContent = "Tape des que ton coup est joue sur l'echiquier."; } @@ -449,7 +476,10 @@ function initChronoPage() { refs.spineLabel.textContent = "Termine"; refs.spineHeadline.textContent = resultText(match); refs.spineText.textContent = "Retournez a la configuration pour lancer une nouvelle rencontre."; - refs.primaryButton.textContent = "Retour a l'accueil"; + 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.arbiterStatus.textContent = "Le match est termine. Vous pouvez revenir a l'accueil ou reinitialiser."; } else if (match.running) { refs.centerLabel.textContent = "Trait"; @@ -458,7 +488,10 @@ 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.primaryButton.textContent = "Pause arbitre"; + 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.arbiterStatus.textContent = `Partie en cours. Joueur au trait : ${playerName(match, match.currentTurn)}.`; } else { refs.centerLabel.textContent = "Trait"; @@ -467,7 +500,10 @@ 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.primaryButton.textContent = "Demarrer la partie"; + 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.arbiterStatus.textContent = `Partie prete. ${playerName(match, match.currentTurn)} commencera.`; } @@ -1336,6 +1372,25 @@ 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) { diff --git a/chrono.html b/chrono.html index 56bc7b4..9319438 100644 --- a/chrono.html +++ b/chrono.html @@ -22,37 +22,84 @@
-
-
- Phase chrono
-