Coilheads kinda
This commit is contained in:
@@ -3,10 +3,11 @@
|
||||
|
||||
// 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, blocks that pick some of their looks when placed, and pipes that stand up or lie
|
||||
// down. and the death block
|
||||
import { assert, assertEquals, assertNotEquals } from "@std/assert";
|
||||
// down. the death block, and the coilhead
|
||||
import { assert, assertAlmostEquals, assertEquals, assertNotEquals } from "@std/assert";
|
||||
import { ItemStack } from "@/common/inventory.ts";
|
||||
import { get_state_value } from "@/common/utils.ts";
|
||||
import { create_entity } from "@/server/game/entity/entity_types.ts";
|
||||
import { copy_dir, test_game } from "./helpers.ts";
|
||||
|
||||
const HALF = "dangerous_business:concrete_wall_slab";
|
||||
@@ -15,6 +16,7 @@ const RANDOM_LOOK = "dangerous_business:water_puddle";
|
||||
const FLOOR = "dangerous_business:concrete_floor";
|
||||
const DEATH = "dangerous_business:death";
|
||||
const PIPE = "dangerous_business:double_steel_pipes";
|
||||
const COILHEAD = "dangerous_business:coilhead";
|
||||
|
||||
// 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
|
||||
@@ -123,3 +125,35 @@ Deno.test("the death block takes away an item falling into it", async () => {
|
||||
for (let i = 0; i < 40 && !item.removed; i++) t.game.tick();
|
||||
assert(item.removed);
|
||||
});
|
||||
|
||||
// a coilhead 6 blocks north of alice, right where she's looking
|
||||
function spawn_coilhead(t: Awaited<ReturnType<typeof setup>>["t"]) {
|
||||
const coilhead = create_entity(t.game.entities, COILHEAD)!;
|
||||
coilhead.set_position(0.5, 100, -2.5);
|
||||
t.game.entities.add_entity(coilhead);
|
||||
return coilhead;
|
||||
}
|
||||
|
||||
Deno.test("a coilhead can't move while a player looks at it, and comes for them once they look away", async () => {
|
||||
const { t } = await setup();
|
||||
const coilhead = spawn_coilhead(t);
|
||||
for (let i = 0; i < 100; i++) t.game.tick();
|
||||
assertAlmostEquals(coilhead.x, 0.5, 1e-6);
|
||||
assertAlmostEquals(coilhead.z, -2.5, 1e-6);
|
||||
|
||||
// looking south, with it behind her
|
||||
t.send(1, { type: "move", x: 0.5, y: 100, z: 3.5, yaw: Math.PI, pitch: 0 });
|
||||
for (let i = 0; i < 100; i++) t.game.tick();
|
||||
assert(coilhead.z > 0, `it only got to z ${coilhead.z}`);
|
||||
});
|
||||
|
||||
Deno.test("a player can't stop a coilhead through a wall", async () => {
|
||||
const { t } = await setup();
|
||||
for (let x = -3; x <= 3; x++) {
|
||||
for (let y = 100; y < 103; y++) t.game.set_block(x, y, 0, FLOOR);
|
||||
}
|
||||
const coilhead = spawn_coilhead(t);
|
||||
for (let i = 0; i < 100; i++) t.game.tick();
|
||||
// up against the wall, still on its way to her
|
||||
assert(coilhead.z > -1.5, `it only got to z ${coilhead.z}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user