2.1.0 : connexion multi-appareils (mot de passe + login) et tuning admin du bestiaire, de l'équipement et des trésors

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
perco
2026-06-12 15:37:21 +02:00
co-authored by Claude Fable 5
parent 1a5d2c7317
commit 646a147774
8 changed files with 509 additions and 25 deletions
+20 -1
View File
@@ -161,7 +161,7 @@ function handleMP(req, res, url) {
if (req.method === "POST" && url.pathname === "/api/mp/join") {
return readBody(req, res, body => {
const r = mp.newTroll(WORLD, body.name, body.race);
const r = mp.newTroll(WORLD, body.name, body.race, body.password);
if (r.error) return sendJSON(res, 400, { error: r.error });
worldDirty = true;
return sendJSON(res, 201, {
@@ -171,6 +171,17 @@ function handleMP(req, res, url) {
});
}
if (req.method === "POST" && url.pathname === "/api/mp/login") {
return readBody(req, res, body => {
const r = mp.login(WORLD, body.name, body.password);
if (r.error) return sendJSON(res, 403, { error: r.error });
return sendJSON(res, 200, {
id: r.troll.id, secret: r.troll.secret,
state: mp.stateFor(WORLD, r.troll),
});
});
}
if (req.method === "GET" && url.pathname === "/api/mp/state") {
const t = mp.authTroll(WORLD, url.searchParams.get("id"), url.searchParams.get("secret"));
if (!t) return sendJSON(res, 403, { error: "troll inconnu ou clé invalide" });
@@ -211,6 +222,14 @@ function handleMP(req, res, url) {
return sendJSON(res, 200, cfg);
});
}
if (req.method === "PUT" && url.pathname === "/api/mp/admin/tuning") {
return readBody(req, res, body => {
const tuning = mp.adminSetTuning(WORLD, body);
worldDirty = true;
mp.worldLog(WORLD, "⚗️ Les Dieux Trõlls ont retouché bêtes et trésors.");
return sendJSON(res, 200, tuning);
});
}
if (req.method === "POST" && url.pathname === "/api/mp/admin/reset") {
mp.adminResetWorld(WORLD);
worldDirty = true;