Goals
This commit is contained in:
@@ -58,3 +58,26 @@ Deno.test("a mob whose way gets walled up searches again, and gives up when ther
|
||||
assert(!mob.navigation.moving);
|
||||
assert(mob.x < 3);
|
||||
});
|
||||
|
||||
Deno.test("a monster finds its way around a wall to the player it's after", async () => {
|
||||
const { game } = await rooms();
|
||||
const alice = game.players()[0];
|
||||
alice.set_position(8.5, 100, 0.5);
|
||||
const monster = test_mob(game, { behavior: "monster" }, 0.5, 100, 0.5);
|
||||
for (let i = 0; i < 400 && Math.hypot(monster.x - 8.5, monster.z - 0.5) > 2; i++) game.tick();
|
||||
assert(Math.hypot(monster.x - 8.5, monster.z - 0.5) <= 2, `it got to ${monster.x} ${monster.z}`);
|
||||
});
|
||||
|
||||
Deno.test("a script's mob walks its way, and stops when told", async () => {
|
||||
const { game, mob } = await rooms();
|
||||
const ref = game.mods.mob(mob);
|
||||
assert(ref.move_to(6.5, 100, 0.5));
|
||||
assert(ref.moving);
|
||||
for (let i = 0; i < 20; i++) game.tick();
|
||||
ref.stop();
|
||||
assert(!ref.moving);
|
||||
const { x, z } = ref.position;
|
||||
for (let i = 0; i < 20; i++) game.tick();
|
||||
assert(Math.hypot(ref.position.x - x, ref.position.z - z) < 0.5);
|
||||
assertEquals(ref.blocked_by, undefined);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user