Asset dump
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// dangerous business's placement components: slabs and other blocks that go in the top or bottom half, blocks that
|
||||
// join the same block beside them, and blocks that pick some of their looks when placed
|
||||
import { assertEquals } from "@std/assert";
|
||||
import { get_state_value } from "@/common/utils.ts";
|
||||
import { copy_dir, test_game } from "./helpers.ts";
|
||||
|
||||
const HALF = "dangerous_business:concrete_wall_slab";
|
||||
const CONNECTS = "dangerous_business:floor_grate";
|
||||
const RANDOM_LOOK = "dangerous_business:water_puddle";
|
||||
const FLOOR = "dangerous_business:concrete_floor";
|
||||
|
||||
// alice on a concrete floor at y 100, south of 0 100 0 and looking north, holding each of the blocks. it's a game of
|
||||
// its own, which tests playing mods/ leave out
|
||||
async function setup() {
|
||||
const dir = Deno.makeTempDirSync({ prefix: "dangerous_business_" });
|
||||
copy_dir("mods/dangerous_business", `${dir}/dangerous_business`);
|
||||
const t = await test_game(dir);
|
||||
t.join(1, "alice");
|
||||
for (let x = -3; x <= 3; x++) {
|
||||
for (let z = -3; z <= 3; z++) {
|
||||
t.game.set_block(x, 99, z, FLOOR);
|
||||
for (let y = 100; y < 103; y++) t.game.set_block(x, y, z, "cubi:air");
|
||||
}
|
||||
}
|
||||
t.send(1, { type: "move", x: 0.5, y: 100, z: 3.5, yaw: 0, pitch: 0 });
|
||||
for (const id of [HALF, CONNECTS, RANDOM_LOOK]) t.send(1, { type: "chat", text: `/give ${id} 64` });
|
||||
const hold = (slot: number) => t.send(1, { type: "select_slot", slot });
|
||||
const state = (x: number, y: number, z: number, name: string) =>
|
||||
get_state_value(t.game.world.get_block_value(x, y, z), t.game.world.get_block_info(x, y, z)!, name);
|
||||
return { t, hold, state };
|
||||
}
|
||||
|
||||
Deno.test("a half block goes in the top half against the underside of a block or the upper half of a side", async () => {
|
||||
const { t, hold, state } = await setup();
|
||||
hold(0);
|
||||
t.send(1, { type: "use_block", x: 0, y: 99, z: 0, face: "top", hit: [0.5, 1, 0.5] });
|
||||
assertEquals(state(0, 100, 0, "half"), 0);
|
||||
|
||||
t.game.set_block(0, 102, -1, FLOOR);
|
||||
t.send(1, { type: "use_block", x: 0, y: 102, z: -1, face: "bottom", hit: [0.5, 0, 0.5] });
|
||||
assertEquals(state(0, 101, -1, "half"), 1);
|
||||
|
||||
t.send(1, { type: "use_block", x: 0, y: 102, z: -1, face: "south", hit: [0.5, 0.8, 1] });
|
||||
assertEquals(state(0, 102, 0, "half"), 1);
|
||||
t.send(1, { type: "use_block", x: 0, y: 102, z: -1, face: "west", hit: [0, 0.2, 0.5] });
|
||||
assertEquals(state(-1, 102, -1, "half"), 0);
|
||||
});
|
||||
|
||||
Deno.test("a connecting block joins the same block beside it, and parts when it's gone", async () => {
|
||||
const { t, hold, state } = await setup();
|
||||
hold(1);
|
||||
t.send(1, { type: "use_block", x: 0, y: 99, z: 0, face: "top", hit: [0.5, 1, 0.5] });
|
||||
t.send(1, { type: "use_block", x: 1, y: 99, z: 0, face: "top", hit: [0.5, 1, 0.5] });
|
||||
// the one placed second joins the first as it's placed, and the first joins it when it's told
|
||||
assertEquals(state(1, 100, 0, "west"), 1);
|
||||
assertEquals(state(0, 100, 0, "east"), 1);
|
||||
assertEquals(state(0, 100, 0, "north"), 0);
|
||||
|
||||
t.game.set_block(1, 100, 0, FLOOR);
|
||||
assertEquals(state(0, 100, 0, "east"), 0);
|
||||
});
|
||||
|
||||
Deno.test("a block with a random look picks the same one wherever it's placed again", async () => {
|
||||
const { t, hold, state } = await setup();
|
||||
hold(2);
|
||||
const looks = () => {
|
||||
const out = [];
|
||||
for (let x = -3; x <= 3; x++) {
|
||||
t.send(1, { type: "use_block", x, y: 99, z: 0, face: "top", hit: [0.5, 1, 0.5] });
|
||||
out.push(`${state(x, 100, 0, "look")} ${state(x, 100, 0, "facing")}`);
|
||||
}
|
||||
return out;
|
||||
};
|
||||
const first = looks();
|
||||
for (let x = -3; x <= 3; x++) t.game.set_block(x, 100, 0, "cubi:air");
|
||||
assertEquals(looks(), first);
|
||||
// the puddle has three looks, and seven of them don't all come out the same
|
||||
for (const look of first) assertEquals(Number(look.split(" ")[0]) < 3, true);
|
||||
assertEquals(new Set(first).size > 1, true);
|
||||
});
|
||||
Reference in New Issue
Block a user