Rename mirror swaps to moves and give each helper its own kind of help
All checks were successful
Validate and deploy Sokko G / validate (push) Successful in 23m30s
Validate and deploy Sokko G / deploy (push) Successful in 18s

On screen, a swap is now a move. The five helps no longer all save a
move: Bravery frees the next move from the row or column rule,
Orientation shows where a chosen piece goes, Fortune doubles the reward
of a rebuilt picture, Endurance takes back the last move and Balanced
shows the model for five seconds. The model is visible until the first
move only: the server no longer sends it afterwards, except during that
help and at the end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-28 14:11:28 +01:00
parent 9cf48ea0d0
commit ddb3b81278
14 changed files with 152 additions and 99 deletions

View file

@ -78,7 +78,7 @@ function HistoryDetail({ entry, catalog }) {
if (entry.type === "cards_recycled") return <span>{details.count} exemplaire{details.count > 1 ? "s" : ""} · +{formatStardust(details.stardust)} d’étoiles</span>;
if (entry.type === "daily_won") return <span>{`Défi n° ${details.number} · ${details.guesses}/6`}{details.stardust > 0 && ` · +${formatStardust(details.stardust)} d’étoiles`}</span>;
if (entry.type === "daily_reward_chosen") return <span>{[details.stardust > 0 && `+${formatStardust(details.stardust)} d’étoiles`, details.star && "+1 étoile dorée"].filter(Boolean).join(" · ")}</span>;
if (entry.type === "mirror_finished") return <span>{`${details.mode === "hard" ? "Difficile" : "Normal"} · ${details.won ? `${details.swaps} échanges` : "image non reconstituée"}`}{details.stardust > 0 && ` · +${formatStardust(details.stardust)} d’étoiles`}</span>;
if (entry.type === "mirror_finished") return <span>{`${details.mode === "hard" ? "Difficile" : "Normal"} · ${details.won ? `${details.swaps} mouvements` : "image non reconstituée"}`}{details.stardust > 0 && ` · +${formatStardust(details.stardust)} d’étoiles`}</span>;
if (entry.type === "race_finished") return <span>{`${details.place === 1 ? "1re" : `${details.place}e`} place`}{details.stardust > 0 && ` · +${formatStardust(details.stardust)} d’étoiles`}</span>;
if (entry.type === "team_recruited") return <span>{`Puissance moyenne ${details.power}`}{details.stardust > 0 && ` · +${formatStardust(details.stardust)} d’étoiles`}</span>;
if (entry.type === "expedition_completed") {

View file

@ -6,7 +6,7 @@ import { sameLine } from "./mirrorFormat.js";
// `tiles[cell]` : le morceau de l'image servie qui se trouve dans la case. Chaque morceau garde sa clé : il glisse d'une case à
// l'autre (technique FLIP : on mesure avant et après, puis on anime l'écart).
export function MirrorBoard({ game, src, modelSrc, tiles, peeking, disabled, content, onSwap }) {
export function MirrorBoard({ game, src, modelSrc, tiles, peeking, disabled, content, onSwap, aiming = false, onAim = null }) {
const { cols, rows } = game;
const [selected, setSelected] = useState(null);
const [hovered, setHovered] = useState(null);
@ -36,6 +36,8 @@ export function MirrorBoard({ game, src, modelSrc, tiles, peeking, disabled, con
const legal = (cell) => selected !== null && cell !== selected && (game.freeSwap || sameLine(cols, selected, cell));
function choose(cell) {
if (!playing || disabled) return;
// Orientation : le clic désigne le morceau dont on veut la place, sans rien échanger.
if (aiming) { setSelected(null); onAim(cell); return; }
if (selected === null || selected === cell) { setSelected(selected === cell ? null : cell); return; }
if (!legal(cell)) { setSelected(cell); return; }
setSelected(null);
@ -45,7 +47,7 @@ export function MirrorBoard({ game, src, modelSrc, tiles, peeking, disabled, con
const lit = (cell) => selected === null && hovered !== null && (cell === hovered || sameLine(cols, hovered, cell));
return <div className="nebula-mirror-frame" data-format={rows === cols ? "square" : "portrait"} data-state={game.status} data-peek={peeking || undefined}>
<div ref={boardRef} className="nebula-mirror-board" style={{ "--mirror-cols": cols, "--mirror-rows": rows }} data-picking={selected !== null || undefined} role="group" aria-label={content.boardLabel}>
<div ref={boardRef} className="nebula-mirror-board" style={{ "--mirror-cols": cols, "--mirror-rows": rows }} data-picking={selected !== null || undefined} data-aiming={aiming || undefined} role="group" aria-label={content.boardLabel}>
{tiles.map((piece, cell) => <button key={piece} ref={(element) => refs.current.set(piece, element)} type="button" className="nebula-mirror-piece"
style={{ gridRow: Math.floor(cell / cols) + 1, gridColumn: (cell % cols) + 1, backgroundImage: src ? `url(${src})` : undefined, backgroundSize: `${cols * 100}% ${rows * 100}%`, backgroundPosition: `${((piece % cols) / (cols - 1)) * 100}% ${(Math.floor(piece / cols) / (rows - 1)) * 100}%` }}
aria-label={fillTemplate(content.pieceLabel, { row: Math.floor(cell / cols) + 1, col: (cell % cols) + 1 })} aria-pressed={selected === cell}

View file

@ -104,6 +104,8 @@ export function MirrorPanel({ catalog, runMutation, busy, content, teamContent,
const boardsRef = useRef({});
const [models, setModels] = useState({});
const [peeking, setPeeking] = useState(false);
// Orientation en cours : le prochain clic sur le plateau désigne le morceau dont on veut la place.
const [aiming, setAiming] = useState(null);
const [toast, setToast] = useState("");
const urls = useRef([]);
// Images en cours de chargement, pour ne pas demander deux fois la même.
@ -195,12 +197,14 @@ export function MirrorPanel({ catalog, runMutation, busy, content, teamContent,
}
async function swap(from, to) {
const before = game.placed.length;
const before = game;
const next = await act(() => swapMirror(mirror.day, activeMode, from, to, game.moves));
const after = next?.games[activeMode];
if (after && after.status === "playing" && activeMode === "normal" && after.placed.length - before >= 2) flash(content.twoPlaced);
if (!after || after.moves === before.moves) return;
if (after.status === "playing" && activeMode === "normal" && after.placed.length - before.placed.length >= 2) flash(content.twoPlaced);
}
// Le modèle se charge à la première demande ; le serveur ne l'envoie que tant qu'il est visible.
async function peek(on) {
setPeeking(on);
if (!on || models[activeMode]) return;
@ -209,10 +213,23 @@ export function MirrorPanel({ catalog, runMutation, busy, content, teamContent,
urls.current.push(src);
setModels((current) => ({ ...current, [activeMode]: src }));
} catch (error) {
setPeeking(false);
setNotice(error.message);
}
}
// Coup de main : l'Orientation attend d'abord le morceau visé ; l'Équilibré montre le modèle quelques secondes.
async function help(cardId, helpId, cell = null) {
if (helpId === "orientation" && cell === null) { setAiming({ cardId, help: helpId }); return; }
setAiming(null);
const next = await act(() => applyMirrorHelp(mirror.day, activeMode, cardId, helpId, game.moves, cell));
const after = next?.games[activeMode];
if (helpId === "balanced" && after?.peekUntil) {
await peek(true);
window.setTimeout(() => setPeeking(false), Math.max(0, after.peekUntil - Date.now()));
}
}
const board = boards[activeMode];
const left = game?.left ?? 0;
return <section className="nebula-mirror" aria-labelledby="nebula-mirror-title">
@ -231,22 +248,24 @@ export function MirrorPanel({ catalog, runMutation, busy, content, teamContent,
{!game && <StartPanel mode={activeMode} mirror={mirror} content={content} busy={busy || !mirror.enabled} onStart={() => { setMode(activeMode); act(() => startMirror(mirror.day, activeMode)); }} />}
{game && <div className="nebula-mirror-layout">
<div className="nebula-mirror-stage">
<MirrorBoard game={game} src={board?.src} modelSrc={peeking ? models[activeMode] : null} tiles={board?.tiles || identity(game.cols * game.rows)} peeking={peeking} disabled={busy || !board?.src || board.applied !== game.moves} content={content} onSwap={swap} />
<MirrorBoard game={game} src={board?.src} modelSrc={peeking ? models[activeMode] : null} tiles={board?.tiles || identity(game.cols * game.rows)} peeking={peeking} disabled={busy || !board?.src || board.applied !== game.moves} content={content} onSwap={swap}
aiming={Boolean(aiming)} onAim={(cell) => help(aiming.cardId, aiming.help, cell)} />
{toast && <p className="nebula-mirror-toast" role="status">{toast}</p>}
{game.status === "playing" && <button className="nds-button nebula-mirror-peek" data-size="sm" data-variant="secondary" type="button" onMouseEnter={() => peek(true)} onMouseLeave={() => peek(false)} onFocus={() => peek(true)} onBlur={() => peek(false)}>{content.peek}</button>}
{game.status === "playing" && game.modelOpen && <button className="nds-button nebula-mirror-peek" title={content.peekUntilFirst} data-size="sm" data-variant="secondary" type="button" onMouseEnter={() => peek(true)} onMouseLeave={() => peek(false)} onFocus={() => peek(true)} onBlur={() => peek(false)}>{content.peek}</button>}
</div>
<div className="nebula-mirror-side">
{game.status === "playing"
? <section className="nds-panel nebula-mirror-counter" aria-live="polite">
<p className="nebula-mirror-left" data-low={left <= 2 || undefined}><strong>{left}</strong><span>{left > 1 ? content.left.many : content.left.one}</span></p>
<p className="nebula-mirror-note">{game.freeSwap ? content.freeHint : content.modes[activeMode].hint}</p>
<p className="nebula-mirror-note">{aiming ? content.aimHint : game.freeSwap ? content.freeHint : game.hint ? content.hintShown : content.modes[activeMode].hint}</p>
{game.treasure && <p className="nebula-mirror-reward">{content.treasureOn}</p>}
<p className="nebula-mirror-reward">{fillTemplate(content.rewardLine, { base: formatStardust(game.rewards.base), perSwap: game.rewards.perSwap })}</p>
</section>
: <MirrorResult catalog={catalog} mirror={mirror} game={game} content={content} nextAt={mirror.nextAt} />}
{game.status !== "playing" && activeMode === "normal" && !mirror.games.hard && <div className="nds-card-actions"><button className="nds-button" data-variant="primary" type="button" onClick={() => setMode("hard")}>{content.toHard}</button></div>}
{(game.status === "playing" || game.helpers.length > 0) && <MirrorHelpers catalog={catalog} mirror={mirror} game={game} content={content} teamContent={teamContent} statLabels={statLabels} busy={busy}
onChoose={(cardIds) => act(() => chooseMirrorHelpers(mirror.day, activeMode, cardIds))}
onHelp={(cardId, help) => act(() => applyMirrorHelp(mirror.day, activeMode, cardId, help, game.moves))} />}
onHelp={(cardId, helpId) => help(cardId, helpId)} />}
</div>
</div>}
</>}

View file

@ -1,5 +1,5 @@
// Rôle : règle le Miroir brisé depuis Administration › Guilde : ouverture, suivi du jour (illustration du Difficile, parties,
// poussière versée), gains et marges d'échanges. Ses règles de jeu restent dans mirror-rules.js.
// poussière versée), gains et marges de mouvements. Ses règles de jeu restent dans mirror-rules.js.
import { useState } from "react";
import { ConfirmModal } from "../../../components/ToolboxModals.jsx";
import { updateMirrorSettings } from "../cardsApi.js";
@ -11,16 +11,16 @@ const number = (value) => value.toLocaleString("fr-FR");
const MIRROR_SETTING_GROUPS = [
{
id: "mirror-rewards", title: "Gains", help: "En poussière d’étoiles, pour une image reconstituée : la base, plus une part par échange restant. Une partie perdue ne rapporte rien. Repères : la Carte du jour rapporte 20 en production, la Course 20 à 5.",
id: "mirror-rewards", title: "Gains", help: "En poussière d’étoiles, pour une image reconstituée : la base, plus une part par mouvement restant. Une partie perdue ne rapporte rien. Repères : la Carte du jour rapporte 20 en production, la Course 20 à 5.",
fields: [
{ path: "rewards.normal.base", label: "Normal, base", min: 0, max: 100_000 },
{ path: "rewards.normal.perSwap", label: "Normal, par échange restant", min: 0, max: 100_000 },
{ path: "rewards.normal.perSwap", label: "Normal, par mouvement restant", min: 0, max: 100_000 },
{ path: "rewards.hard.base", label: "Difficile, base", min: 0, max: 100_000 },
{ path: "rewards.hard.perSwap", label: "Difficile, par échange restant", min: 0, max: 100_000 }
{ path: "rewards.hard.perSwap", label: "Difficile, par mouvement restant", min: 0, max: 100_000 }
]
},
{
id: "mirror-margins", title: "Marges d’échanges", help: "Échanges permis au-delà du meilleur résultat trouvé par l’ordinateur. En Normal, avec 3, un joueur attentif réussit environ 9 fois sur 10 (simulation). Une partie commencée garde sa limite.",
id: "mirror-margins", title: "Marges de mouvements", help: "Mouvements permis au-delà du meilleur résultat trouvé par l’ordinateur. En Normal, avec 3, un joueur attentif réussit environ 9 fois sur 10 (simulation). Une partie commencée garde sa limite.",
fields: [
{ path: "margins.normal", label: "Normal", min: 0, max: 30 },
{ path: "margins.hard", label: "Difficile", min: 0, max: 30 }
@ -47,7 +47,7 @@ function MirrorStatus({ settings, today, catalog, busy, onToggle }) {
</div>
<dl className="nebula-admin-race-figures">
{Object.entries(today.games).map(([mode, games]) => <div key={mode}><dt>{MODE_LABELS[mode]}</dt><dd>{games.started ? `${number(games.started)} partie${games.started > 1 ? "s" : ""} · ${number(games.won)} gagnée${games.won > 1 ? "s" : ""} · ${number(games.lost)} perdue${games.lost > 1 ? "s" : ""}` : "Aucune partie."}</dd></div>)}
<div><dt>Difficile du jour</dt><dd>{today.hard ? `${hardCard?.name || today.hard.cardId} · ordinateur : ${today.hard.par} échanges` : "Tiré à la première partie du jour."}</dd></div>
<div><dt>Difficile du jour</dt><dd>{today.hard ? `${hardCard?.name || today.hard.cardId} · ordinateur : ${today.hard.par} mouvements` : "Tiré à la première partie du jour."}</dd></div>
</dl>
{confirming && <ConfirmModal
title={open ? "Fermer le Miroir brisé ?" : "Ouvrir le Miroir brisé ?"}

View file

@ -161,8 +161,9 @@ export function chooseMirrorHelpers(day, mode, cardIds) {
return request("/mirror/helpers", { method: "POST", body: JSON.stringify({ day, mode, cardIds }) });
}
export function applyMirrorHelp(day, mode, cardId, help, moves) {
return request("/mirror/help", { method: "POST", body: JSON.stringify({ day, mode, cardId, help, moves }) });
// `cell` : pour l'Orientation, la case du morceau dont on veut connaître la place.
export function applyMirrorHelp(day, mode, cardId, help, moves, cell = null) {
return request("/mirror/help", { method: "POST", body: JSON.stringify({ day, mode, cardId, help, moves, cell }) });
}
// Serveur de développement seulement.