Add guide character (owl) with varied bilingual messages, moods and setting

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
denis
2026-10-16 15:00:18 +02:00
parent 6b4b89a742
commit f732a5a765
21 changed files with 651 additions and 18 deletions
+11 -2
View File
@@ -5,14 +5,17 @@ import { el, renderInline } from './dom.js';
export class HintPanel {
#i18n;
#hints;
#onReveal;
#revealed = 0;
#button;
#list;
#root;
/** @param {string[]} hints Indices déjà localisés, du plus vague au plus précis. */
constructor(i18n, hints) {
/** @param {string[]} hints Indices déjà localisés, du plus vague au plus précis.
* @param {{onReveal?: () => void}} [options] Rappel à chaque indice révélé. */
constructor(i18n, hints, { onReveal = () => {} } = {}) {
this.#i18n = i18n;
this.#onReveal = onReveal;
this.#hints = hints;
this.#button = el('button', { type: 'button', class: 'btn', onclick: () => this.reveal() });
this.#list = el('ol', { class: 'hint-list', 'aria-live': 'polite' });
@@ -24,6 +27,11 @@ export class HintPanel {
return this.#root;
}
/** Reste-t-il au moins un indice à révéler ? */
get hasMore() {
return this.#revealed < this.#hints.length;
}
/** Affiche l'indice suivant. Renvoie false s'il n'en reste plus. */
reveal() {
if (this.#revealed >= this.#hints.length) {
@@ -32,6 +40,7 @@ export class HintPanel {
this.#list.append(el('li', {}, renderInline(this.#hints[this.#revealed])));
this.#revealed += 1;
this.#refresh();
this.#onReveal();
return true;
}