Jester time

This commit is contained in:
2026-11-21 23:07:42 -03:00
parent 0c711b8163
commit f308ab52f1
14 changed files with 3317 additions and 395 deletions
+13
View File
@@ -4,6 +4,7 @@
// mobs following paths, see server/game/entity/navigation.ts
import { assert, assertEquals } from "@std/assert";
import { test_game, test_mob } from "./helpers.ts";
import { MeleeAttackGoal } from "@/server/game/entity/goals.ts";
// two rooms on a stone floor at y 99, split by a wall at x 3 with a doorway 2 high at z 4. a goal-less mob in the
// west room at 0.5 100 0.5, and alice in its corner, so it thinks
@@ -81,3 +82,15 @@ Deno.test("a script's mob walks its way, and stops when told", async () => {
assert(Math.hypot(ref.position.x - x, ref.position.z - z) < 0.5);
assertEquals(ref.blocked_by, undefined);
});
Deno.test("a mob going after its target stops when a script lets the target go partway through its thinking", async () => {
const { game, mob } = await rooms();
const melee = new MeleeAttackGoal(mob);
mob.target = game.players()[0];
assert(melee.can_use());
melee.start();
melee.tick();
mob.target = undefined;
melee.tick();
assert(!melee.can_continue_to_use());
});