diff --git a/README.md b/README.md index 57fe86d..5f2d947 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ Le moteur est piloté par les données : tout le contenu d'un chapitre (points d | Reculer | flèche en bas de l'écran, clic droit ou `Échap` | | Utiliser un objet | clic sur l'objet dans l'inventaire, puis sur la cible | | Combiner deux objets | clic sur un objet de l'inventaire, puis sur un autre objet de l'inventaire | +| Fermer un message | clic n'importe où (ou `Échap`) | +| Carnet d'indices | bouton **Carnet** ou `C` ; « Noter dans le carnet » sous les messages qui révèlent un indice | | Indice progressif | bouton **Indice** ou `H` | | Mode debug | `D` : caméra libre (glisser = orbiter, molette = zoom). Affiche l'objet visé et le point 3D. `C` copie le point de vue en JSON `"camera"` | @@ -32,7 +34,7 @@ La partie est sauvegardée automatiquement dans le navigateur (bouton « Continu **Difficulté** (au lancement d'une partie) : - **Facile** : les objets interactifs s'entourent d'un contour doré et affichent leur nom au survol ; -- **Difficile** : seul le curseur change, et les flèches de navigation restent indiquées. +- **Difficile** : aucun indice visuel sur les objets (ni contour, ni nom, ni changement de curseur). Seules les flèches de navigation restent indiquées. ## Le chapitre 1 : le bureau du professeur @@ -115,6 +117,9 @@ tests/ - **Déclencheurs** (`triggers`) : des actions exécutées une seule fois, dès que leurs conditions deviennent vraies. Par exemple, le coffret s'ouvre quand les 4 molettes affichent le bon code. - **Combinaisons** (`combinations`) : deux objets d'inventaire et les actions à exécuter quand on les combine. - **Variables initiales** (`vars`) : par exemple, la position de départ des molettes. +- **Indices** (`clues`) : textes que le joueur peut noter dans son carnet. L'action `{ "clue": "id" }`, placée après un message, ajoute le bouton « Noter dans le carnet ». +- **Lampe UV** (`uvLight`) : objet qui, tenu en main, projette un halo sous la souris. Les surfaces en encre invisible (`invisibleInk()` dans le monde) n'apparaissent que dans ce halo, jusqu'à leur révélation par la prop `reveal`. +- **Objet obtenu** : toute action `give` déclenche l'annonce centrale « Objet obtenu » et fait clignoter la case. ### Choix structurants diff --git a/src/engine/BaseRenderer.ts b/src/engine/BaseRenderer.ts index c018f33..897dc4a 100644 --- a/src/engine/BaseRenderer.ts +++ b/src/engine/BaseRenderer.ts @@ -1,7 +1,7 @@ import { isMuted, playSound, setMuted } from './audio'; import { cursorCss } from './cursors'; import type { Engine, MessageKind, Transition, View } from './Engine'; -import type { CursorKind, Hotspot, PuzzleDef, Scene } from './types'; +import type { Clue, CursorKind, Hotspot, Item, PuzzleDef, Scene } from './types'; import { getPuzzleFactory, type PuzzleContext, type PuzzleInstance } from '../puzzles/registry'; export interface RendererOptions { @@ -49,6 +49,13 @@ export abstract class BaseRenderer implements View { protected debugEl: HTMLElement; protected debug = false; private messageEl: HTMLElement; + private messageText: HTMLElement; + private toastEl: HTMLElement; + private uvHaloEl: HTMLElement; + private notebookBtn: HTMLButtonElement; + private notebookEl: HTMLElement | null = null; + /** Dernier objet obtenu : sa case clignote dans l'inventaire. */ + private freshItem: string | null = null; private tooltipEl: HTMLElement; private puzzleLayer: HTMLElement; private inventoryEl: HTMLElement; @@ -75,6 +82,9 @@ export abstract class BaseRenderer implements View { this.sceneLayer = el('div', 'scenes', this.stage); this.hotspotsEl = el('div', 'hotspots', this.stage); this.messageEl = el('div', 'message', this.stage); + this.messageText = el('span', 'message-text', this.messageEl); + this.toastEl = el('div', 'item-toast', this.stage); + this.uvHaloEl = el('div', 'uv-halo', this.stage); this.tooltipEl = el('div', 'tooltip', this.stage); this.puzzleLayer = el('div', 'puzzle-layer', this.stage); this.debugEl = el('div', 'debug-info', this.stage); @@ -83,6 +93,9 @@ export abstract class BaseRenderer implements View { this.inventoryEl = el('div', 'inventory', hud); const right = el('div', 'hud-right', hud); this.timerEl = el('div', 'timer', right); + this.notebookBtn = el('button', 'hud-btn notebook-btn', right); + this.notebookBtn.title = 'Carnet d’indices (C)'; + this.notebookBtn.onclick = () => this.toggleNotebook(); const hintBtn = el('button', 'hud-btn', right); hintBtn.innerHTML = '? Indice'; hintBtn.title = 'Obtenir un indice (H)'; @@ -99,6 +112,15 @@ export abstract class BaseRenderer implements View { this.heldEl = el('div', 'held-item', this.root); + // Le message en cours se ferme au clic suivant, n'importe où dans la scène. + this.stage.addEventListener( + 'pointerdown', + (e) => { + if ((e.target as HTMLElement).closest('.message button')) return; + this.hideMessage(); + }, + true, + ); this.stage.addEventListener('contextmenu', (e) => { e.preventDefault(); if (!this.puzzle) engine.goBack(); @@ -139,8 +161,12 @@ export abstract class BaseRenderer implements View { private onKey = (e: KeyboardEvent): void => { if (e.key === 'Escape') { - if (this.puzzle) this.closePuzzle(); + if (this.notebookEl) this.toggleNotebook(false); + else if (this.puzzle) this.closePuzzle(); + else if (this.messageEl.classList.contains('visible')) this.hideMessage(); else this.engine.goBack(); + } else if ((e.key === 'c' || e.key === 'C') && !this.debug) { + this.toggleNotebook(); } else if (e.key === 'h' || e.key === 'H') { this.engine.nextHint(); } else if (e.key === 'd' || e.key === 'D') { @@ -163,6 +189,9 @@ export abstract class BaseRenderer implements View { this.refreshStage(instant); this.renderRectHotspots(); this.renderInventory(); + const n = this.engine.state.notebook.length; + this.notebookBtn.innerHTML = `Carnet${n ? ` ${n}` : ''}`; + if (this.notebookEl) this.renderNotebook(); } /** Zones écran (rect) : flèches de navigation et zones écran éventuelles. */ @@ -204,7 +233,10 @@ export abstract class BaseRenderer implements View { } protected cursorFor(hs: Hotspot): string { - if (this.engine.state.selected && !hs.id.startsWith('__')) return cursorCss('use'); + const isNav = hs.id.startsWith('__'); + // En Difficile, aucun indice visuel sur les objets : au joueur de tester. + if (!isNav && this.engine.state.difficulty === 'hard') return 'default'; + if (this.engine.state.selected && !isNav) return cursorCss('use'); let kind: CursorKind = 'look'; if (hs.cursor) kind = hs.cursor; else { @@ -250,12 +282,15 @@ export abstract class BaseRenderer implements View { slot.title = item ? `${item.name}${item.description ? ' — ' + item.description : ''}` : id; slot.dataset.item = id; slot.classList.toggle('selected', state.selected === id); + if (id === this.freshItem) slot.classList.add('fresh'); slot.onclick = () => { const sel = this.engine.state.selected; if (sel && sel !== id) this.engine.combine(sel, id); else this.engine.selectItem(id); }; } + const uv = this.engine.scenario.uvLight; + this.uvHaloEl.classList.toggle('visible', !!uv && state.selected === uv.item); const held = state.selected ? this.engine.getItem(state.selected) : undefined; if (held) { this.heldEl.style.backgroundImage = `url("${this.opts.resolveImage(held.icon)}")`; @@ -270,15 +305,92 @@ export abstract class BaseRenderer implements View { showMessage(text: string, kind: MessageKind): void { window.clearTimeout(this.messageTimer); this.messageEl.className = `message visible ${kind}`; - this.messageEl.textContent = text; + this.messageText.textContent = text; + this.messageEl.querySelector('.clue-btn')?.remove(); if (kind === 'hint') playSound('beep'); - this.messageTimer = window.setTimeout(() => this.hideMessage(), Math.max(3500, text.length * 60)); + // Fermeture automatique (le clic suivant le ferme aussi). + this.messageTimer = window.setTimeout(() => this.hideMessage(), Math.max(5000, text.length * 70)); } protected hideMessage(): void { + window.clearTimeout(this.messageTimer); this.messageEl.classList.remove('visible'); } + /** Bouton « Noter dans le carnet » sous le message courant. */ + offerClue(clue: Clue): void { + this.messageEl.querySelector('.clue-btn')?.remove(); + const btn = el('button', 'clue-btn', this.messageEl); + btn.textContent = 'Noter dans le carnet'; + btn.title = clue.text; + btn.onclick = (e) => { + e.stopPropagation(); + this.engine.noteClue(clue.id); + btn.textContent = 'Noté ✓'; + btn.disabled = true; + this.notebookBtn.classList.remove('pulse'); + void this.notebookBtn.offsetWidth; + this.notebookBtn.classList.add('pulse'); + window.setTimeout(() => this.hideMessage(), 700); + }; + // Laisse le temps de cliquer : la fermeture automatique est repoussée. + window.clearTimeout(this.messageTimer); + this.messageTimer = window.setTimeout(() => this.hideMessage(), 9000); + } + + /** Annonce centrale « Objet obtenu » + case de l'inventaire qui clignote. */ + itemGained(item: Item): void { + this.toastEl.innerHTML = ''; + const img = el('img', '', this.toastEl); + img.src = this.opts.resolveImage(item.icon); + img.alt = ''; + el('div', 'item-toast-label', this.toastEl).textContent = 'Objet obtenu'; + el('div', 'item-toast-name', this.toastEl).textContent = item.name; + this.toastEl.classList.remove('show'); + void this.toastEl.offsetWidth; + this.toastEl.classList.add('show'); + this.freshItem = item.id; + window.setTimeout(() => { + if (this.freshItem === item.id) this.freshItem = null; + }, 2600); + } + + // --- Carnet ---------------------------------------------------------------------- + + private toggleNotebook(open = !this.notebookEl): void { + if (!open) { + this.notebookEl?.remove(); + this.notebookEl = null; + return; + } + if (this.notebookEl) return; + this.hideTooltip(); + const overlay = el('div', 'puzzle-overlay visible notebook-overlay', this.puzzleLayer); + overlay.addEventListener('click', (e) => { + if (e.target === overlay) this.toggleNotebook(false); + }); + this.notebookEl = overlay; + this.renderNotebook(); + } + + private renderNotebook(): void { + if (!this.notebookEl) return; + const ids = this.engine.state.notebook; + this.notebookEl.innerHTML = ''; + const book = el('div', 'notebook', this.notebookEl); + const close = el('button', 'puzzle-close', book); + close.textContent = '×'; + close.title = 'Fermer (Échap)'; + close.onclick = () => this.toggleNotebook(false); + el('h3', '', book).textContent = 'Carnet'; + if (!ids.length) { + el('p', 'notebook-empty', book).textContent = 'Aucune note pour l’instant. Quand vous découvrez un indice, choisissez « Noter dans le carnet ».'; + return; + } + const list = el('ol', '', book); + for (const id of ids) el('li', '', list).textContent = this.engine.getClue(id)?.text ?? id; + } + // --- Puzzles ------------------------------------------------------------------------ openPuzzle(def: PuzzleDef, ctx: PuzzleContext): void { @@ -325,6 +437,7 @@ export abstract class BaseRenderer implements View { protected onMouseMove(e: MouseEvent): void { this.heldEl.style.transform = `translate(${e.clientX + 14}px, ${e.clientY + 14}px)`; const r = this.stage.getBoundingClientRect(); + this.uvHaloEl.style.transform = `translate(${e.clientX - r.left}px, ${e.clientY - r.top}px) translate(-50%, -50%)`; // Décalage plus grand quand un objet est tenu, pour ne pas masquer son icône. const dy = this.engine.state.selected ? 62 : 22; const tx = Math.min(e.clientX - r.left + 18, r.width - this.tooltipEl.offsetWidth - 8); diff --git a/src/engine/Engine.ts b/src/engine/Engine.ts index da4d736..ead0161 100644 --- a/src/engine/Engine.ts +++ b/src/engine/Engine.ts @@ -1,6 +1,6 @@ import { playSound } from './audio'; import { checkAll, saveState, type GameState } from './state'; -import type { Action, Hotspot, Interaction, Item, PuzzleDef, Scenario, Scene } from './types'; +import type { Action, Clue, Hotspot, Interaction, Item, PuzzleDef, Scenario, Scene } from './types'; import type { PuzzleContext } from '../puzzles/registry'; export type MessageKind = 'info' | 'hint' | 'item'; @@ -14,6 +14,10 @@ export interface View { showScene(scene: Scene, transition: Transition): void; refresh(): void; showMessage(text: string, kind: MessageKind): void; + /** Ajoute au message courant la proposition de noter cet indice. */ + offerClue?(clue: Clue): void; + /** Annonce d'un objet obtenu. */ + itemGained?(item: Item): void; openPuzzle(def: PuzzleDef, ctx: PuzzleContext): void; closePuzzle(): void; showWin(): void; @@ -80,6 +84,20 @@ export class Engine { return this.items.get(id); } + getClue(id: string): Clue | undefined { + return this.scenario.clues?.find((c) => c.id === id); + } + + /** Note un indice dans le carnet. Renvoie false s'il y était déjà ou n'existe pas. */ + noteClue(id: string): boolean { + if (!this.getClue(id) || this.state.notebook.includes(id)) return false; + this.state.notebook.push(id); + playSound('pickup'); + saveState(this.state); + this.view.refresh(); + return true; + } + /** Zones actives de la scène, y compris les bandes de navigation générées. */ activeHotspots(scene: Scene): Hotspot[] { const [w, h] = this.scenario.resolution; @@ -211,7 +229,11 @@ export class Engine { } else if ('clearFlag' in action) { delete this.state.flags[action.clearFlag]; } else if ('give' in action) { - if (!this.state.inventory.includes(action.give)) this.state.inventory.push(action.give); + if (!this.state.inventory.includes(action.give)) { + this.state.inventory.push(action.give); + const item = this.getItem(action.give); + if (item) this.view.itemGained?.(item); + } playSound('pickup'); } else if ('remove' in action) { this.state.inventory = this.state.inventory.filter((i) => i !== action.remove); @@ -228,6 +250,9 @@ export class Engine { this.state.vars[action.set] = action.value; } else if ('if' in action) { for (const a of checkAll(this.state, action.if) ? action.then : (action.else ?? [])) this.exec(a); + } else if ('clue' in action) { + const clue = this.getClue(action.clue); + if (clue && !this.state.notebook.includes(clue.id)) this.view.offerClue?.(clue); } else if ('win' in action) { this.state.won = true; this.state.selected = null; diff --git a/src/engine/scenarioAnalysis.ts b/src/engine/scenarioAnalysis.ts index 8178881..967faf0 100644 --- a/src/engine/scenarioAnalysis.ts +++ b/src/engine/scenarioAnalysis.ts @@ -95,6 +95,10 @@ export function analyzeScenario(s: Scenario): string[] { trig.add(t.id); } + // Indices : chacun doit pouvoir être proposé au joueur + const offered = new Set(actions.flatMap(({ a }) => ('clue' in a ? [a.clue] : []))); + for (const c of s.clues ?? []) if (!offered.has(c.id)) errors.push(`indice "${c.id}" : jamais proposé (action clue)`); + // Scènes accessibles depuis le départ const edges = new Map(); for (const sc of s.scenes) { diff --git a/src/engine/scenarioLoader.ts b/src/engine/scenarioLoader.ts index 7c35808..ac43e34 100644 --- a/src/engine/scenarioLoader.ts +++ b/src/engine/scenarioLoader.ts @@ -42,6 +42,7 @@ export function validateScenario(s: Scenario, imageExists: (p: string) => boolea const scenes = new Set(s.scenes.map((x) => x.id)); const items = new Set(s.items.map((x) => x.id)); const puzzles = new Set(s.puzzles.map((x) => x.id)); + const clues = new Set((s.clues ?? []).map((x) => x.id)); const checkConds = (where: string, conds?: Condition[]) => conds?.forEach((c) => { @@ -61,6 +62,7 @@ export function validateScenario(s: Scenario, imageExists: (p: string) => boolea checkActions(where, a.then); checkActions(where, a.else ?? []); } + if ('clue' in a && !clues.has(a.clue)) errors.push(`${where} : indice inconnu "${a.clue}"`); if ('remove' in a && !items.has(a.remove)) errors.push(`${where} : objet inconnu "${a.remove}"`); if ('goto' in a && !scenes.has(a.goto)) errors.push(`${where} : scène inconnue "${a.goto}"`); if ('give' in a && !items.has(a.give)) errors.push(`${where} : objet inconnu "${a.give}"`); @@ -72,6 +74,7 @@ export function validateScenario(s: Scenario, imageExists: (p: string) => boolea if (!scenes.has(s.startScene)) errors.push(`startScene inconnue "${s.startScene}"`); if (!s.world) errors.push(`"world" manquant`); + if (s.uvLight && !items.has(s.uvLight.item)) errors.push(`uvLight : objet inconnu "${s.uvLight.item}"`); for (const sc of s.scenes) { if (!sc.camera) errors.push(`scène ${sc.id} : "camera" manquante`); for (const nav of [sc.left, sc.right, sc.back]) if (nav && !scenes.has(nav)) errors.push(`scène ${sc.id} : navigation vers "${nav}" inconnue`); diff --git a/src/engine/state.ts b/src/engine/state.ts index 3f86238..2e14fc4 100644 --- a/src/engine/state.ts +++ b/src/engine/state.ts @@ -19,6 +19,8 @@ export interface GameState { /** Déclencheurs déjà exécutés. */ fired: Record; difficulty: Difficulty; + /** Indices notés dans le carnet (identifiants, dans l'ordre). */ + notebook: string[]; } export function newState(scenarioId: string, startScene: string, difficulty: Difficulty = 'easy'): GameState { @@ -26,6 +28,7 @@ export function newState(scenarioId: string, startScene: string, difficulty: Dif scenarioId, vars: {}, fired: {}, + notebook: [], difficulty, scene: startScene, flags: {}, diff --git a/src/engine/three/ThreeRenderer.ts b/src/engine/three/ThreeRenderer.ts index f441e0d..4fde90e 100644 --- a/src/engine/three/ThreeRenderer.ts +++ b/src/engine/three/ThreeRenderer.ts @@ -11,7 +11,7 @@ import type { Engine, Transition } from '../Engine'; import { checkAll } from '../state'; import type { CameraView, Hotspot, Scene } from '../types'; import { buildWorld, type World } from '../../worlds'; -import { PICK_LAYER } from '../../worlds/common'; +import { PICK_LAYER, UV_LIGHT } from '../../worlds/common'; interface CamPose { pos: THREE.Vector3; @@ -26,6 +26,8 @@ interface PropEntry { baseVisible: boolean; /** Lumière : on ne la masque jamais (changer le nombre de lumières recompile tous les shaders), on l'éteint. */ light?: { obj: THREE.Light; intensity: number }; + /** Encre invisible : uniforme « révélée en permanence ». */ + ink?: { value: number }; mats: { mat: THREE.MeshStandardMaterial; color: THREE.Color; emissive: THREE.Color; intensity: number }[]; } @@ -77,6 +79,7 @@ export class ThreeRenderer extends BaseRenderer { /** Rendu à la demande : on ne redessine que si quelque chose a changé. */ private dirty = true; private hoveredObj: THREE.Object3D | null = null; + private lastHitPoint: THREE.Vector3 | null = null; readonly quality: 'high' | 'low'; /** ?test=1 : basse qualité, caméra et objets sans animation (tests automatisés). */ readonly testMode: boolean; @@ -185,7 +188,8 @@ export class ThreeRenderer extends BaseRenderer { } }); const light = (obj as THREE.Light).isLight ? { obj: obj as THREE.Light, intensity: (obj as THREE.Light).intensity } : undefined; - this.props.set(rule.object, { obj, basePos: obj.position.clone(), baseQuat: obj.quaternion.clone(), baseVisible: obj.visible, mats, light }); + const ink = ((obj as THREE.Mesh).material as THREE.Material | undefined)?.userData?.uRevealed as { value: number } | undefined; + this.props.set(rule.object, { obj, basePos: obj.position.clone(), baseQuat: obj.quaternion.clone(), baseVisible: obj.visible, mats, light, ink }); } for (const scene of scenario.scenes) for (const hs of scene.hotspots) @@ -323,6 +327,9 @@ export class ThreeRenderer extends BaseRenderer { protected refreshStage(instant: boolean): void { this.dirty = true; + UV_LIGHT.uUvActive.value = this.uvActive ? 1 : 0; + UV_LIGHT.uUvRadius.value = this.engine.scenario.uvLight?.radius ?? 0.14; + if (!this.uvActive) UV_LIGHT.uUvPoint.value.set(0, -100, 0); const state = this.engine.state; // Zones 3D actives de la scène courante this.hotspotByName.clear(); @@ -337,12 +344,14 @@ export class ThreeRenderer extends BaseRenderer { const quat = p.baseQuat.clone(); let visible = p.baseVisible; let emissive: string | null = null; + let revealed = false; for (const rule of this.engine.scenario.props ?? []) { if (rule.object !== name || !checkAll(state, rule.when)) continue; if (rule.visible !== undefined) visible = rule.visible; if (rule.offset) pos.add(new THREE.Vector3(...rule.offset)); if (rule.rotation) quat.setFromEuler(new THREE.Euler(...rule.rotation)); if (rule.emissive) emissive = rule.emissive; + if (rule.reveal !== undefined) revealed = rule.reveal; if (rule.spin) { const angle = (state.vars[rule.spin.var] ?? 0) * rule.spin.step; quat.multiply(new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(...rule.spin.axis).normalize(), angle)); @@ -352,6 +361,7 @@ export class ThreeRenderer extends BaseRenderer { p.light.obj.visible = true; p.light.obj.intensity = visible ? p.light.intensity : 0; } else p.obj.visible = visible; + if (p.ink) p.ink.value = revealed ? 1 : 0; for (const m of p.mats) { if (emissive) { m.mat.emissive.set(emissive); @@ -395,6 +405,7 @@ export class ThreeRenderer extends BaseRenderer { const hits = this.raycaster.intersectObject(this.world.root, true); const hit = hits.find((h) => this.isVisibleDeep(h.object)); if (!hit) { + this.lastHitPoint = null; this.debugHit = ''; return { hs: null, obj: null }; } @@ -404,6 +415,7 @@ export class ThreeRenderer extends BaseRenderer { if (o.name) chain.push(o.name); if (!found.hs && o.name && this.hotspotByName.has(o.name)) found = { hs: this.hotspotByName.get(o.name)!, obj: o }; } + this.lastHitPoint = hit.point.clone(); const p = hit.point; this.debugHit = `objet : ${chain.join(' ‹ ') || '(sans nom)'} · point : [${round(p.x)}, ${round(p.y)}, ${round(p.z)}]`; return found; @@ -427,6 +439,16 @@ export class ThreeRenderer extends BaseRenderer { if (this.puzzleOpen) return; const { hs, obj } = this.pick(e); this.setHovered(this.camAnim ? null : hs, this.camAnim ? null : obj); + // Lampe UV en main : le halo suit le point visé et révèle l'encre invisible. + if (this.uvActive) { + UV_LIGHT.uUvPoint.value.copy(this.lastHitPoint ?? new THREE.Vector3(0, -100, 0)); + this.dirty = true; + } + } + + private get uvActive(): boolean { + const uv = this.engine.scenario.uvLight; + return !!uv && this.engine.state.selected === uv.item; } private onClick(e: MouseEvent): void { diff --git a/src/engine/types.ts b/src/engine/types.ts index 6bbb7fe..5ab4e9b 100644 --- a/src/engine/types.ts +++ b/src/engine/types.ts @@ -33,7 +33,9 @@ export type Action = | { add: string; value?: number; mod?: number } | { set: string; value: number } /** Action conditionnelle. */ - | { if: Condition[]; then: Action[]; else?: Action[] }; + | { if: Condition[]; then: Action[]; else?: Action[] } + /** Propose de noter un indice dans le carnet (bouton dans le message affiché). */ + | { clue: string }; export type SoundName = 'click' | 'step' | 'success' | 'error' | 'unlock' | 'drawer' | 'pickup' | 'beep' | 'dial' | 'switch' | 'power' | 'reveal'; @@ -81,6 +83,8 @@ export interface PropRule { rotation?: Vec3; /** Couleur émissive (allume un voyant, une lampe...). */ emissive?: string; + /** Encre invisible : true = révélée en permanence (sinon visible seulement sous la lampe UV). */ + reveal?: boolean; /** * Rotation pilotée par une variable : angle = valeur × step (radians) * autour de `axis`, ajoutée à la rotation initiale. Ex. une molette de cadenas. @@ -103,6 +107,19 @@ export interface Combination { export type Difficulty = 'easy' | 'hard'; +/** Indice que le joueur peut noter dans son carnet. */ +export interface Clue { + id: string; + text: string; +} + +/** Objet d'inventaire qui, tenu en main, éclaire en UV sous la souris (révèle l'encre invisible). */ +export interface UvLight { + item: string; + /** Rayon du halo dans le monde, en mètres. */ + radius?: number; +} + export interface Scene { id: string; title?: string; @@ -159,4 +176,6 @@ export interface Scenario { combinations?: Combination[]; /** Valeurs initiales des variables (ex. position de départ des molettes). */ vars?: Record; + clues?: Clue[]; + uvLight?: UvLight; } diff --git a/src/engine/walkthrough.ts b/src/engine/walkthrough.ts index 248bdaa..f6ca519 100644 --- a/src/engine/walkthrough.ts +++ b/src/engine/walkthrough.ts @@ -14,9 +14,10 @@ import type { PuzzleContext } from '../puzzles/registry'; * { "use": "key", "on": "lock" } sélectionner un objet puis cliquer sur une zone * { "combine": ["uvlamp", "batteries"] } combiner deux objets de l'inventaire * { "solve": "cipher" } résoudre le mini-jeu ouvert à l'écran + * { "note": "digit3" } noter l'indice proposé par le dernier message * Chaque étape peut vérifier l'état après coup : "expect": ["item:key", "scene:desk", "won"]. */ -export type WalkStep = ({ click: string; times?: number } | { use: string; on: string } | { combine: [string, string] } | { solve: string }) & { +export type WalkStep = ({ click: string; times?: number } | { use: string; on: string } | { combine: [string, string] } | { solve: string } | { note: string }) & { expect?: string[]; }; @@ -35,12 +36,17 @@ export interface WalkResult { class HeadlessView implements View { messages: string[] = []; + offered: string | null = null; puzzle: { def: PuzzleDef; ctx: PuzzleContext } | null = null; won = false; showScene(): void {} refresh(): void {} showMessage(text: string): void { this.messages.push(text); + this.offered = null; + } + offerClue(clue: { id: string }): void { + this.offered = clue.id; } openPuzzle(def: PuzzleDef, ctx: PuzzleContext): void { this.puzzle = { def, ctx }; @@ -89,6 +95,9 @@ export function runWalkthrough(scenario: Scenario, wt: Walkthrough): WalkResult const missing = step.combine.filter((it) => !state.inventory.includes(it)); if (missing.length) err = `objets absents de l'inventaire : ${missing.join(', ')}`; else if (!engine.combine(step.combine[0], step.combine[1])) err = `combinaison ${step.combine.join(' + ')} sans effet`; + } else if ('note' in step) { + if (view.offered !== step.note) err = `l'indice "${step.note}" n'est pas proposé par le dernier message (proposé : ${view.offered ?? 'aucun'})`; + else engine.noteClue(step.note); } else if ('solve' in step) { if (view.puzzle?.def.id !== step.solve) err = `le mini-jeu "${step.solve}" n'est pas ouvert (ouvert : ${view.puzzle?.def.id ?? 'aucun'})`; else view.puzzle.ctx.solve(); diff --git a/src/main.ts b/src/main.ts index bd8c944..a273a82 100644 --- a/src/main.ts +++ b/src/main.ts @@ -34,7 +34,7 @@ function showMenu(): void {

