Shared state between client and server

This commit is contained in:
2026-10-03 18:45:07 -03:00
parent 63e6248f9f
commit 7417bfd5f1
24 changed files with 656 additions and 193 deletions
+2 -1
View File
@@ -43,7 +43,7 @@ Deno.test("packing a mod keeps its data, scripts, textures and credits, and give
const bworld = read_bmod(Deno.readFileSync(`${folder}/bworld.bmod`), "bworld.bmod");
assertEquals(bworld.data.blocks.length, [...Deno.readDirSync("mods/bworld/blocks")].length);
assertEquals(Object.keys(bworld.scripts), ["server", "client"]);
assertEquals(Object.keys(bworld.scripts), ["server", "client", "shared"]);
Deno.removeSync(sources, { recursive: true });
Deno.removeSync(folder, { recursive: true });
@@ -115,6 +115,7 @@ Deno.test("the server loads every .bmod in its folder, dependencies first, and p
const copy = read_bmod(mod.client_bytes, mod.listing.file);
assertEquals(copy.scripts.server, undefined, "server scripts never go to players");
assertEquals(copy.scripts.worldgen, undefined, "players get the world from the server, not its generator");
assertEquals(copy.scripts.shared, mod.bmod.scripts.shared, "players run the shared rules too");
assertEquals(copy.data, mod.bmod.data);
}
assert(mods[1].bmod.scripts.server, "the server still has it");