- Introduce AGENTS.md to outline agent behavior, quality standards, and self-improvement guidelines. - Create AI-AGENTS.md for internal agent use, ensuring clarity in agent operations. - Add NPC_Personalities.md to define character traits, speech patterns, and writing guidelines for major NPCs, enhancing narrative consistency. - Update mission JSON files to include new narrative elements and unlock conditions for procedural missions. - Enhance GameLoop and MissionManager to support new mission features and procedural generation. - Implement tests for new functionalities to ensure integration and reliability within the game architecture.
112 lines
3.1 KiB
JavaScript
112 lines
3.1 KiB
JavaScript
import { expect } from "@esm-bundle/chai";
|
|
import * as THREE from "three";
|
|
import { GameLoop } from "../../../src/core/GameLoop.js";
|
|
import {
|
|
createGameLoopSetup,
|
|
cleanupGameLoop,
|
|
createRunData,
|
|
createMockGameStateManagerForCombat,
|
|
setupCombatUnits,
|
|
cleanupTurnSystem,
|
|
} from "./helpers.js";
|
|
|
|
describe("Core: GameLoop - Combat Movement Highlights", function () {
|
|
this.timeout(30000);
|
|
|
|
let gameLoop;
|
|
let container;
|
|
let mockGameStateManager;
|
|
let playerUnit;
|
|
let enemyUnit;
|
|
|
|
beforeEach(async () => {
|
|
const setup = createGameLoopSetup();
|
|
gameLoop = setup.gameLoop;
|
|
container = setup.container;
|
|
|
|
if (gameLoop.turnSystemAbortController) {
|
|
gameLoop.turnSystemAbortController.abort();
|
|
}
|
|
gameLoop.stop();
|
|
if (
|
|
gameLoop.turnSystem &&
|
|
typeof gameLoop.turnSystem.reset === "function"
|
|
) {
|
|
gameLoop.turnSystem.reset();
|
|
}
|
|
|
|
gameLoop.init(container);
|
|
mockGameStateManager = createMockGameStateManagerForCombat();
|
|
gameLoop.gameStateManager = mockGameStateManager;
|
|
|
|
const runData = createRunData({
|
|
squad: [{ id: "u1", classId: "CLASS_VANGUARD" }],
|
|
});
|
|
await gameLoop.startLevel(runData, { startAnimation: false });
|
|
|
|
gameLoop.updateCombatState = async () => Promise.resolve();
|
|
|
|
const units = setupCombatUnits(gameLoop);
|
|
playerUnit = units.playerUnit;
|
|
enemyUnit = units.enemyUnit;
|
|
});
|
|
|
|
afterEach(async () => {
|
|
// Clear highlights first to free Three.js resources
|
|
if (gameLoop.clearMovementHighlights) {
|
|
gameLoop.clearMovementHighlights();
|
|
}
|
|
if (gameLoop.clearSpawnZoneHighlights) {
|
|
gameLoop.clearSpawnZoneHighlights();
|
|
}
|
|
|
|
// Dispose of Three.js meshes manually if needed
|
|
if (gameLoop.movementHighlights) {
|
|
gameLoop.movementHighlights.forEach((mesh) => {
|
|
if (mesh.geometry) mesh.geometry.dispose();
|
|
if (mesh.material) {
|
|
if (Array.isArray(mesh.material)) {
|
|
mesh.material.forEach((mat) => mat.dispose());
|
|
} else {
|
|
mesh.material.dispose();
|
|
}
|
|
}
|
|
});
|
|
gameLoop.movementHighlights.clear();
|
|
}
|
|
|
|
cleanupTurnSystem(gameLoop);
|
|
cleanupGameLoop(gameLoop, container);
|
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
});
|
|
|
|
it("CoA 6: should not show movement highlights for enemy units", () => {
|
|
mockGameStateManager.getCombatState.returns({
|
|
activeUnit: {
|
|
id: enemyUnit.id,
|
|
name: enemyUnit.name,
|
|
},
|
|
turnQueue: [],
|
|
});
|
|
|
|
gameLoop.updateMovementHighlights(enemyUnit);
|
|
expect(gameLoop.movementHighlights.size).to.equal(0);
|
|
});
|
|
|
|
it("CoA 7: should clear movement highlights when not in combat", () => {
|
|
mockGameStateManager.getCombatState.returns({
|
|
activeUnit: {
|
|
id: playerUnit.id,
|
|
name: playerUnit.name,
|
|
},
|
|
turnQueue: [],
|
|
});
|
|
gameLoop.updateMovementHighlights(playerUnit);
|
|
expect(gameLoop.movementHighlights.size).to.be.greaterThan(0);
|
|
|
|
mockGameStateManager.currentState = "STATE_DEPLOYMENT";
|
|
gameLoop.updateMovementHighlights(playerUnit);
|
|
expect(gameLoop.movementHighlights.size).to.equal(0);
|
|
});
|
|
});
|
|
|