55 lines
2.5 KiB
TypeScript
55 lines
2.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { partyRejoinMovement } from "./partyRejoin";
|
|
import { emptyPartyRouteState } from "./partyPathing";
|
|
import type { PartyNavigationGraph } from "./partyNavigation";
|
|
|
|
const graph: PartyNavigationGraph = {
|
|
nodes: [
|
|
{ id: 0, position: [0, 0, 0], neighbors: [{ to: 1, cost: 6 }] },
|
|
{ id: 1, position: [0, 0, 6], neighbors: [{ to: 0, cost: 6 }, { to: 2, cost: 2 }] },
|
|
{ id: 2, position: [2, 0, 6], neighbors: [{ to: 1, cost: 2 }, { to: 3, cost: 6 }] },
|
|
{ id: 3, position: [2, 0, 0], neighbors: [{ to: 2, cost: 6 }] },
|
|
],
|
|
weldTolerance: .001, sourceVertexCount: 4, sourceTriangleCount: 2,
|
|
weldedNodeCount: 4, componentCount: 1, discardedNodeCount: 0,
|
|
};
|
|
|
|
describe("individual resurrection return navigation", () => {
|
|
it("finishes only when near the player on a clear traversable segment", () => {
|
|
expect(partyRejoinMovement("tank", [0, 0, 0], [2, 0, 0], 0, null, emptyPartyRouteState(),
|
|
{ directSegmentAllowed: () => true }).rejoined).toBe(true);
|
|
expect(partyRejoinMovement("tank", [0, 0, 0], [0, 5, 0], 0, null, emptyPartyRouteState(),
|
|
{ directSegmentAllowed: () => true }).rejoined).toBe(false);
|
|
});
|
|
|
|
it("routes out of a room even when the player is close on the other side of a wall", () => {
|
|
const result = partyRejoinMovement("tank", [0, 0, 0], [2, 0, 0], 0, graph, emptyPartyRouteState(), {
|
|
directSegmentAllowed: (start, end) => start[0] === end[0] || (start[2] >= 5 && end[2] >= 5),
|
|
routeSegmentAllowed: () => true,
|
|
});
|
|
expect(result.rejoined).toBe(false);
|
|
expect(result.blocked).toBe(false);
|
|
expect(result.waypoint).toEqual([0, 0, 6]);
|
|
});
|
|
|
|
it("follows the current player position, not a fixed death location or boss", () => {
|
|
const result = partyRejoinMovement("tank", [0, 0, 0], [20, 0, 0], 0, null, emptyPartyRouteState(), {
|
|
directSegmentAllowed: () => true,
|
|
});
|
|
const moved = partyRejoinMovement("tank", [4, 0, 0], [20, 0, 8], 50, null, result.route, {
|
|
directSegmentAllowed: () => true,
|
|
});
|
|
expect(moved.waypoint).toEqual([20, 0, 8]);
|
|
expect(moved.rejoined).toBe(false);
|
|
});
|
|
|
|
it("reports blocked navigation to the existing watchdog instead of walking through walls", () => {
|
|
const result = partyRejoinMovement("tank", [0, 0, 0], [20, 0, 0], 0, null, emptyPartyRouteState(), {
|
|
directSegmentAllowed: () => false,
|
|
});
|
|
expect(result.blocked).toBe(true);
|
|
expect(result.waypoint).toBeNull();
|
|
expect(result.rejoined).toBe(false);
|
|
});
|
|
});
|