ESCAPE

Prototype · moteur point & click

-

Clic : examiner · flèches : tourner / reculer (ou clic droit, Échap) · objet en main + autre objet : combiner · H : indice · D : mode debug

+

Clic : examiner · flèches : tourner / reculer (ou clic droit, Échap) · objet en main + autre objet : combiner · C : carnet · H : indice · D : mode debug

Facile : objets surlignés et nommés au survol · Difficile : seul le curseur vous guide

`; const list = screen.querySelector('.chapters')!; diff --git a/src/scenarios/chapitre1/scenario.json b/src/scenarios/chapitre1/scenario.json index f18f272..d653424 100644 --- a/src/scenarios/chapitre1/scenario.json +++ b/src/scenarios/chapitre1/scenario.json @@ -4,33 +4,73 @@ "subtitle": "Le professeur Lindqvist a disparu en laissant son bureau truffé d’énigmes. Cinq mécanismes vous séparent de la sortie. Durée : 15 à 20 minutes.", "difficulty": 2, "world": "bureau", - "resolution": [1280, 720], + "resolution": [ + 1280, + 720 + ], "startScene": "north", "intro": "Vous vous réveillez dans le bureau du professeur Lindqvist. La porte est verrouillée et le plafonnier ne fonctionne plus… Fouillez la pièce : le professeur aimait les secrets.", "outro": "La clé tourne dans la serrure avec un claquement sec. La porte s’ouvre sur un couloir éclairé… Le professeur Lindqvist cachait bien d’autres secrets. Fin du chapitre 1.", - - "vars": { "dial1": 3, "dial2": 7, "dial3": 2, "dial4": 5 }, - + "vars": { + "dial1": 3, + "dial2": 7, + "dial3": 2, + "dial4": 5 + }, "items": [ - { "id": "uvlamp", "name": "Lampe UV", "icon": "images/uvlamp.svg", "description": "Une petite lampe à ultraviolets. Elle n’a pas de piles." }, - { "id": "batteries", "name": "Piles", "icon": "images/batteries.svg", "description": "Deux piles, encore chargées." }, - { "id": "uvlampOn", "name": "Lampe UV allumée", "icon": "images/uvlamp_on.svg", "description": "Sa lumière violette révèle les encres invisibles." }, - { "id": "lever", "name": "Manette", "icon": "images/lever.svg", "description": "Une manette à poignée rouge, comme celles des disjoncteurs." }, - { "id": "key", "name": "Clé en laiton", "icon": "images/key.svg", "description": "Une vieille clé, lourde et finement ouvragée." } + { + "id": "uvlamp", + "name": "Lampe UV", + "icon": "images/uvlamp.svg", + "description": "Une petite lampe à ultraviolets. Elle n’a pas de piles." + }, + { + "id": "batteries", + "name": "Piles", + "icon": "images/batteries.svg", + "description": "Deux piles, encore chargées." + }, + { + "id": "uvlampOn", + "name": "Lampe UV allumée", + "icon": "images/uvlamp_on.svg", + "description": "Sa lumière violette révèle les encres invisibles." + }, + { + "id": "lever", + "name": "Manette", + "icon": "images/lever.svg", + "description": "Une manette à poignée rouge, comme celles des disjoncteurs." + }, + { + "id": "key", + "name": "Clé en laiton", + "icon": "images/key.svg", + "description": "Une vieille clé, lourde et finement ouvragée." + } ], - "combinations": [ { - "items": ["uvlamp", "batteries"], + "items": [ + "uvlamp", + "batteries" + ], "do": [ - { "remove": "uvlamp" }, - { "remove": "batteries" }, - { "give": "uvlampOn" }, - { "message": "Vous glissez les piles dans la lampe : une lueur violette s’allume." } + { + "remove": "uvlamp" + }, + { + "remove": "batteries" + }, + { + "give": "uvlampOn" + }, + { + "message": "Vous glissez les piles dans la lampe : une lueur violette s’allume." + } ] } ], - "puzzles": [ { "id": "cipher", @@ -41,7 +81,14 @@ "ciphertext": "SL JVMMYL Z'VBCYL H S'OLBYL VB SL ALTWZ Z'LZA HYYLAL", "shift": 7 }, - "onSolve": [{ "message": "« LE COFFRE S’OUVRE À L’HEURE OÙ LE TEMPS S’EST ARRÊTÉ »" }] + "onSolve": [ + { + "message": "« LE COFFRE S’OUVRE À L’HEURE OÙ LE TEMPS S’EST ARRÊTÉ »" + }, + { + "clue": "cipher" + } + ] }, { "id": "colorPanel", @@ -50,96 +97,553 @@ "params": { "caption": "Commande", "colors": [ - { "id": "red", "label": "Rouge", "hex": "#d64541" }, - { "id": "blue", "label": "Bleu", "hex": "#3a7bd5" }, - { "id": "green", "label": "Vert", "hex": "#3fae5a" }, - { "id": "yellow", "label": "Jaune", "hex": "#f2c230" }, - { "id": "purple", "label": "Violet", "hex": "#8e5bd0" }, - { "id": "white", "label": "Blanc", "hex": "#e8e8e8" } + { + "id": "red", + "label": "Rouge", + "hex": "#d64541" + }, + { + "id": "blue", + "label": "Bleu", + "hex": "#3a7bd5" + }, + { + "id": "green", + "label": "Vert", + "hex": "#3fae5a" + }, + { + "id": "yellow", + "label": "Jaune", + "hex": "#f2c230" + }, + { + "id": "purple", + "label": "Violet", + "hex": "#8e5bd0" + }, + { + "id": "white", + "label": "Blanc", + "hex": "#e8e8e8" + } ], - "solution": ["yellow", "red", "blue", "green"] + "solution": [ + "yellow", + "red", + "blue", + "green" + ] }, "onSolve": [ - { "setFlag": "drawer_open" }, - { "sound": "drawer" }, - { "message": "Un déclic sourd résonne dans la pièce… quelque chose s’est ouvert du côté du bureau." } + { + "setFlag": "drawer_open" + }, + { + "sound": "drawer" + }, + { + "message": "Un déclic sourd résonne dans la pièce… quelque chose s’est ouvert du côté du bureau." + } ] } ], - "triggers": [ { "id": "safeCode", - "when": ["var:dial1=1", "var:dial2=0", "var:dial3=4", "var:dial4=0"], + "when": [ + "var:dial1=1", + "var:dial2=0", + "var:dial3=4", + "var:dial4=0" + ], "do": [ - { "setFlag": "safe_open" }, - { "sound": "unlock" }, - { "message": "1-0-4-0 : clic ! La porte du coffret s’entrouvre." } + { + "setFlag": "safe_open" + }, + { + "sound": "unlock" + }, + { + "message": "1-0-4-0 : clic ! La porte du coffret s’entrouvre." + } ] } ], - "props": [ - { "object": "uvMessage", "when": ["!flag:uv_painting"], "visible": false }, - - { "object": "dial1", "spin": { "var": "dial1", "axis": [1, 0, 0], "step": 0.6283 } }, - { "object": "dial2", "spin": { "var": "dial2", "axis": [1, 0, 0], "step": 0.6283 } }, - { "object": "dial3", "spin": { "var": "dial3", "axis": [1, 0, 0], "step": 0.6283 } }, - { "object": "dial4", "spin": { "var": "dial4", "axis": [1, 0, 0], "step": 0.6283 } }, - { "object": "safeDoor", "when": ["flag:safe_open"], "rotation": [0, -1.75, 0] }, - { "object": "leverItem", "when": ["flag:lever_taken"], "visible": false }, - - { "object": "breakerLever", "when": ["!flag:lever_installed"], "visible": false }, - { "object": "breakerLever", "when": ["flag:power_on"], "rotation": [2.79, 0, 0] }, - { "object": "breakerLed", "when": ["!flag:power_on"], "emissive": "#ff3b30" }, - { "object": "breakerLed", "when": ["flag:power_on"], "emissive": "#3fe06a" }, - { "object": "ceilingLight", "when": ["!flag:power_on"], "visible": false }, - { "object": "ceilingBulb", "when": ["flag:power_on"], "emissive": "#ffe6b0" }, - { "object": "paintingSpot", "when": ["!flag:power_on"], "visible": false }, - - { "object": "panelLed", "when": ["flag:power_on"], "emissive": "#ff3b30" }, - { "object": "panelLamp1", "when": ["solved:colorPanel"], "emissive": "#f2c230" }, - { "object": "panelLamp2", "when": ["solved:colorPanel"], "emissive": "#d64541" }, - { "object": "panelLamp3", "when": ["solved:colorPanel"], "emissive": "#3a7bd5" }, - { "object": "panelLamp4", "when": ["solved:colorPanel"], "emissive": "#3fae5a" }, - { "object": "panelLed", "when": ["solved:colorPanel"], "emissive": "#3fe06a" }, - - { "object": "secretDrawer", "when": ["flag:drawer_open"], "offset": [0, 0, 0.3] }, - { "object": "key", "when": ["flag:key_taken"], "visible": false }, - { "object": "door", "when": ["flag:door_open"], "rotation": [0, 1.35, 0] } + { + "object": "uvMessage", + "when": [ + "flag:uv_painting" + ], + "reveal": true + }, + { + "object": "drawerL1", + "when": [ + "flag:drawerL1_open" + ], + "offset": [ + 0, + 0, + 0.3 + ] + }, + { + "object": "uvlampItem", + "when": [ + "flag:uvlamp_found" + ], + "visible": false + }, + { + "object": "flowers", + "when": [ + "flag:vase_open" + ], + "rotation": [ + 0, + 0, + -1.45 + ] + }, + { + "object": "batteriesItem", + "when": [ + "flag:batteries_found" + ], + "visible": false + }, + { + "object": "dial1", + "spin": { + "var": "dial1", + "axis": [ + 1, + 0, + 0 + ], + "step": 0.6283 + } + }, + { + "object": "dial2", + "spin": { + "var": "dial2", + "axis": [ + 1, + 0, + 0 + ], + "step": 0.6283 + } + }, + { + "object": "dial3", + "spin": { + "var": "dial3", + "axis": [ + 1, + 0, + 0 + ], + "step": 0.6283 + } + }, + { + "object": "dial4", + "spin": { + "var": "dial4", + "axis": [ + 1, + 0, + 0 + ], + "step": 0.6283 + } + }, + { + "object": "safeDoor", + "when": [ + "flag:safe_open" + ], + "rotation": [ + 0, + -1.75, + 0 + ] + }, + { + "object": "leverItem", + "when": [ + "flag:lever_taken" + ], + "visible": false + }, + { + "object": "breakerLever", + "when": [ + "!flag:lever_installed" + ], + "visible": false + }, + { + "object": "breakerLever", + "when": [ + "flag:power_on" + ], + "rotation": [ + 2.79, + 0, + 0 + ] + }, + { + "object": "breakerLed", + "when": [ + "!flag:power_on" + ], + "emissive": "#ff3b30" + }, + { + "object": "breakerLed", + "when": [ + "flag:power_on" + ], + "emissive": "#3fe06a" + }, + { + "object": "ceilingLight", + "when": [ + "!flag:power_on" + ], + "visible": false + }, + { + "object": "ceilingBulb", + "when": [ + "flag:power_on" + ], + "emissive": "#ffe6b0" + }, + { + "object": "paintingSpot", + "when": [ + "!flag:power_on" + ], + "visible": false + }, + { + "object": "panelLed", + "when": [ + "flag:power_on" + ], + "emissive": "#ff3b30" + }, + { + "object": "panelLamp1", + "when": [ + "solved:colorPanel" + ], + "emissive": "#f2c230" + }, + { + "object": "panelLamp2", + "when": [ + "solved:colorPanel" + ], + "emissive": "#d64541" + }, + { + "object": "panelLamp3", + "when": [ + "solved:colorPanel" + ], + "emissive": "#3a7bd5" + }, + { + "object": "panelLamp4", + "when": [ + "solved:colorPanel" + ], + "emissive": "#3fae5a" + }, + { + "object": "panelLed", + "when": [ + "solved:colorPanel" + ], + "emissive": "#3fe06a" + }, + { + "object": "secretDrawer", + "when": [ + "flag:drawer_open" + ], + "offset": [ + 0, + 0, + 0.3 + ] + }, + { + "object": "key", + "when": [ + "flag:key_taken" + ], + "visible": false + }, + { + "object": "door", + "when": [ + "flag:door_open" + ], + "rotation": [ + 0, + 1.35, + 0 + ] + } ], - "scenes": [ { "id": "north", "title": "Mur nord — le bureau", - "camera": { "position": [0, 1.6, 0], "target": [0, 1.3, -3], "fov": 55 }, + "camera": { + "position": [ + 0, + 1.6, + 0 + ], + "target": [ + 0, + 1.3, + -3 + ], + "fov": 55 + }, "left": "west", "right": "east", "hotspots": [ - { "id": "desk", "label": "Bureau", "object": "desk", "interactions": [{ "do": [{ "goto": "desk" }] }] }, - { "id": "note", "label": "Mot épinglé", "object": "note", "interactions": [{ "do": [{ "goto": "note" }] }] }, - { "id": "digit3", "label": "Inscription", "cursor": "look", "object": "digit3", "interactions": [{ "do": [{ "message": "Un grand « 3 » peint en bleu, à même le papier peint. La peinture a coulé." }] }] }, - { "id": "clock", "label": "Horloge", "object": "clock", "interactions": [{ "do": [{ "goto": "clock" }] }] }, - { "id": "map", "label": "Carte", "object": "map", "interactions": [{ "do": [{ "message": "Une vieille carte de la Baltique, annotée à la main." }] }] } + { + "id": "desk", + "label": "Bureau", + "object": "desk", + "interactions": [ + { + "do": [ + { + "goto": "desk" + } + ] + } + ] + }, + { + "id": "note", + "label": "Mot épinglé", + "object": "note", + "interactions": [ + { + "do": [ + { + "goto": "note" + } + ] + } + ] + }, + { + "id": "digit3", + "label": "Inscription", + "cursor": "look", + "object": "digit3", + "interactions": [ + { + "do": [ + { + "message": "Un grand « 3 » peint en bleu, à même le papier peint. La peinture a coulé." + }, + { + "clue": "digit3" + } + ] + } + ] + }, + { + "id": "clock", + "label": "Horloge", + "object": "clock", + "interactions": [ + { + "do": [ + { + "goto": "clock" + } + ] + } + ] + }, + { + "id": "map", + "label": "Carte", + "object": "map", + "interactions": [ + { + "do": [ + { + "message": "Une vieille carte de la Baltique, annotée à la main." + } + ] + } + ] + } ] }, { "id": "east", "title": "Mur est — la fenêtre", - "camera": { "position": [0, 1.6, 0], "target": [3, 1.3, 0], "fov": 55 }, + "camera": { + "position": [ + 0, + 1.6, + 0 + ], + "target": [ + 3, + 1.3, + 0 + ], + "fov": 55 + }, "left": "north", "right": "south", "hotspots": [ - { "id": "window", "label": "Fenêtre", "object": ["window", "curtains"], "interactions": [{ "do": [{ "message": "Des planches sont clouées de l’autre côté de la vitre. Aucune issue par ici." }] }] }, - { "id": "painting", "label": "Tableau", "object": "painting", "interactions": [{ "do": [{ "goto": "painting" }] }] }, + { + "id": "window", + "label": "Fenêtre", + "object": [ + "window", + "curtains" + ], + "interactions": [ + { + "do": [ + { + "message": "Des planches sont clouées de l’autre côté de la vitre. Aucune issue par ici." + } + ] + } + ] + }, + { + "id": "painting", + "label": "Tableau", + "object": "painting", + "interactions": [ + { + "do": [ + { + "goto": "painting" + } + ] + } + ] + }, { "id": "vase", "label": "Vase", "object": "vase", "interactions": [ - { "when": ["!flag:batteries_found"], "do": [{ "give": "batteries" }, { "setFlag": "batteries_found" }, { "message": "Quelque chose cliquette au fond du vase… deux piles !" }] }, - { "do": [{ "message": "Des fleurs fanées. Le vase est vide, maintenant." }] } + { + "when": [ + "!flag:vase_open" + ], + "do": [ + { + "setFlag": "vase_open" + }, + { + "goto": "vase" + } + ] + }, + { + "do": [ + { + "goto": "vase" + } + ] + } + ] + } + ] + }, + { + "id": "vase", + "title": "Le vase", + "camera": { + "position": [ + 2.75, + 1.42, + 1.0 + ], + "target": [ + 2.78, + 0.84, + 1.0 + ], + "fov": 24 + }, + "back": "east", + "hotspots": [ + { + "id": "vaseInside", + "label": "Vase", + "cursor": "look", + "object": "vase", + "interactions": [ + { + "when": [ + "flag:batteries_found" + ], + "do": [ + { + "message": "Le fond du vase est vide, maintenant." + } + ] + }, + { + "do": [ + { + "message": "Vous écartez les fleurs fanées : quelque chose brille au fond du vase." + } + ] + } + ] + }, + { + "id": "batteries", + "label": "Piles", + "visibleWhen": [ + "!flag:batteries_found" + ], + "object": "batteriesItem", + "interactions": [ + { + "do": [ + { + "give": "batteries" + }, + { + "setFlag": "batteries_found" + }, + { + "message": "Deux piles, encore chargées." + } + ] + } ] } ] @@ -147,103 +651,531 @@ { "id": "south", "title": "Mur sud — la porte", - "camera": { "position": [0, 1.6, 0], "target": [0, 1.3, 3], "fov": 55 }, + "camera": { + "position": [ + 0, + 1.6, + 0 + ], + "target": [ + 0, + 1.3, + 3 + ], + "fov": 55 + }, "left": "east", "right": "west", "hotspots": [ - { "id": "door", "label": "Porte", "object": "door", "interactions": [{ "do": [{ "goto": "door" }] }] }, + { + "id": "door", + "label": "Porte", + "object": "door", + "interactions": [ + { + "do": [ + { + "goto": "door" + } + ] + } + ] + }, { "id": "panel", "label": "Boîtier de commande", "cursor": "zoom", "object": "panel", "interactions": [ - { "when": ["solved:colorPanel"], "do": [{ "message": "Les quatre voyants sont allumés. Le boîtier ne répond plus." }] }, - { "when": ["!flag:power_on"], "do": [{ "message": "Le boîtier est éteint : son circuit est coupé. Il doit y avoir un disjoncteur quelque part." }] }, - { "do": [{ "puzzle": "colorPanel" }] } + { + "when": [ + "solved:colorPanel" + ], + "do": [ + { + "message": "Les quatre voyants sont allumés. Le boîtier ne répond plus." + } + ] + }, + { + "when": [ + "!flag:power_on" + ], + "do": [ + { + "message": "Le boîtier est éteint : son circuit est coupé. Il doit y avoir un disjoncteur quelque part." + }, + { + "clue": "panel" + } + ] + }, + { + "do": [ + { + "puzzle": "colorPanel" + } + ] + } ] }, - { "id": "digit4", "label": "Inscription", "cursor": "look", "object": "digit4", "interactions": [{ "do": [{ "message": "Un « 4 » vert, peint maladroitement sur les boiseries." }] }] }, - { "id": "mirror", "label": "Miroir", "object": "mirror", "interactions": [{ "do": [{ "message": "Votre reflet a l’air fatigué." }] }] } + { + "id": "digit4", + "label": "Inscription", + "cursor": "look", + "object": "digit4", + "interactions": [ + { + "do": [ + { + "message": "Un « 4 » vert, peint maladroitement sur les boiseries." + }, + { + "clue": "digit4" + } + ] + } + ] + }, + { + "id": "mirror", + "label": "Miroir", + "object": "mirror", + "interactions": [ + { + "do": [ + { + "message": "Votre reflet a l’air fatigué." + } + ] + } + ] + } ] }, { "id": "west", "title": "Mur ouest — la bibliothèque", - "camera": { "position": [0, 1.6, 0], "target": [-3, 1.3, 0], "fov": 55 }, + "camera": { + "position": [ + 0, + 1.6, + 0 + ], + "target": [ + -3, + 1.3, + 0 + ], + "fov": 55 + }, "left": "south", "right": "north", "hotspots": [ - { "id": "shelf", "label": "Bibliothèque", "object": "bookshelf", "interactions": [{ "do": [{ "goto": "shelf" }] }] }, - { "id": "safe", "label": "Coffret", "object": "safe", "interactions": [{ "do": [{ "goto": "safe" }] }] }, - { "id": "breaker", "label": "Disjoncteur", "object": "breaker", "interactions": [{ "do": [{ "goto": "breaker" }] }] }, - { "id": "armchair", "label": "Fauteuil", "object": "armchair", "interactions": [{ "do": [{ "message": "Un fauteuil en cuir usé. Rien sous les coussins." }] }] } + { + "id": "shelf", + "label": "Bibliothèque", + "object": "bookshelf", + "interactions": [ + { + "do": [ + { + "goto": "shelf" + } + ] + } + ] + }, + { + "id": "safe", + "label": "Coffret", + "object": "safe", + "interactions": [ + { + "do": [ + { + "goto": "safe" + } + ] + } + ] + }, + { + "id": "breaker", + "label": "Disjoncteur", + "object": "breaker", + "interactions": [ + { + "do": [ + { + "goto": "breaker" + } + ] + } + ] + }, + { + "id": "armchair", + "label": "Fauteuil", + "object": "armchair", + "interactions": [ + { + "do": [ + { + "message": "Un fauteuil en cuir usé. Rien sous les coussins." + } + ] + } + ] + } ] }, - { "id": "desk", "title": "Le bureau", - "camera": { "position": [0, 1.45, -1.05], "target": [0, 0.85, -2.7], "fov": 50 }, + "camera": { + "position": [ + 0, + 1.45, + -1.05 + ], + "target": [ + 0, + 0.85, + -2.7 + ], + "fov": 50 + }, "back": "north", "hotspots": [ - { "id": "note", "label": "Mot épinglé", "object": "note", "interactions": [{ "do": [{ "goto": "note" }] }] }, - { "id": "lamp", "label": "Lampe", "object": "lamp", "interactions": [{ "do": [{ "message": "Une lampe de banquier, sur batterie de secours. Sa lumière est chaude et rassurante." }] }] }, - { "id": "inkwell", "label": "Encrier", "object": "inkwell", "interactions": [{ "do": [{ "message": "L’encre a séché depuis longtemps." }] }] }, - { "id": "books", "label": "Livres", "object": "deskBooks", "interactions": [{ "do": [{ "message": "« Chromatisme et mémoire », « Traité des serrures », « Le chiffre de César ». Lectures étranges." }] }] }, { - "id": "drawersLeft", - "label": "Tiroirs", - "object": "drawersLeft", + "id": "note", + "label": "Mot épinglé", + "object": "note", "interactions": [ - { "when": ["!flag:uvlamp_found"], "do": [{ "give": "uvlamp" }, { "setFlag": "uvlamp_found" }, { "message": "Sous une pile de factures : une petite lampe à ultraviolets. Elle ne s’allume pas, il manque les piles." }] }, - { "do": [{ "message": "Des factures, des crayons, des trombones. Rien d’autre." }] } + { + "do": [ + { + "goto": "note" + } + ] + } + ] + }, + { + "id": "lamp", + "label": "Lampe", + "object": "lamp", + "interactions": [ + { + "do": [ + { + "message": "Une lampe de banquier, sur batterie de secours. Sa lumière est chaude et rassurante." + } + ] + } + ] + }, + { + "id": "inkwell", + "label": "Encrier", + "object": "inkwell", + "interactions": [ + { + "do": [ + { + "message": "L’encre a séché depuis longtemps." + } + ] + } + ] + }, + { + "id": "books", + "label": "Livres", + "object": "deskBooks", + "interactions": [ + { + "do": [ + { + "message": "« Chromatisme et mémoire », « Traité des serrures », « Le chiffre de César ». Lectures étranges." + } + ] + } + ] + }, + { + "id": "drawersLeft", + "label": "Tiroir du bas", + "object": "drawersLeft", + "interactions": [ + { + "do": [ + { + "message": "Le tiroir du bas est rempli de vieux carnets de comptes. Rien d’utile." + } + ] + } + ] + }, + { + "id": "drawerL1", + "label": "Tiroir", + "object": "drawerL1", + "interactions": [ + { + "when": [ + "!flag:drawerL1_open" + ], + "do": [ + { + "setFlag": "drawerL1_open" + }, + { + "sound": "drawer" + }, + { + "goto": "drawerLeft" + } + ] + }, + { + "do": [ + { + "goto": "drawerLeft" + } + ] + } + ] + }, + { + "id": "drawersRight", + "label": "Tiroirs", + "object": "drawersRight", + "interactions": [ + { + "do": [ + { + "message": "Vides. Quelqu’un a fait le ménage." + } + ] + } ] }, - { "id": "drawersRight", "label": "Tiroirs", "object": "drawersRight", "interactions": [{ "do": [{ "message": "Vides. Quelqu’un a fait le ménage." }] }] }, { "id": "secretPanel", "label": "Panneau central", - "visibleWhen": ["!flag:drawer_open"], + "visibleWhen": [ + "!flag:drawer_open" + ], "object": "secretDrawer", - "interactions": [{ "do": [{ "sound": "step" }, { "message": "Le panneau sonne creux… mais il n’a ni poignée ni serrure." }] }] + "interactions": [ + { + "do": [ + { + "sound": "step" + }, + { + "message": "Le panneau sonne creux… mais il n’a ni poignée ni serrure." + } + ] + } + ] }, { "id": "secretDrawer", "label": "Tiroir secret", - "visibleWhen": ["flag:drawer_open", "flag:key_taken"], + "visibleWhen": [ + "flag:drawer_open", + "flag:key_taken" + ], "object": "secretDrawer", - "interactions": [{ "do": [{ "message": "Le tiroir secret est vide, maintenant." }] }] + "interactions": [ + { + "do": [ + { + "message": "Le tiroir secret est vide, maintenant." + } + ] + } + ] }, { "id": "key", "label": "Clé", - "visibleWhen": ["flag:drawer_open", "!flag:key_taken"], + "visibleWhen": [ + "flag:drawer_open", + "!flag:key_taken" + ], "object": "key", - "interactions": [{ "do": [{ "give": "key" }, { "setFlag": "key_taken" }, { "message": "Vous prenez une clé en laiton. Elle est lourde et froide." }] }] + "interactions": [ + { + "do": [ + { + "give": "key" + }, + { + "setFlag": "key_taken" + }, + { + "message": "Vous prenez une clé en laiton. Elle est lourde et froide." + } + ] + } + ] + } + ] + }, + { + "id": "drawerLeft", + "title": "Le tiroir", + "camera": { + "position": [ + -0.55, + 1.25, + -1.8 + ], + "target": [ + -0.55, + 0.48, + -2.17 + ], + "fov": 34 + }, + "back": "desk", + "hotspots": [ + { + "id": "invoices", + "label": "Factures", + "cursor": "look", + "object": "drawerL1", + "interactions": [ + { + "do": [ + { + "message": "Des factures de l’horloger, du libraire… rien d’intéressant." + } + ] + } + ] + }, + { + "id": "uvlamp", + "label": "Lampe", + "visibleWhen": [ + "!flag:uvlamp_found" + ], + "object": "uvlampItem", + "interactions": [ + { + "do": [ + { + "give": "uvlamp" + }, + { + "setFlag": "uvlamp_found" + }, + { + "message": "Une petite lampe à ultraviolets, cachée sous les factures. Elle ne s’allume pas : il manque les piles." + } + ] + } + ] } ] }, { "id": "note", "title": "Le mot", - "camera": { "position": [0.35, 1.18, -2.62], "target": [0.35, 1.18, -3], "fov": 30 }, + "camera": { + "position": [ + 0.35, + 1.18, + -2.62 + ], + "target": [ + 0.35, + 1.18, + -3 + ], + "fov": 30 + }, "back": "desk", - "hotspots": [] + "hotspots": [ + { + "id": "paper", + "label": "Mot", + "cursor": "look", + "object": "note", + "interactions": [ + { + "do": [ + { + "message": "« Lindqvist, ils ont repeint la pièce, mais j’ai laissé les chiffres. Chaque chiffre a sa couleur. Chaque couleur a sa place. — A. »" + }, + { + "clue": "note" + } + ] + } + ] + } + ] }, { "id": "clock", "title": "L’horloge", - "camera": { "position": [-1.9, 1.88, -2.2], "target": [-1.9, 1.94, -3], "fov": 34 }, + "camera": { + "position": [ + -1.9, + 1.88, + -2.2 + ], + "target": [ + -1.9, + 1.94, + -3 + ], + "fov": 34 + }, "back": "north", "hotspots": [ - { "id": "clockFace", "label": "Horloge", "cursor": "look", "object": "clock", "interactions": [{ "do": [{ "message": "Les aiguilles sont figées. Le temps s’est arrêté, ici." }] }] } + { + "id": "clockFace", + "label": "Horloge", + "cursor": "look", + "object": "clock", + "interactions": [ + { + "do": [ + { + "message": "Les aiguilles sont figées. Le temps s’est arrêté, ici." + }, + { + "clue": "clock" + } + ] + } + ] + } ] }, { "id": "painting", "title": "Le tableau", - "camera": { "position": [1.55, 1.72, 1.0], "target": [3, 1.72, 1.0], "fov": 40 }, + "camera": { + "position": [ + 1.55, + 1.72, + 1.0 + ], + "target": [ + 3, + 1.72, + 1.0 + ], + "fov": 40 + }, "back": "east", "hotspots": [ { @@ -252,22 +1184,99 @@ "cursor": "look", "object": "paintingCanvas", "interactions": [ - { "when": ["selected:uvlampOn", "!flag:uv_painting"], "do": [{ "setFlag": "uv_painting" }, { "sound": "reveal" }, { "message": "Sous la lumière violette, des lettres luminescentes apparaissent sur la toile !" }] }, - { "when": ["selected:uvlampOn"], "do": [{ "message": "Le message brille toujours sous la lampe." }] }, - { "do": [{ "message": "Un paysage au crépuscule, signé « A. L. »." }] } + { + "when": [ + "selected:uvlampOn", + "!flag:uv_painting" + ], + "do": [ + { + "setFlag": "uv_painting" + }, + { + "sound": "reveal" + }, + { + "message": "Sous la lumière violette, des lettres luminescentes apparaissent sur la toile ! Cliquez sur le message pour l’examiner." + } + ] + }, + { + "when": [ + "selected:uvlampOn" + ], + "do": [ + { + "message": "Le message brille toujours sous la lampe." + } + ] + }, + { + "do": [ + { + "message": "Un paysage au crépuscule, signé « A. L. »." + } + ] + } + ] + }, + { + "id": "digit1", + "label": "Détail", + "cursor": "look", + "object": "digit1", + "interactions": [ + { + "do": [ + { + "message": "Un « 1 » jaune a été ajouté dans le ciel, d’un coup de pinceau rapide." + }, + { + "clue": "digit1" + } + ] + } ] }, - { "id": "digit1", "label": "Détail", "cursor": "look", "object": "digit1", "interactions": [{ "do": [{ "message": "Un « 1 » jaune a été ajouté dans le ciel, d’un coup de pinceau rapide." }] }] }, { "id": "uvText", "label": "Message luminescent", "cursor": "zoom", - "visibleWhen": ["flag:uv_painting"], + "visibleWhen": [ + "flag:uv_painting" + ], "object": "uvMessage", "interactions": [ - { "when": ["solved:cipher"], "do": [{ "message": "« LE COFFRE S’OUVRE À L’HEURE OÙ LE TEMPS S’EST ARRÊTÉ »" }] }, - { "when": ["selected:uvlampOn"], "do": [{ "puzzle": "cipher" }] }, - { "do": [{ "puzzle": "cipher" }] } + { + "when": [ + "solved:cipher" + ], + "do": [ + { + "message": "« LE COFFRE S’OUVRE À L’HEURE OÙ LE TEMPS S’EST ARRÊTÉ »" + }, + { + "clue": "cipher" + } + ] + }, + { + "when": [ + "selected:uvlampOn" + ], + "do": [ + { + "puzzle": "cipher" + } + ] + }, + { + "do": [ + { + "puzzle": "cipher" + } + ] + } ] } ] @@ -275,46 +1284,229 @@ { "id": "shelf", "title": "La bibliothèque", - "camera": { "position": [-1.7, 1.3, -0.08], "target": [-3, 1.25, -0.08], "fov": 40 }, + "camera": { + "position": [ + -1.7, + 1.3, + -0.08 + ], + "target": [ + -3, + 1.25, + -0.08 + ], + "fov": 40 + }, "back": "west", "hotspots": [ - { "id": "books", "label": "Livres", "cursor": "look", "object": "bookshelf", "interactions": [{ "do": [{ "message": "Cryptographie, chimie, horlogerie… Rien qui ne serve maintenant." }] }] }, - { "id": "book2", "label": "Livre blanc", "cursor": "look", "object": "book2", "interactions": [{ "do": [{ "message": "Un livre sans titre. Un « 2 » rouge est peint à la main sur la tranche." }] }] } + { + "id": "books", + "label": "Livres", + "cursor": "look", + "object": "bookshelf", + "interactions": [ + { + "do": [ + { + "message": "Cryptographie, chimie, horlogerie… Rien qui ne serve maintenant." + } + ] + } + ] + }, + { + "id": "book2", + "label": "Livre blanc", + "cursor": "look", + "object": "book2", + "interactions": [ + { + "do": [ + { + "message": "Un livre sans titre. Un « 2 » rouge est peint à la main sur la tranche." + }, + { + "clue": "digit2" + } + ] + } + ] + } ] }, { "id": "safe", "title": "Le coffret", - "camera": { "position": [-1.95, 0.62, -0.36], "target": [-2.7, 0.22, -0.36], "fov": 40 }, + "camera": { + "position": [ + -1.95, + 0.62, + -0.36 + ], + "target": [ + -2.7, + 0.22, + -0.36 + ], + "fov": 40 + }, "back": "west", "hotspots": [ - { "id": "dial1", "label": "Molette 1", "cursor": "use", "visibleWhen": ["!flag:safe_open"], "object": "dial1", "interactions": [{ "do": [{ "add": "dial1", "mod": 10 }, { "sound": "dial" }] }] }, - { "id": "dial2", "label": "Molette 2", "cursor": "use", "visibleWhen": ["!flag:safe_open"], "object": "dial2", "interactions": [{ "do": [{ "add": "dial2", "mod": 10 }, { "sound": "dial" }] }] }, - { "id": "dial3", "label": "Molette 3", "cursor": "use", "visibleWhen": ["!flag:safe_open"], "object": "dial3", "interactions": [{ "do": [{ "add": "dial3", "mod": 10 }, { "sound": "dial" }] }] }, - { "id": "dial4", "label": "Molette 4", "cursor": "use", "visibleWhen": ["!flag:safe_open"], "object": "dial4", "interactions": [{ "do": [{ "add": "dial4", "mod": 10 }, { "sound": "dial" }] }] }, + { + "id": "dial1", + "label": "Molette 1", + "cursor": "use", + "visibleWhen": [ + "!flag:safe_open" + ], + "object": "dial1", + "interactions": [ + { + "do": [ + { + "add": "dial1", + "mod": 10 + }, + { + "sound": "dial" + } + ] + } + ] + }, + { + "id": "dial2", + "label": "Molette 2", + "cursor": "use", + "visibleWhen": [ + "!flag:safe_open" + ], + "object": "dial2", + "interactions": [ + { + "do": [ + { + "add": "dial2", + "mod": 10 + }, + { + "sound": "dial" + } + ] + } + ] + }, + { + "id": "dial3", + "label": "Molette 3", + "cursor": "use", + "visibleWhen": [ + "!flag:safe_open" + ], + "object": "dial3", + "interactions": [ + { + "do": [ + { + "add": "dial3", + "mod": 10 + }, + { + "sound": "dial" + } + ] + } + ] + }, + { + "id": "dial4", + "label": "Molette 4", + "cursor": "use", + "visibleWhen": [ + "!flag:safe_open" + ], + "object": "dial4", + "interactions": [ + { + "do": [ + { + "add": "dial4", + "mod": 10 + }, + { + "sound": "dial" + } + ] + } + ] + }, { "id": "safeBody", "label": "Coffret", "cursor": "look", "object": "safe", "interactions": [ - { "when": ["flag:safe_open"], "do": [{ "message": "Le coffret est ouvert." }] }, - { "do": [{ "message": "Un coffret en acier « Lindqvist & Fils ». Quatre molettes chiffrées le verrouillent." }] } + { + "when": [ + "flag:safe_open" + ], + "do": [ + { + "message": "Le coffret est ouvert." + } + ] + }, + { + "do": [ + { + "message": "Un coffret en acier « Lindqvist & Fils ». Quatre molettes chiffrées le verrouillent." + } + ] + } ] }, { "id": "lever", "label": "Manette", - "visibleWhen": ["flag:safe_open", "!flag:lever_taken"], + "visibleWhen": [ + "flag:safe_open", + "!flag:lever_taken" + ], "object": "leverItem", - "interactions": [{ "do": [{ "give": "lever" }, { "setFlag": "lever_taken" }, { "message": "Une manette à poignée rouge… comme celles des disjoncteurs." }] }] + "interactions": [ + { + "do": [ + { + "give": "lever" + }, + { + "setFlag": "lever_taken" + }, + { + "message": "Une manette à poignée rouge… comme celles des disjoncteurs." + } + ] + } + ] } ] }, { "id": "breaker", "title": "Le disjoncteur", - "camera": { "position": [-2.05, 1.5, 1.6], "target": [-2.9, 1.42, 1.6], "fov": 40 }, + "camera": { + "position": [ + -2.05, + 1.5, + 1.6 + ], + "target": [ + -2.9, + 1.42, + 1.6 + ], + "fov": 40 + }, "back": "west", "hotspots": [ { @@ -322,39 +1514,163 @@ "label": "Disjoncteur", "object": "breaker", "interactions": [ - { "when": ["selected:lever"], "do": [{ "remove": "lever" }, { "setFlag": "lever_installed" }, { "sound": "switch" }, { "message": "La manette s’emboîte parfaitement. Elle est en position haute." }] }, - { "when": ["flag:power_on"], "do": [{ "message": "Le voyant est vert : le courant est rétabli." }] }, - { "when": ["flag:lever_installed"], "do": [{ "message": "La manette est en position haute. Il suffit de l’abaisser." }] }, - { "when": ["item:lever"], "do": [{ "message": "La manette du coffret devrait s’emboîter ici. Sélectionnez-la dans l’inventaire, puis cliquez sur le disjoncteur." }] }, - { "do": [{ "message": "Un disjoncteur dont on a retiré la manette. Impossible de rétablir le courant ainsi." }] } + { + "when": [ + "selected:lever" + ], + "do": [ + { + "remove": "lever" + }, + { + "setFlag": "lever_installed" + }, + { + "sound": "switch" + }, + { + "message": "La manette s’emboîte parfaitement. Elle est en position haute." + } + ] + }, + { + "when": [ + "flag:power_on" + ], + "do": [ + { + "message": "Le voyant est vert : le courant est rétabli." + } + ] + }, + { + "when": [ + "flag:lever_installed" + ], + "do": [ + { + "message": "La manette est en position haute. Il suffit de l’abaisser." + } + ] + }, + { + "when": [ + "item:lever" + ], + "do": [ + { + "message": "La manette du coffret devrait s’emboîter ici. Sélectionnez-la dans l’inventaire, puis cliquez sur le disjoncteur." + } + ] + }, + { + "do": [ + { + "message": "Un disjoncteur dont on a retiré la manette. Impossible de rétablir le courant ainsi." + } + ] + } ] }, { "id": "breakerLever", "label": "Abaisser la manette", "cursor": "use", - "visibleWhen": ["flag:lever_installed", "!flag:power_on"], + "visibleWhen": [ + "flag:lever_installed", + "!flag:power_on" + ], "object": "breakerLever", - "interactions": [{ "do": [{ "setFlag": "power_on" }, { "sound": "switch" }, { "sound": "power" }, { "message": "Clac ! Le plafonnier grésille puis s’allume. Le courant est revenu dans la pièce." }] }] + "interactions": [ + { + "do": [ + { + "setFlag": "power_on" + }, + { + "sound": "switch" + }, + { + "sound": "power" + }, + { + "message": "Clac ! Le plafonnier grésille puis s’allume. Le courant est revenu dans la pièce." + } + ] + } + ] } ] }, { "id": "door", "title": "La porte", - "camera": { "position": [0, 1.35, 1.55], "target": [-0.1, 1.15, 3], "fov": 50 }, + "camera": { + "position": [ + 0, + 1.35, + 1.55 + ], + "target": [ + -0.1, + 1.15, + 3 + ], + "fov": 50 + }, "back": "south", "hotspots": [ - { "id": "doorBody", "label": "Porte", "cursor": "look", "object": "door", "interactions": [{ "do": [{ "message": "Une lourde porte en chêne. Impossible de la forcer." }] }] }, + { + "id": "doorBody", + "label": "Porte", + "cursor": "look", + "object": "door", + "interactions": [ + { + "do": [ + { + "message": "Une lourde porte en chêne. Impossible de la forcer." + } + ] + } + ] + }, { "id": "panelSide", "label": "Boîtier de commande", "cursor": "zoom", "object": "panel", "interactions": [ - { "when": ["solved:colorPanel"], "do": [{ "message": "Les quatre voyants sont allumés. Le boîtier ne répond plus." }] }, - { "when": ["!flag:power_on"], "do": [{ "message": "Le boîtier est éteint : son circuit est coupé. Il doit y avoir un disjoncteur quelque part." }] }, - { "do": [{ "puzzle": "colorPanel" }] } + { + "when": [ + "solved:colorPanel" + ], + "do": [ + { + "message": "Les quatre voyants sont allumés. Le boîtier ne répond plus." + } + ] + }, + { + "when": [ + "!flag:power_on" + ], + "do": [ + { + "message": "Le boîtier est éteint : son circuit est coupé. Il doit y avoir un disjoncteur quelque part." + }, + { + "clue": "panel" + } + ] + }, + { + "do": [ + { + "puzzle": "colorPanel" + } + ] + } ] }, { @@ -363,40 +1679,84 @@ "cursor": "look", "object": "lock", "interactions": [ - { "when": ["selected:key"], "do": [{ "sound": "unlock" }, { "remove": "key" }, { "setFlag": "door_open" }, { "win": true }] }, - { "when": ["item:key"], "do": [{ "message": "Cette clé en laiton devrait aller dans la serrure. Sélectionnez-la dans l’inventaire, puis cliquez ici." }] }, - { "do": [{ "message": "Verrouillée. Le trou de serrure est assez large pour une vieille clé." }] } + { + "when": [ + "selected:key" + ], + "do": [ + { + "sound": "unlock" + }, + { + "remove": "key" + }, + { + "setFlag": "door_open" + }, + { + "win": true + } + ] + }, + { + "when": [ + "item:key" + ], + "do": [ + { + "message": "Cette clé en laiton devrait aller dans la serrure. Sélectionnez-la dans l’inventaire, puis cliquez ici." + } + ] + }, + { + "do": [ + { + "message": "Verrouillée. Le trou de serrure est assez large pour une vieille clé." + } + ] + } ] } ] } ], - "hints": [ { - "when": ["!item:uvlampOn", "!flag:uv_painting"], + "when": [ + "!item:uvlampOn", + "!flag:uv_painting" + ], "hints": [ - "Fouillez les meubles : les tiroirs du bureau, ce qui traîne sur les murs et les tables…", - "La lampe UV trouvée dans le bureau n’a pas de piles. Le vase posé sur la console, près du tableau, en cache peut-être.", + "Fouillez les meubles : ouvrez les tiroirs du bureau, regardez dans ce qui traîne…", + "La lampe UV, dans un tiroir du bureau, n’a pas de piles. Regardez au fond du vase posé sous le tableau.", "Sélectionnez la lampe UV dans l’inventaire, puis cliquez sur les piles pour les combiner." ] }, { - "when": ["item:uvlampOn", "!flag:uv_painting"], + "when": [ + "item:uvlampOn", + "!flag:uv_painting" + ], "hints": [ "Une lampe UV révèle les encres invisibles. Où un artiste laisserait-il un message ?", - "Approchez-vous du tableau, sélectionnez la lampe UV allumée, puis cliquez sur la toile." + "Approchez-vous du tableau, prenez la lampe UV allumée en main et promenez son halo sur la toile, puis cliquez sur ce qui apparaît." ] }, { - "when": ["flag:uv_painting", "!solved:cipher"], + "when": [ + "flag:uv_painting", + "!solved:cipher" + ], "hints": [ "Chaque lettre a été remplacée par une autre, plus loin dans l’alphabet.", "Cliquez sur le message lumineux et tournez la roue jusqu’à ce que le texte devienne lisible (décalage 7)." ] }, { - "when": ["solved:cipher", "!flag:safe_open"], + "when": [ + "solved:cipher", + "!flag:safe_open" + ], "hints": [ "À quelle heure le temps s’est-il arrêté dans cette pièce ? Regardez l’horloge de près.", "Un coffret à molettes est rangé en bas de la bibliothèque.", @@ -404,14 +1764,20 @@ ] }, { - "when": ["flag:safe_open", "!flag:power_on"], + "when": [ + "flag:safe_open", + "!flag:power_on" + ], "hints": [ "La manette du coffret doit servir à rétablir le courant. Le boîtier près de la porte est éteint…", "Le disjoncteur est sur le mur ouest, à gauche de la bibliothèque : installez la manette, puis abaissez-la." ] }, { - "when": ["flag:power_on", "!solved:colorPanel"], + "when": [ + "flag:power_on", + "!solved:colorPanel" + ], "hints": [ "Le boîtier près de la porte est maintenant sous tension. Relisez le mot épinglé au-dessus du bureau.", "Quatre chiffres de couleur sont cachés dans la pièce : deux sont peints sur les murs, les deux autres se trouvent sur le tableau et dans la bibliothèque.", @@ -419,12 +1785,61 @@ ] }, { - "when": ["flag:drawer_open", "!flag:key_taken"], - "hints": ["Le déclic venait du bureau.", "Le panneau central du bureau s’est ouvert : approchez-vous du bureau pour voir ce qu’il contient."] + "when": [ + "flag:drawer_open", + "!flag:key_taken" + ], + "hints": [ + "Le déclic venait du bureau.", + "Le panneau central du bureau s’est ouvert : approchez-vous du bureau pour voir ce qu’il contient." + ] }, { - "when": ["flag:key_taken"], - "hints": ["Cette clé doit bien ouvrir quelque chose…", "Sélectionnez la clé dans l’inventaire, puis cliquez sur la serrure de la porte."] + "when": [ + "flag:key_taken" + ], + "hints": [ + "Cette clé doit bien ouvrir quelque chose…", + "Sélectionnez la clé dans l’inventaire, puis cliquez sur la serrure de la porte." + ] + } + ], + "uvLight": { + "item": "uvlampOn", + "radius": 0.14 + }, + "clues": [ + { + "id": "note", + "text": "Mot du professeur : « Chaque chiffre a sa couleur. Chaque couleur a sa place. »" + }, + { + "id": "digit1", + "text": "Un « 1 » jaune, peint dans le ciel du tableau." + }, + { + "id": "digit2", + "text": "Un « 2 » rouge, sur la tranche d’un livre de la bibliothèque." + }, + { + "id": "digit3", + "text": "Un « 3 » bleu, peint sur le mur au-dessus du bureau." + }, + { + "id": "digit4", + "text": "Un « 4 » vert, peint sur les boiseries près de la porte." + }, + { + "id": "cipher", + "text": "Message décodé : « Le coffre s’ouvre à l’heure où le temps s’est arrêté. »" + }, + { + "id": "clock", + "text": "L’horloge du mur nord est arrêtée." + }, + { + "id": "panel", + "text": "Le boîtier près de la porte a 4 emplacements, numérotés de 1 à 4, et plusieurs couleurs possibles." } ] } diff --git a/src/scenarios/chapitre1/walkthrough.json b/src/scenarios/chapitre1/walkthrough.json index c68e5c0..9fd1b62 100644 --- a/src/scenarios/chapitre1/walkthrough.json +++ b/src/scenarios/chapitre1/walkthrough.json @@ -1,43 +1,240 @@ { "description": "Solution de référence du chapitre 1. Rejouée automatiquement par `npm test` (moteur seul) et `npm run smoke` (vrais clics dans le navigateur).", "steps": [ - { "click": "desk", "expect": ["scene:desk"] }, - { "click": "drawersLeft", "expect": ["item:uvlamp"] }, - { "click": "__back" }, - { "click": "__right", "expect": ["scene:east"] }, - { "click": "vase", "expect": ["item:batteries"] }, - { "combine": ["uvlamp", "batteries"], "expect": ["item:uvlampOn", "!item:uvlamp"] }, - { "click": "painting", "expect": ["scene:painting"] }, - { "use": "uvlampOn", "on": "canvas", "expect": ["flag:uv_painting"] }, - { "click": "uvText" }, - { "solve": "cipher", "expect": ["solved:cipher"] }, - { "click": "__back" }, - { "click": "__left", "expect": ["scene:north"] }, - { "click": "clock", "expect": ["scene:clock"] }, - { "click": "__back" }, - { "click": "__left", "expect": ["scene:west"] }, - { "click": "safe", "expect": ["scene:safe"] }, - { "click": "dial1", "times": 8 }, - { "click": "dial2", "times": 3 }, - { "click": "dial3", "times": 2 }, - { "click": "dial4", "times": 5, "expect": ["flag:safe_open"] }, - { "click": "lever", "expect": ["item:lever"] }, - { "click": "__back" }, - { "click": "breaker", "expect": ["scene:breaker"] }, - { "use": "lever", "on": "breakerBox", "expect": ["flag:lever_installed", "!item:lever"] }, - { "click": "breakerLever", "expect": ["flag:power_on"] }, - { "click": "__back" }, - { "click": "__left", "expect": ["scene:south"] }, - { "click": "panel" }, - { "solve": "colorPanel", "expect": ["flag:drawer_open"] }, - { "click": "__right" }, - { "click": "__right", "expect": ["scene:north"] }, - { "click": "desk" }, - { "click": "key", "expect": ["item:key"] }, - { "click": "__back" }, - { "click": "__left" }, - { "click": "__left", "expect": ["scene:south"] }, - { "click": "door" }, - { "use": "key", "on": "lock", "expect": ["won"] } + { + "click": "desk", + "expect": [ + "scene:desk" + ] + }, + { + "click": "drawerL1", + "expect": [ + "scene:drawerLeft", + "flag:drawerL1_open" + ] + }, + { + "click": "uvlamp", + "expect": [ + "item:uvlamp" + ] + }, + { + "click": "__back", + "expect": [ + "scene:desk" + ] + }, + { + "click": "__back", + "expect": [ + "scene:north" + ] + }, + { + "click": "__right", + "expect": [ + "scene:east" + ] + }, + { + "click": "vase", + "expect": [ + "scene:vase" + ] + }, + { + "click": "batteries", + "expect": [ + "item:batteries" + ] + }, + { + "click": "__back", + "expect": [ + "scene:east" + ] + }, + { + "combine": [ + "uvlamp", + "batteries" + ], + "expect": [ + "item:uvlampOn", + "!item:uvlamp" + ] + }, + { + "click": "painting", + "expect": [ + "scene:painting" + ] + }, + { + "click": "digit1" + }, + { + "note": "digit1" + }, + { + "use": "uvlampOn", + "on": "canvas", + "expect": [ + "flag:uv_painting" + ] + }, + { + "click": "uvText" + }, + { + "solve": "cipher", + "expect": [ + "solved:cipher" + ] + }, + { + "click": "__back" + }, + { + "click": "__left", + "expect": [ + "scene:north" + ] + }, + { + "click": "clock", + "expect": [ + "scene:clock" + ] + }, + { + "click": "clockFace" + }, + { + "note": "clock" + }, + { + "click": "__back" + }, + { + "click": "__left", + "expect": [ + "scene:west" + ] + }, + { + "click": "safe", + "expect": [ + "scene:safe" + ] + }, + { + "click": "dial1", + "times": 8 + }, + { + "click": "dial2", + "times": 3 + }, + { + "click": "dial3", + "times": 2 + }, + { + "click": "dial4", + "times": 5, + "expect": [ + "flag:safe_open" + ] + }, + { + "click": "lever", + "expect": [ + "item:lever" + ] + }, + { + "click": "__back" + }, + { + "click": "breaker", + "expect": [ + "scene:breaker" + ] + }, + { + "use": "lever", + "on": "breakerBox", + "expect": [ + "flag:lever_installed", + "!item:lever" + ] + }, + { + "click": "breakerLever", + "expect": [ + "flag:power_on" + ] + }, + { + "click": "__back" + }, + { + "click": "__left", + "expect": [ + "scene:south" + ] + }, + { + "click": "panel" + }, + { + "solve": "colorPanel", + "expect": [ + "flag:drawer_open" + ] + }, + { + "click": "__right" + }, + { + "click": "__right", + "expect": [ + "scene:north" + ] + }, + { + "click": "desk" + }, + { + "click": "key", + "expect": [ + "item:key" + ] + }, + { + "click": "__back" + }, + { + "click": "__left" + }, + { + "click": "__left", + "expect": [ + "scene:south" + ] + }, + { + "click": "door" + }, + { + "use": "key", + "on": "lock", + "expect": [ + "won" + ] + } ] } diff --git a/src/style.css b/src/style.css index a20d3c8..b88815e 100644 --- a/src/style.css +++ b/src/style.css @@ -196,16 +196,16 @@ button.primary:hover { background: #dbb55c; } .message { position: absolute; left: 50%; - bottom: 14%; - transform: translate(-50%, 12px); - max-width: min(760px, 86%); - padding: 14px 22px; + top: 14px; + transform: translate(-50%, -12px); + max-width: min(700px, 80%); + padding: 12px 20px; background: rgba(8, 9, 10, .86); border: 1px solid rgba(201, 162, 74, .35); border-radius: 8px; font-family: var(--serif); - font-size: clamp(14px, 1.6vw, 18px); - line-height: 1.55; + font-size: clamp(13px, 1.45vw, 17px); + line-height: 1.5; text-align: center; opacity: 0; pointer-events: none; @@ -217,6 +217,90 @@ button.primary:hover { background: #dbb55c; } .message.visible { opacity: 1; transform: translate(-50%, 0); } .message.hint { border-color: #5aa0d8; } .message.hint::before { content: 'Indice — '; color: #7fbaea; font-style: italic; } +.message-text { display: block; } +.clue-btn { + pointer-events: auto; + margin-top: 10px; + font: 600 13px/1 system-ui, sans-serif; + padding: 8px 14px; + background: #2a2214; + border-color: var(--brass-dark); + color: #f1d58e; +} +.clue-btn::before { content: ''; display: inline-block; width: 12px; height: 14px; margin-right: 8px; vertical-align: -2px; background: linear-gradient(#e9dec4, #cdb88a); border-left: 3px solid #8a3a2a; border-radius: 1px; } +.clue-btn:disabled { opacity: .8; cursor: default; } + +/* Halo de la lampe UV (le révélateur d'encre est calculé en 3D, ceci est l'effet lumineux) */ +.uv-halo { + position: absolute; + left: 0; + top: 0; + width: clamp(140px, 17vw, 230px); + aspect-ratio: 1; + border-radius: 50%; + background: radial-gradient(circle, rgba(180, 120, 255, .5) 0%, rgba(140, 80, 255, .28) 40%, rgba(90, 40, 220, 0) 70%); + mix-blend-mode: screen; + pointer-events: none; + opacity: 0; + transition: opacity .25s; + z-index: 12; +} +.uv-halo.visible { opacity: 1; } + +/* Annonce « Objet obtenu » */ +.item-toast { + position: absolute; + left: 50%; + top: 46%; + transform: translate(-50%, -50%); + display: flex; + flex-direction: column; + align-items: center; + gap: 6px; + padding: 18px 34px 16px; + border-radius: 14px; + background: radial-gradient(ellipse at center, rgba(20, 16, 8, .92), rgba(8, 7, 4, .85)); + border: 1px solid rgba(201, 162, 74, .55); + box-shadow: 0 0 60px rgba(201, 162, 74, .25), 0 20px 50px rgba(0, 0, 0, .7); + opacity: 0; + pointer-events: none; + z-index: 24; +} +.item-toast img { width: 72px; height: 72px; filter: drop-shadow(0 0 14px rgba(255, 215, 130, .45)); } +.item-toast-label { font: 600 11px/1 system-ui, sans-serif; letter-spacing: .25em; text-transform: uppercase; color: var(--brass); } +.item-toast-name { font-family: var(--serif); font-size: clamp(20px, 2.4vw, 28px); color: #f4e6c8; } +.item-toast.show { animation: toast 2.4s ease forwards; } +@keyframes toast { + 0% { opacity: 0; transform: translate(-50%, -40%) scale(.9); } + 12% { opacity: 1; transform: translate(-50%, -50%) scale(1); } + 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); } + 100% { opacity: 0; transform: translate(-50%, -62%) scale(.98); } +} +.slot.fresh { animation: fresh 0.8s ease 3; border-color: var(--brass); } +@keyframes fresh { 50% { box-shadow: 0 0 0 3px rgba(201, 162, 74, .6), 0 0 22px rgba(201, 162, 74, .6); } } + +/* Carnet d'indices */ +.notebook-btn b { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 4px; padding: 0 4px; border-radius: 9px; background: var(--brass); color: #1a1408; font-size: 11px; } +.notebook-btn.pulse { animation: fresh .8s ease 2; } +.notebook { + position: relative; + width: min(560px, 84%); + max-height: 80%; + overflow: auto; + padding: 26px 34px 30px 52px; + border-radius: 6px; + background: + repeating-linear-gradient(transparent 0 31px, rgba(90, 120, 160, .28) 31px 32px), + linear-gradient(90deg, transparent 38px, rgba(200, 70, 60, .45) 38px 40px, transparent 40px), + #efe6cf; + color: #2a2a4a; + box-shadow: 0 25px 60px rgba(0, 0, 0, .8); + font-family: 'Segoe Script', 'Bradley Hand', 'Comic Sans MS', cursive; +} +.notebook h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 24px; color: #3a2a1a; } +.notebook ol { margin: 0; padding-left: 18px; line-height: 32px; font-size: 16px; } +.notebook-empty { font-family: var(--serif); font-style: italic; color: #6a5a4a; line-height: 1.6; } +.notebook .puzzle-close { top: 10px; right: 10px; color: var(--text); } .tooltip { position: absolute; diff --git a/src/worlds/bureau.ts b/src/worlds/bureau.ts index 4f41614..3dec025 100644 --- a/src/worlds/bureau.ts +++ b/src/worlds/bureau.ts @@ -1,7 +1,7 @@ import * as THREE from 'three'; import * as T from './textures'; import type { World } from './index'; -import { PICK_LAYER } from './common'; +import { PICK_LAYER, invisibleInk } from './common'; /** * Le bureau du professeur, en 3D, construit par code (primitives + textures @@ -149,16 +149,65 @@ function desk(): THREE.Group { const g = group(name, x, 0, 0); g.add(box(0.5, 0.68, 0.72, M.woodDark, 0, 0.42, 0)); for (const y of [0.6, 0.26]) { - g.add(box(0.46, 0.3, 0.02, M.woodMid, 0, y, 0.37)); + const front = box(0.46, 0.3, 0.02, M.woodMid, 0, 0, 0.37); const handle = new THREE.Mesh(new THREE.CylinderGeometry(0.008, 0.008, 0.1, 12), M.brass); handle.rotation.z = Math.PI / 2; - handle.position.set(0, y, 0.39); - g.add(handle); + handle.position.set(0, 0, 0.39); + const drawer = group(undefined, 0, y, 0, front, handle); + // Le tiroir du haut à gauche s'ouvre réellement (contenu : factures + lampe UV). + if (name === 'drawersLeft' && y === 0.6) { + drawer.name = 'drawerL1'; + drawer.add(...drawerBody(), ...drawerContents()); + } + g.add(drawer); } for (const fx of [-0.22, 0.22]) for (const fz of [-0.32, 0.32]) g.add(box(0.05, 0.08, 0.05, M.woodBlack, fx, 0.04, fz)); return g; }; + /** Caisson intérieur d'un tiroir (visible une fois tiré). */ + function drawerBody(): THREE.Object3D[] { + const inside = new THREE.MeshStandardMaterial({ color: '#3a2414', map: grain, roughness: 0.9 }); + return [ + box(0.42, 0.01, 0.5, inside, 0, -0.12, 0.11), + box(0.01, 0.2, 0.5, inside, -0.205, -0.03, 0.11), + box(0.01, 0.2, 0.5, inside, 0.205, -0.03, 0.11), + box(0.42, 0.2, 0.01, inside, 0, -0.03, -0.14), + ]; + } + + /** Factures en vrac et lampe UV à moitié cachée dessous. */ + function drawerContents(): THREE.Object3D[] { + const paper = (c: string) => new THREE.MeshStandardMaterial({ color: c, roughness: 0.95 }); + const sheets: THREE.Object3D[] = []; + [ + ['#e9e1cc', -0.07, 0.12, 0.15], + ['#ddd3b8', -0.05, 0.16, -0.1], + ['#efe8d6', -0.02, 0.1, 0.32], + ].forEach(([c, x, z, r], i) => { + const s = box(0.17, 0.003, 0.12, paper(c as string), x as number, -0.113 + i * 0.004, z as number); + s.rotation.y = r as number; + sheets.push(s); + }); + // Lampe UV : corps sombre, tête et lentille violette qui dépasse des factures + const body = new THREE.Mesh(new THREE.CylinderGeometry(0.016, 0.016, 0.12, 16), new THREE.MeshStandardMaterial({ color: '#3d4247', metalness: 0.6, roughness: 0.4 })); + body.rotation.z = Math.PI / 2; + const head = new THREE.Mesh(new THREE.CylinderGeometry(0.024, 0.02, 0.035, 16), new THREE.MeshStandardMaterial({ color: '#2c2f33', metalness: 0.6, roughness: 0.4 })); + head.rotation.z = Math.PI / 2; + head.position.x = 0.075; + const lens = new THREE.Mesh(new THREE.CircleGeometry(0.02, 16), new THREE.MeshStandardMaterial({ color: '#6a3fc0', emissive: '#4a2a90', emissiveIntensity: 0.6, roughness: 0.2 })); + lens.rotation.y = Math.PI / 2; + lens.position.x = 0.093; + const zone = pickZone(0.18, 0.09, 0.02, 0, 0); + zone.rotation.x = -Math.PI / 2; + const lamp = group('uvlampItem', 0.085, -0.098, 0.15, body, head, lens, zone); + lamp.rotation.y = 0.5; + // Une facture posée en travers de la lampe + const over = box(0.15, 0.003, 0.1, paper('#e4dcc4'), 0.02, -0.08, 0.16); + over.rotation.set(0.12, -0.4, 0.05); + return [...sheets, lamp, over]; + } + // Tiroir secret : façade sans poignée, identique au bandeau du bureau. const drawerInside = new THREE.MeshStandardMaterial({ color: '#2a1a0e', roughness: 1 }); const keyGroup = key(); @@ -343,18 +392,11 @@ function eastWall(): THREE.Group { canvas, pickZone(0.12, 0.14, 0.33, 0.24, 0.025, 'digit1'), ); - // Message à l'encre invisible : caché tant que la lampe UV ne l'a pas révélé. - const uv = plane( - 0.92, - 0.41, - new THREE.MeshBasicMaterial({ map: T.uvMessage(["SL JVMMYL Z'VBCYL", "H S'OLBYL VB SL", "ALTWZ Z'LZA HYYLAL"]), transparent: true, depthWrite: false, blending: THREE.AdditiveBlending }), - 0, - -0.08, - 0.024, - 'uvMessage', - ); + // Message à l'encre invisible : n'apparaît que dans le halo de la lampe UV, + // puis reste visible une fois révélé. Enfant de la toile : un clic dessus = clic sur la toile. + const uv = plane(0.92, 0.41, invisibleInk(T.uvMessage(["SL JVMMYL Z'VBCYL", "H S'OLBYL VB SL", "ALTWZ Z'LZA HYYLAL"])), 0, -0.08, 0.004, 'uvMessage'); uv.userData.noShadow = true; - painting.add(uv); + canvas.add(uv); g.add(painting); // Applique de tableau const bar = new THREE.Mesh(new THREE.CylinderGeometry(0.02, 0.02, 0.36, 16), M.brass); @@ -369,10 +411,25 @@ function eastWall(): THREE.Group { // Console et vase const vase = new THREE.Mesh( - new THREE.LatheGeometry([new THREE.Vector2(0.0, 0), new THREE.Vector2(0.06, 0.0), new THREE.Vector2(0.09, 0.08), new THREE.Vector2(0.06, 0.2), new THREE.Vector2(0.04, 0.26), new THREE.Vector2(0.05, 0.28)], 32), - new THREE.MeshStandardMaterial({ color: '#2c4a5e', roughness: 0.25, metalness: 0.1 }), + new THREE.LatheGeometry([new THREE.Vector2(0.0, 0), new THREE.Vector2(0.06, 0.0), new THREE.Vector2(0.09, 0.08), new THREE.Vector2(0.07, 0.2), new THREE.Vector2(0.065, 0.26), new THREE.Vector2(0.075, 0.28)], 32), + new THREE.MeshStandardMaterial({ color: '#2c4a5e', roughness: 0.25, metalness: 0.1, side: THREE.DoubleSide }), ); - const flowers = group(undefined, 0, 0.28, 0); + // Fond du vase (intérieur) et deux piles cachées dedans + const vaseBottom = new THREE.Mesh(new THREE.CircleGeometry(0.06, 24), new THREE.MeshStandardMaterial({ color: '#1d3442', roughness: 0.6 })); + vaseBottom.rotation.x = -Math.PI / 2; + vaseBottom.position.y = 0.005; + const battery = (x: number, z: number, r: number) => { + const b = new THREE.Mesh(new THREE.CylinderGeometry(0.0075, 0.0075, 0.05, 16), new THREE.MeshStandardMaterial({ color: '#2a2d31', metalness: 0.5, roughness: 0.4 })); + const cap = new THREE.Mesh(new THREE.CylinderGeometry(0.0076, 0.0076, 0.014, 16), new THREE.MeshStandardMaterial({ color: '#c9a24a', metalness: 0.7, roughness: 0.3, emissive: '#5a4210', emissiveIntensity: 0.6 })); + cap.position.y = 0.019; + const bg = group(undefined, x, 0.013, z, b, cap); + bg.rotation.set(Math.PI / 2, 0, r); + return bg; + }; + const batteryZone = pickZone(0.1, 0.1, 0, 0.03, 0); + batteryZone.rotation.x = -Math.PI / 2; + const batteries = group('batteriesItem', 0, 0, 0, battery(-0.012, 0.004, 0.4), battery(0.012, -0.006, -0.3), batteryZone); + const flowers = group('flowers', 0, 0.28, 0); [ ['#c84a5a', -0.05, 0.25], ['#e0b84a', 0.07, 0.2], @@ -392,7 +449,7 @@ function eastWall(): THREE.Group { 0.22, box(0.8, 0.04, 0.34, M.woodLight, 0, 0.8, 0), ...[-0.36, 0.36].flatMap((x) => [-0.14, 0.14].map((z) => box(0.035, 0.78, 0.035, M.woodDark, x, 0.39, z))), - group('vase', 0, 0.82, 0, vase, flowers, pickZone(0.24, 0.6, 0, 0.27, 0.1)), + group('vase', 0, 0.82, 0, vase, vaseBottom, batteries, flowers, pickZone(0.24, 0.6, 0, 0.27, 0.1)), ); g.add(consoleTable); return g; diff --git a/src/worlds/common.ts b/src/worlds/common.ts index 8b3de45..bc08eb7 100644 --- a/src/worlds/common.ts +++ b/src/worlds/common.ts @@ -1,2 +1,38 @@ +import * as THREE from 'three'; + /** Calque des zones cliquables invisibles : ignoré par la caméra, vu par le raycast. */ export const PICK_LAYER = 1; + +/** + * Lampe UV : uniformes partagés par tous les matériaux « encre invisible ». + * Le rendu met à jour le point visé par la souris quand la lampe est en main. + */ +export const UV_LIGHT = { + uUvPoint: { value: new THREE.Vector3(0, -100, 0) }, + uUvRadius: { value: 0.14 }, + uUvActive: { value: 0 }, +}; + +/** + * Matériau d'encre invisible : rien n'apparaît, sauf dans le halo de la lampe UV + * ou une fois l'encre « révélée » (prop `reveal`, uniforme uRevealed). + */ +export function invisibleInk(map: THREE.Texture): THREE.MeshBasicMaterial { + const mat = new THREE.MeshBasicMaterial({ map, transparent: true, depthWrite: false, blending: THREE.AdditiveBlending }); + const uRevealed = { value: 0 }; + mat.userData.uRevealed = uRevealed; + mat.onBeforeCompile = (shader) => { + Object.assign(shader.uniforms, UV_LIGHT, { uRevealed }); + shader.vertexShader = shader.vertexShader + .replace('#include ', '#include \nvarying vec3 vInkWorld;') + .replace('#include ', '#include \nvInkWorld = (modelMatrix * vec4(transformed, 1.0)).xyz;'); + shader.fragmentShader = shader.fragmentShader + .replace('#include ', '#include \nvarying vec3 vInkWorld;\nuniform vec3 uUvPoint;\nuniform float uUvRadius;\nuniform float uUvActive;\nuniform float uRevealed;') + .replace( + '#include ', + '#include \nfloat inkD = distance(vInkWorld, uUvPoint);\nfloat ink = max(uRevealed, uUvActive * (1.0 - smoothstep(uUvRadius * 0.5, uUvRadius, inkD)));\ngl_FragColor.a *= ink;', + ); + }; + mat.customProgramCacheKey = () => 'invisible-ink'; + return mat; +} diff --git a/tests/engine.test.ts b/tests/engine.test.ts index 065eff2..82808df 100644 --- a/tests/engine.test.ts +++ b/tests/engine.test.ts @@ -116,7 +116,15 @@ describe('moteur', () => { expect(state.inventory).toEqual(['x', 'xy']); }); - it('navigation générée (flèches)', () => { + it('carnet : un indice proposé peut être noté une seule fois', () => { + const { engine, state } = makeEngine({ clues: [{ id: 'c1', text: 'indice' }] }); + expect(engine.noteClue('c1')).toBe(true); + expect(engine.noteClue('c1')).toBe(false); + expect(engine.noteClue('inconnu')).toBe(false); + expect(state.notebook).toEqual(['c1']); + }); + + it('navigation générée (flèches)', () => { const { engine, state, hs } = makeEngine(); engine.click(hs('__right')); expect(state.scene).toBe('b'); diff --git a/tests/smoke.cjs b/tests/smoke.cjs index 48f22a3..c6ca913 100644 --- a/tests/smoke.cjs +++ b/tests/smoke.cjs @@ -145,6 +145,9 @@ function check(state, c) { } else if ('combine' in step) { await slot(step.combine[0]); await slot(step.combine[1]); + } else if ('note' in step) { + await page.click('.message .clue-btn'); + await page.waitForFunction((id) => window.__escape.engine.state.notebook.includes(id), step.note); } else if ('solve' in step) { const def = await page.evaluate((id) => window.__escape.engine.scenario.puzzles.find((p) => p.id === id), step.solve); if (def.type === 'colorCode') {