Region file format
This commit is contained in:
+4
-34
@@ -165,11 +165,13 @@ Deno.test("a new watering can starts empty, and players are told so in its lore"
|
||||
assertEquals(can.lore, "Water: 0/32");
|
||||
|
||||
// lore is worked out for players, it isn't saved
|
||||
const saved = JSON.parse(t.game.save());
|
||||
const saved = JSON.parse(t.game.save().level);
|
||||
const saved_can = saved.players.alice?.inventory?.find((i: Msg) => i?.id === "bworld:watering_can");
|
||||
assert(!saved_can || saved_can.lore === undefined);
|
||||
t.game.on_disconnect(1);
|
||||
const after = JSON.parse(t.game.save()).players.alice.inventory.find((i: Msg) => i?.id === "bworld:watering_can");
|
||||
const after = JSON.parse(t.game.save().level).players.alice.inventory.find((i: Msg) =>
|
||||
i?.id === "bworld:watering_can"
|
||||
);
|
||||
assertEquals(after.lore, undefined);
|
||||
});
|
||||
|
||||
@@ -182,38 +184,6 @@ Deno.test("items are called by their name, or by one made from their id", async
|
||||
assertEquals(display_name("test:thing"), "A Thing");
|
||||
});
|
||||
|
||||
Deno.test("chests and furnaces from a world saved before they were mod code keep their items and keep smelting", async () => {
|
||||
const t = await test_game("mods", Deno.readTextFileSync("tests/fixtures/world_v2.json"), "fixture-seed");
|
||||
t.join(1, "alice");
|
||||
|
||||
t.send(1, { type: "use_block", x: 1, y: 100, z: 0, face: "top" });
|
||||
const chest = last_container(t.take(1), "screen");
|
||||
assertEquals(chest.length, 27);
|
||||
assertEquals(chest[4], { id: "bworld:coal", count: 6 });
|
||||
t.send(1, { type: "close_screen" });
|
||||
|
||||
t.send(1, { type: "use_block", x: 2, y: 100, z: 0, face: "top" });
|
||||
let messages = t.take(1);
|
||||
assertEquals(last_container(messages, "screen"), [
|
||||
{ id: "bworld:iron_ore", count: 2 },
|
||||
{ id: "bworld:coal", count: 2 },
|
||||
{ id: "bworld:iron_ingot", count: 1 },
|
||||
]);
|
||||
const properties = messages.filter((m) => m.type === "screen_properties").at(-1).properties;
|
||||
assertEquals(properties, { progress: 50, progress_max: 200, fuel: 751, fuel_max: 1000 });
|
||||
|
||||
// 150 more ticks finish the second ingot
|
||||
for (let i = 0; i < 150; i++) t.game.tick();
|
||||
messages = t.take(1);
|
||||
assertEquals(last_container(messages, "screen")[2], { id: "bworld:iron_ingot", count: 2 });
|
||||
|
||||
// saved in the new format, nothing lost
|
||||
const saved = JSON.parse(t.game.save());
|
||||
assertEquals(saved.version, 3);
|
||||
assert(saved.tiles.every((tile: Msg) => tile.data === undefined && tile.containers === undefined));
|
||||
assertEquals(Object.keys(saved.containers).length, 2);
|
||||
});
|
||||
|
||||
Deno.test("a smithing table upgrades a wooden pickaxe with 5 stone, using up exactly that", async () => {
|
||||
const t = await setup([["bworld:wood_pickaxe", 1], ["bworld:stone", 7]]);
|
||||
t.game.set_block(1, 100, 0, "bworld:smithing_table");
|
||||
|
||||
Reference in New Issue
Block a user