48 lines
1.7 KiB
TypeScript
48 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { enemyTelegraphContainsPosition } from "./enemyTelegraphGeometry";
|
|
|
|
const placement = {
|
|
sourcePosition: [0, 0, 0] as const,
|
|
targetPosition: [0, 0, 10] as const,
|
|
sourceYaw: 0,
|
|
};
|
|
|
|
describe("enemy telegraph gameplay geometry", () => {
|
|
it("matches source and target anchored circles", () => {
|
|
expect(enemyTelegraphContainsPosition({
|
|
shape: "circle", anchor: "source", warningMs: 1_000, radius: 4,
|
|
}, placement, [3, 0, 0])).toBe(true);
|
|
expect(enemyTelegraphContainsPosition({
|
|
shape: "circle", anchor: "target", warningMs: 1_000, radius: 3,
|
|
}, placement, [0, 0, 8])).toBe(true);
|
|
expect(enemyTelegraphContainsPosition({
|
|
shape: "circle", anchor: "target", warningMs: 1_000, radius: 3,
|
|
}, placement, [0, 0, 4])).toBe(false);
|
|
});
|
|
|
|
it("keeps cone hits in front and within the visible angle", () => {
|
|
const cone = {
|
|
shape: "cone" as const,
|
|
anchor: "source" as const,
|
|
warningMs: 1_000,
|
|
length: 10,
|
|
angleDegrees: 90,
|
|
};
|
|
expect(enemyTelegraphContainsPosition(cone, placement, [2, 0, 7])).toBe(true);
|
|
expect(enemyTelegraphContainsPosition(cone, placement, [8, 0, 2])).toBe(false);
|
|
expect(enemyTelegraphContainsPosition(cone, placement, [0, 0, -2])).toBe(false);
|
|
});
|
|
|
|
it("uses the visible line width for collision", () => {
|
|
const line = {
|
|
shape: "line" as const,
|
|
anchor: "source" as const,
|
|
warningMs: 1_000,
|
|
length: 12,
|
|
width: 4,
|
|
};
|
|
expect(enemyTelegraphContainsPosition(line, placement, [1.9, 0, 8])).toBe(true);
|
|
expect(enemyTelegraphContainsPosition(line, placement, [2.1, 0, 8])).toBe(false);
|
|
});
|
|
});
|