Rename mirror swaps to moves and give each helper its own kind of help
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:
parent
9cf48ea0d0
commit
ddb3b81278
14 changed files with 152 additions and 99 deletions
|
|
@ -776,41 +776,45 @@
|
|||
"rules": [
|
||||
"Cliquez un morceau, puis un autre de la même rangée ou de la même colonne : ils s’échangent.",
|
||||
"Un morceau qui n’est ni dans la rangée ni dans la colonne de sa place passe par une case relais. Un beau coup choisit un relais qui rapproche aussi un autre morceau.",
|
||||
"Reconstituez l’image avant la fin des échanges. Chaque échange restant rapporte de la poussière en plus."
|
||||
"Reconstituez l’image avant la fin des mouvements. Chaque mouvement restant rapporte de la poussière en plus."
|
||||
],
|
||||
"rewardLine": "Image reconstituée : {base}, plus {perSwap} par échange restant.",
|
||||
"rewardLine": "Image reconstituée : {base}, plus {perSwap} par mouvement restant.",
|
||||
"hardLocked": "Terminez d’abord le Normal du jour.",
|
||||
"dailyFirst": "Trouvez d’abord votre Carte du jour : le Difficile d’aujourd’hui en montre la réponse.",
|
||||
"left": { "one": "échange restant", "many": "échanges restants" },
|
||||
"freeHint": "Échange libre : votre prochain échange peut se faire avec n’importe quel morceau.",
|
||||
"left": { "one": "mouvement restant", "many": "mouvements restants" },
|
||||
"freeHint": "Mouvement libre : votre prochain mouvement peut échanger n’importe quels morceaux.",
|
||||
"aimHint": "Où va ce morceau ? Cliquez le morceau dont vous voulez connaître la place.",
|
||||
"hintShown": "Sa vraie place pulse en doré.",
|
||||
"treasureOn": "Trésor : votre gain sera doublé.",
|
||||
"boardLabel": "Morceaux de l’illustration",
|
||||
"pieceLabel": "Morceau rangée {row}, colonne {col}",
|
||||
"peek": "Voir le modèle",
|
||||
"peekUntilFirst": "Le modèle se voit jusqu’à votre premier mouvement, puis seulement avec un compagnon Équilibré.",
|
||||
"twoPlaced": "Deux morceaux posés d’un coup",
|
||||
"helpersTitle": "Coups de main de votre équipe",
|
||||
"helpersChoose": "Choisissez jusqu’à {count} compagnons avant votre premier échange. Chacun donne son coup de main une fois, quand vous le voulez.",
|
||||
"helpersChoose": "Choisissez jusqu’à {count} compagnons avant votre premier mouvement. Chacun donne son coup de main une fois, quand vous le voulez.",
|
||||
"helpersNone": "Avec une Équipe du jour, deux compagnons peuvent vous donner un coup de main.",
|
||||
"helpersNoneChosen": "Aucun compagnon choisi pour cette partie.",
|
||||
"toTeam": "Voir l’Équipe du jour",
|
||||
"or": "ou",
|
||||
"helpChoice": "Au choix :",
|
||||
"helps": {
|
||||
"bravoure": { "name": "Échange libre", "text": "Votre prochain échange peut se faire entre deux morceaux quelconques." },
|
||||
"endurance": { "name": "Un échange de plus", "text": "Vous gagnez un échange." },
|
||||
"fortune": { "name": "Un morceau se pose", "text": "Un morceau mal placé, tiré au hasard, va à sa place. Gratuit." },
|
||||
"orientation": { "name": "Un bon coup", "text": "Montre un bon échange à faire maintenant." },
|
||||
"balanced": { "name": "Reprendre", "text": "Annule votre dernier échange et vous le rend." }
|
||||
"bravoure": { "name": "Mouvement libre", "text": "Votre prochain mouvement peut échanger deux morceaux quelconques." },
|
||||
"orientation": { "name": "Où va ce morceau ?", "text": "Choisissez un morceau : sa vraie place s’éclaire." },
|
||||
"fortune": { "name": "Trésor", "text": "Si vous reconstituez l’image, votre gain de poussière est doublé." },
|
||||
"endurance": { "name": "Reprendre", "text": "Annule votre dernier mouvement : les morceaux reviennent et le mouvement vous est rendu." },
|
||||
"balanced": { "name": "Voir le modèle", "text": "L’illustration entière s’affiche pendant 5 secondes." }
|
||||
},
|
||||
"toHard": "Passer au Difficile",
|
||||
"wonTitle": "Image reconstituée !",
|
||||
"lostTitle": "Plus d’échange",
|
||||
"lostTitle": "Plus de mouvement",
|
||||
"lostText": "{placed} morceaux sur {total} sont à leur place.",
|
||||
"resultSwaps": "{swaps} échanges. Meilleur résultat de l’ordinateur : {par}.",
|
||||
"resultSwaps": "{swaps} mouvements. Meilleur résultat de l’ordinateur : {par}.",
|
||||
"resultBetter": "Vous avez fait mieux que l’ordinateur !",
|
||||
"revealed": "Illustration : {card}",
|
||||
"share": "Copier le résultat",
|
||||
"shared": "Résultat copié",
|
||||
"shareText": { "name": "Miroir brisé", "won": "{swaps} échanges (ordinateur : {par})", "lost": "✗ {placed}/{total} morceaux", "help": "{count} coup de main", "helps": "{count} coups de main" },
|
||||
"shareText": { "name": "Miroir brisé", "won": "{swaps} mouvements (ordinateur : {par})", "lost": "✗ {placed}/{total} morceaux", "help": "{count} coup de main", "helps": "{count} coups de main" },
|
||||
"next": "Nouvelles images dans {time}.",
|
||||
"devReset": "Rejouer (développement)"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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") {
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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>}
|
||||
</>}
|
||||
|
|
|
|||
|
|
@ -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é ?"}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -80,3 +80,6 @@
|
|||
.nebula-mirror-board, .nebula-mirror-frame { transition: none; }
|
||||
.nebula-mirror-piece[data-hint] { animation: none; box-shadow: inset 0 0 0 3px var(--color-accent-gold); }
|
||||
}
|
||||
// Orientation : le plateau attend le morceau visé.
|
||||
.nebula-mirror-board[data-aiming] .nebula-mirror-piece { cursor: help; }
|
||||
.nebula-mirror-board[data-aiming] .nebula-mirror-piece:hover { box-shadow: inset 0 0 0 3px var(--color-stat-orientation); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue