v2.10.1 : bestiaire etape 2 - editeur admin (ages + monstres)

mp.js adminSetTuning : gere patch.ages (setMonsterAge, borne 0-99) et
patch.bestiary (setBestiary, champs numeriques clampes 0-99999, textes
family/speed/capacities/blason) ; reset des categories bestiary/ages.
admin.html : section Bestiaire - 8 multiplicateurs d'age + editeur monstre
(filtre famille + recherche, formulaire de tous les champs) lisant
/api/reference/bestiary+/ages, sauvegarde via le tuning. CSS dedie.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
perco
2026-06-15 16:50:01 +02:00
co-authored by Claude Opus 4.8
parent 836837fa55
commit 18f5e7fc3b
4 changed files with 126 additions and 2 deletions
+22 -1
View File
@@ -994,7 +994,28 @@ function adminSetTuning(world, patch) {
};
if (Array.isArray(patch.reset)) {
for (const cat of patch.reset) {
if (["monsters", "gear", "potions", "scrolls"].includes(cat)) db.resetCategory(cat);
if (["monsters", "gear", "potions", "scrolls", "bestiary", "ages"].includes(cat)) db.resetCategory(cat);
}
}
// Bestiaire : multiplicateurs d'âge + édition d'un monstre (valeurs absolues).
if (patch.ages && typeof patch.ages === "object") {
for (const [age, mult] of Object.entries(patch.ages)) {
const a = Number(age), m = Number(mult);
if (Number.isInteger(a) && a >= 0 && a <= 7 && Number.isFinite(m)) db.setMonsterAge(a, Math.max(0, Math.min(99, m)));
}
}
if (patch.bestiary && typeof patch.bestiary === "object") {
const knownB = new Set(db.bestiaryAll().map(b => b.name));
const txt = new Set(["family", "speed", "capacities", "blason"]);
for (const [name, vals] of Object.entries(patch.bestiary)) {
if (!knownB.has(name) || typeof vals !== "object") continue;
const entry = {};
for (const k of db.BESTIARY_KEYS) {
if (vals[k] == null) continue;
if (txt.has(k)) entry[k] = String(vals[k]).slice(0, 300);
else { const v = Number(vals[k]); if (Number.isFinite(v)) entry[k] = clampInt(v, 0, 99999); }
}
if (Object.keys(entry).length) db.setBestiary(name, entry);
}
}
if (patch.monsters && typeof patch.monsters === "object") {