Make tool upgrades cost money
This commit is contained in:
+37
-7
@@ -251,12 +251,13 @@ 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("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]]);
|
||||
Deno.test("a smithing table upgrades a wooden pickaxe with 5 stone and a brass coin, using up exactly that", async () => {
|
||||
const t = await setup([["bworld:wood_pickaxe", 1], ["bworld:stone", 7], ["bworld:brass_coin", 1]]);
|
||||
t.game.set_block(1, 100, 0, "bworld:smithing_table");
|
||||
let messages = t.take(1);
|
||||
const pickaxe = slot_of(messages, "bworld:wood_pickaxe");
|
||||
const stone = slot_of(messages, "bworld:stone");
|
||||
const coin = slot_of(messages, "bworld:brass_coin");
|
||||
|
||||
// mods' own, like the player's curios
|
||||
const containers = t.game.containers.size;
|
||||
@@ -270,9 +271,14 @@ Deno.test("a smithing table upgrades a wooden pickaxe with 5 stone, using up exa
|
||||
click(t, opened, 3);
|
||||
assertEquals(t.take(1).filter((m) => m.type === "cursor").at(-1)?.item ?? null, null);
|
||||
|
||||
// the result shows up once there's enough stone, and taking it uses up the pickaxe and 5 stone
|
||||
// nor with the stone but not the coin
|
||||
move_to_menu(t, opened, stone, 1);
|
||||
t.game.tick();
|
||||
assertEquals(menu_items(t.take(1))[3], null);
|
||||
|
||||
// the result shows up once the coin is in, and taking it uses up the pickaxe, 5 stone and the coin
|
||||
move_to_menu(t, opened, coin, 2);
|
||||
t.game.tick();
|
||||
assertEquals(menu_items(t.take(1))[3], { id: "bworld:stone_pickaxe", count: 1 });
|
||||
click(t, opened, 3);
|
||||
messages = t.take(1);
|
||||
@@ -289,14 +295,38 @@ Deno.test("a smithing table upgrades a wooden pickaxe with 5 stone, using up exa
|
||||
assertEquals(t.game.containers.size, containers, "its slots are gone");
|
||||
});
|
||||
|
||||
Deno.test("a smithing result can't be taken once its inputs are gone, even before it updates", async () => {
|
||||
const t = await setup([["bworld:wood_pickaxe", 1], ["bworld:stone", 5]]);
|
||||
Deno.test("a smithing addition needs its whole count, and all of it is used up", async () => {
|
||||
const t = await setup([["bworld:stone_pickaxe", 1], ["bworld:copper_ingot", 5], ["bworld:brass_coin", 6]]);
|
||||
t.game.set_block(1, 100, 0, "bworld:smithing_table");
|
||||
const messages = t.take(1);
|
||||
t.send(1, { type: "use_block", x: 1, y: 100, z: 0, face: "top" });
|
||||
const opened = opened_menu(t.take(1));
|
||||
move_to_menu(t, opened, slot_of(messages, "bworld:wood_pickaxe"), 0);
|
||||
move_to_menu(t, opened, slot_of(messages, "bworld:stone"), 1);
|
||||
move_to_menu(t, opened, slot_of(messages, "bworld:stone_pickaxe"), 0);
|
||||
move_to_menu(t, opened, slot_of(messages, "bworld:copper_ingot"), 1);
|
||||
|
||||
// right-clicking the coins onto the slot puts down one at a time
|
||||
const coins = inventory_slot(opened, slot_of(messages, "bworld:brass_coin"));
|
||||
click(t, opened, coins);
|
||||
for (let i = 0; i < 4; i++) t.send(1, { type: "click", menu: opened.id, slot: 2, button: 2 });
|
||||
t.game.tick();
|
||||
assertEquals(menu_items(t.take(1))[3], null);
|
||||
|
||||
t.send(1, { type: "click", menu: opened.id, slot: 2, button: 2 });
|
||||
t.game.tick();
|
||||
assertEquals(menu_items(t.take(1))[3], { id: "bworld:copper_pickaxe", count: 1 });
|
||||
click(t, opened, coins);
|
||||
click(t, opened, 3);
|
||||
assertEquals(menu_items(t.take(1)).slice(0, 4), [null, null, null, null]);
|
||||
});
|
||||
|
||||
Deno.test("a smithing result can't be taken once its inputs are gone, even before it updates", async () => {
|
||||
const t = await setup([["bworld:copper_pickaxe", 1], ["bworld:iron_ingot", 5]]);
|
||||
t.game.set_block(1, 100, 0, "bworld:smithing_table");
|
||||
const messages = t.take(1);
|
||||
t.send(1, { type: "use_block", x: 1, y: 100, z: 0, face: "top" });
|
||||
const opened = opened_menu(t.take(1));
|
||||
move_to_menu(t, opened, slot_of(messages, "bworld:copper_pickaxe"), 0);
|
||||
move_to_menu(t, opened, slot_of(messages, "bworld:iron_ingot"), 1);
|
||||
t.game.tick();
|
||||
|
||||
// take the pickaxe back out and try the result in the same tick
|
||||
|
||||
@@ -88,7 +88,11 @@ Deno.test("the recipe viewer finds what makes and uses an item, in any recipe ty
|
||||
r.type === "bworld:smelting" && outputs(r)[0].ids[0] === "bworld:iron_ingot"
|
||||
),
|
||||
);
|
||||
assertEquals(ids(inputs(making("bworld:stone_pickaxe")[0])), ["bworld:wood_pickaxe", "bworld:stone"]);
|
||||
assertEquals(ids(inputs(making("bworld:stone_pickaxe")[0])), [
|
||||
"bworld:wood_pickaxe",
|
||||
"bworld:stone",
|
||||
"bworld:brass_coin",
|
||||
]);
|
||||
assertEquals(category_name("bworld:smithing"), "Smithing");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user