Add sell value for every block and item in the game, crazy

This commit is contained in:
2026-10-04 01:09:31 -03:00
parent 67c84e3504
commit 6a6abae0d5
67 changed files with 365 additions and 52 deletions
+17
View File
@@ -45,10 +45,27 @@ Deno.test("mods/bworld json survives going to the registry and back", async () =
}
for (const file of Deno.readDirSync("mods/bworld/items")) {
const { item: json } = JSON.parse(Deno.readTextFileSync(`mods/bworld/items/${file.name}`));
// one without a texture fills in a block's item instead, see the test below
if (json.texture === undefined) continue;
assertEquals(item_to_json(json.id, item_from_json(json)), json, file.name);
}
});
Deno.test("an item file without a texture fills in the item of the block with its id", async () => {
const dir = mods_with_template();
Deno.writeTextFileSync(
`${dir}/copper_tools/items/example_block.json`,
JSON.stringify({ format_version: 1, item: { id: "copper_tools:example_block", base_sell_value: 3 } }),
);
await test_game(dir);
const item = EverythingRegistry.get<ItemRegistry>("items", "copper_tools:example_block")!;
assertEquals(item.base_sell_value, 3);
// and keeps what the block gave it
assertEquals(item.block_id, "copper_tools:example_block");
assertEquals(item.texture_id, "copper_tools:example_block");
Deno.removeSync(dir, { recursive: true });
});
Deno.test("a mod made from the template loads and runs", async () => {
const dir = mods_with_template();
const { game, take, send } = await test_game(dir);