v2.11.1 : nom monstre 'Nom [Age]' + gestion du feminin

bestiary.js regenere avec champ gender (m/f, liste curatee de ~31
feminins) + export AGE_NAMES_F. db.js : gender en colonne (BESTIARY_TXT_KEYS)
+ migration ALTER TABLE ... ADD COLUMN gender AVANT le seed, puis UPDATE
du genre des lignes existantes. game.js buildBestiaryMonster(.., ageNamesF, ..)
: nom = 'Nom [Age]' avec age accorde au genre. mp.js + makeMonster passent
AGE_NAMES_F. treasures.js : age affiche au feminin. admin : champ Genre.
Tests : format + feminin (Plante [Doyenne]).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
perco
2026-06-15 21:05:00 +02:00
co-authored by Claude Opus 4.8
parent 116ac7d063
commit 867569c3c9
8 changed files with 38 additions and 13 deletions
+5
View File
@@ -234,6 +234,11 @@ non affilié au jeu original de Mountyhall SARL.
## Versions
- **2.11.1** (2026-06-15) — Nom des monstres au format **« Nom [Âge] »**
(« Ankheg [Mûr] », « Lutin [Adulte] ») au lieu du préfixe. Gestion du
**féminin** : chaque monstre a un genre (m/f, éditable en admin), et l'âge
s'accorde (« Plante Carnivore [Doyenne] »). ~31 monstres détectés féminins par
défaut (liste curatée), corrigeable au cas par cas dans l'admin.
- **2.11.0** (2026-06-15) — Bestiaire, étape 4 : **les monstres du bestiaire
apparaissent dans le jeu** (solo ET monde partagé), à la place des 7 anciens.
À chaque apparition, on choisit un monstre dont le niveau de base tombe dans la
+1 -1
View File
@@ -339,7 +339,7 @@ async function connect() {
/* ---------- Bestiaire ---------- */
let BEST = [], AGES = [];
const BEST_FIELDS = [
["family", "Famille", "text"], ["minAge", "Âge min", "int"], ["maxAge", "Âge max", "int"],
["family", "Famille", "text"], ["gender", "Genre (m/f)", "text"], ["minAge", "Âge min", "int"], ["maxAge", "Âge max", "int"],
["levelMin", "Niveau min", "int"], ["levelMax", "Niveau max", "int"],
["pvMin", "PV min", "int"], ["pvMax", "PV max", "int"],
["attMin", "ATT min (D6)", "int"], ["attMax", "ATT max", "int"],
+7 -1
View File
@@ -26,7 +26,7 @@ const bestiaryLib = require("./js/bestiary.js");
const BESTIARY_STATS = ["level", "pv", "att", "esq", "deg", "reg", "armPhys", "armMag", "vue", "mm", "rm"];
const BESTIARY_RANGE_KEYS = BESTIARY_STATS.flatMap(k => [k + "Min", k + "Max"]);
const BESTIARY_INT_KEYS = [...BESTIARY_RANGE_KEYS, "minAge", "maxAge", "fly", "ranged", "magic", "seesHidden", "nbAtt"];
const BESTIARY_TXT_KEYS = ["family", "speed", "capacities", "blason"];
const BESTIARY_TXT_KEYS = ["family", "speed", "capacities", "blason", "gender"];
const BESTIARY_KEYS = [...BESTIARY_INT_KEYS, ...BESTIARY_TXT_KEYS]; // hors `name` (clé)
const MONSTER_KEYS = ["level", "att", "attMag", "esq", "deg", "degMag", "pv", "armor", "armorMag", "vue"];
@@ -147,6 +147,9 @@ function init(file = ":memory:") {
age INTEGER PRIMARY KEY, mult REAL
);
`);
// Migration : la colonne `gender` du bestiaire a été ajoutée après coup → on
// l'ajoute aux bases déjà créées AVANT tout INSERT/UPDATE qui la référence.
try { DB.exec("ALTER TABLE bestiary ADD COLUMN gender TEXT"); } catch { /* déjà là */ }
const insM = DB.prepare(`INSERT OR IGNORE INTO monsters
(name, emoji, boss, isStatic, ${MONSTER_KEYS.join(", ")})
VALUES (?, ?, ?, ?, ${MONSTER_KEYS.map(() => "?").join(", ")})`);
@@ -171,6 +174,9 @@ function init(file = ":memory:") {
for (const b of bestiaryLib.BESTIARY) insB.run(b.name, ...BESTIARY_KEYS.map(k => b[k]));
const insA = DB.prepare("INSERT OR IGNORE INTO monster_ages (age, mult) VALUES (?, ?)");
bestiaryLib.AGE_MULT.forEach((mult, age) => insA.run(age, mult));
// Peuple le genre des lignes déjà présentes (sans genre) depuis la référence.
const updGender = DB.prepare("UPDATE bestiary SET gender = ? WHERE name = ? AND (gender IS NULL OR gender = '')");
for (const b of bestiaryLib.BESTIARY) updGender.run(b.gender, b.name);
// Correctif des bases déjà créées : PufPuff avait été seedé à tort en [0,2]
// (le niveau 0 d'une potion n'existe pas, minimum 1) → on le ramène à [1,3].
// Le garde `powerMin = 0` évite d'écraser une plage éditée volontairement.
+5 -3
View File
File diff suppressed because one or more lines are too long
+5 -5
View File
@@ -4,7 +4,7 @@
"use strict";
const APP_VERSION = "2.11.0";
const APP_VERSION = "2.11.1";
/* Alpha : maîtrise initiale haute pour les tests. Remettre 15 % / 15 % à la v1.0 officielle. */
const START_COMP_PCT = 90;
@@ -218,7 +218,7 @@ const FAMILY_EMOJI_G = { Insecte: "🐛", Animal: "🐾", "Démon": "👿", Huma
* on tire chaque stat dans sa plage. `list` = lignes du bestiaire, `ageMults` =
* [m0..m7], `ageNames` = noms d'âge par famille. Partagé solo (données statiques
* de bestiary.js) / multi (données de la base, tunées admin). */
function buildBestiaryMonster(list, ageMults, ageNames, depth, x, y) {
function buildBestiaryMonster(list, ageMults, ageNames, ageNamesF, depth, x, y) {
if (!list || !list.length) return null;
const band = 3;
let pool = list.filter(m => m.levelMin <= depth + band && m.levelMax >= depth - band);
@@ -232,9 +232,9 @@ function buildBestiaryMonster(list, ageMults, ageNames, depth, x, y) {
const f = (ageMults[age] || 1) / (ageMults[b.minAge] || 1);
const roll = (mn, mx) => { const lo = Math.round(mn * f), hi = Math.round(mx * f); return lo + Math.floor(Math.random() * (Math.max(lo, hi) - lo + 1)); };
const att = Math.max(1, roll(b.attMin, b.attMax)), deg = Math.max(1, roll(b.degMin, b.degMax)), pv = Math.max(1, roll(b.pvMin, b.pvMax));
const names = (ageNames && ageNames[b.family]) || [];
const names = ((b.gender === "f" ? ageNamesF : ageNames) || {})[b.family] || [];
return {
name: ((names[age] ? names[age] + " " : "") + b.name).trim(),
name: `${b.name}${names[age] ? " [" + names[age] + "]" : ""}`,
emoji: FAMILY_EMOJI_G[b.family] || "👹",
level: Math.max(1, roll(b.levelMin, b.levelMax)),
att, esq: Math.max(1, roll(b.esqMin, b.esqMax)), deg,
@@ -251,7 +251,7 @@ function buildBestiaryMonster(list, ageMults, ageNames, depth, x, y) {
function makeMonster(depth, x, y) {
// Bestiaire (données statiques chargées dans le navigateur en solo)
if (typeof BESTIARY !== "undefined" && BESTIARY.length)
return buildBestiaryMonster(BESTIARY, AGE_MULT, AGE_NAMES, depth, x, y);
return buildBestiaryMonster(BESTIARY, AGE_MULT, AGE_NAMES, AGE_NAMES_F, depth, x, y);
// Repli (bestiaire non chargé) : ancien système des 7 types
const pool = MONSTER_TYPES.filter(m => m.level <= depth + 1 && m.level >= Math.max(1, depth - 2));
const type = pool[Math.floor(Math.random() * pool.length)];
+9 -1
View File
@@ -64,7 +64,7 @@ function templateCard(t) {
/* Carte d'un monstre du bestiaire : blason + stats (plages) + âges + capacités. */
function monsterCard(m) {
const rg = (a, b, s = "") => (a === b ? `${a}${s}` : `${a}-${b}${s}`);
const ages = BESTIARY_AGE_NAMES[m.family] || [];
const ages = ((m.gender === "f" ? BESTIARY_AGE_NAMES_F : BESTIARY_AGE_NAMES)[m.family]) || [];
const ageTxt = m.minAge === m.maxAge ? (ages[m.minAge] || "—")
: `${ages[m.minAge] || m.minAge}${ages[m.maxAge] || m.maxAge}`;
const fx = [
@@ -231,6 +231,14 @@ const BESTIARY_AGE_NAMES = {
Monstre: ["Nouveau", "Jeune", "Adulte", "Vétéran", "Briscard", "Doyen", "Légendaire", "Mythique"],
"Mort-Vivant": ["Naissant", "Récent", "Ancien", "Vénérable", "Séculaire", "Antique", "Ancestral", "Antédiluvien"],
};
const BESTIARY_AGE_NAMES_F = {
Insecte: ["Larve", "Immature", "Juvénile", "Imago", "Développée", "Mûre", "Accomplie", "Achevée"],
Animal: ["Bébé", "Enfançon", "Jeune", "Adulte", "Mature", "Chef de harde", "Ancienne", "Ancêtre"],
"Démon": ["Initiale", "Novice", "Mineure", "Favorite", "Majeure", "Supérieure", "Suprême", "Ultime"],
Humanoide: ["Nouvelle", "Jeune", "Adulte", "Vétérane", "Briscarde", "Doyenne", "Légendaire", "Mythique"],
Monstre: ["Nouvelle", "Jeune", "Adulte", "Vétérane", "Briscarde", "Doyenne", "Légendaire", "Mythique"],
"Mort-Vivant": ["Naissante", "Récente", "Ancienne", "Vénérable", "Séculaire", "Antique", "Ancestrale", "Antédiluvienne"],
};
const FAMILY_EMOJI = { Insecte: "🐛", Animal: "🐾", "Démon": "👿", Humanoide: "🧝", Monstre: "👹", "Mort-Vivant": "💀" };
async function fetchRef(cat) {
+1 -1
View File
@@ -163,7 +163,7 @@ function spawnMonster(world, now = Date.now()) {
// profondeur, avec un âge au hasard. Données de la base (tunées admin) +
// multiplicateurs d'âge.
const depth = world.config.worldDepth;
const m = g.buildBestiaryMonster(db.bestiaryAll(), db.monsterAges().map(a => a.mult), bestiaryLib.AGE_NAMES, depth, pos.x, pos.y);
const m = g.buildBestiaryMonster(db.bestiaryAll(), db.monsterAges().map(a => a.mult), bestiaryLib.AGE_NAMES, bestiaryLib.AGE_NAMES_F, depth, pos.x, pos.y);
if (!m) return null;
m.id = world.nextId++;
m.dlaMs = Math.round(monsterDlaMs(world.config));
+5 -1
View File
@@ -262,10 +262,14 @@ function makeWorld(over = {}) {
pvMin: 5000, pvMax: 5000, attMin: 7, attMax: 7, esqMin: 3, esqMax: 3, degMin: 4, degMax: 4, regMin: 1, regMax: 1,
armPhysMin: 2, armPhysMax: 2, armMagMin: 0, armMagMax: 0, vueMin: 4, vueMax: 4, mmMin: 0, mmMax: 0, rmMin: 0, rmMax: 0,
fly: 0, ranged: 0, magic: 1, seesHidden: 0, speed: "Normale", nbAtt: 1, capacities: "", blason: "" }];
const bm = g.buildBestiaryMonster(one, [1, 1, 1, 1, 1, 1, 1, 1], best.AGE_NAMES, 10, 0, 0);
const bm = g.buildBestiaryMonster(one, [1, 1, 1, 1, 1, 1, 1, 1], best.AGE_NAMES, best.AGE_NAMES_F, 10, 0, 0);
assert.strictEqual(bm.pv, 5000, "PV tiré dans la plage du bestiaire");
assert.strictEqual(bm.att, 7, "ATT tirée dans la plage");
assert.strictEqual(bm.attMag, 7, "monstre magique : attMag = att");
assert.strictEqual(bm.name, "Cobaye [Nouveau]", "nom au format Nom [Âge]");
// féminin : « Plante [Doyenne] »
const fem = g.buildBestiaryMonster([{ ...one[0], name: "Plante", gender: "f", minAge: 5, maxAge: 5 }], [1, 1, 1, 1, 1, 1, 1, 1], best.AGE_NAMES, best.AGE_NAMES_F, 10, 0, 0);
assert.strictEqual(fem.name, "Plante [Doyenne]", "âge au féminin : " + fem.name);
// édition admin du bestiaire reflétée en base
const name = db.bestiaryAll()[0].name;
mp.adminSetTuning(w, { bestiary: { [name]: { pvMin: 4242, pvMax: 4242 } } });