Files
Mana-Loop/src/lib/game/stores/pipelines/golem-combat.ts
T
n8n-gitea a2cdf6d21c
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m19s
feat: implement golemancy combat system (spec §6, §9)
- Add ActiveGolem interface and activeGolems to GolemancyState
- Add maxRoomDuration to all 12 golem definitions
- Create golem-combat-actions.ts with pure golem combat logic (summoning, maintenance, attacks, room-duration)
- Create golem-combat.ts pipeline for golem combat setup
- Wire golem maintenance and attacks into processCombatTick
- Wire golem summoning into advanceRoomOrFloor on room entry
- Wire golem room-duration countdown into onFloorCleared callback
- Update combat-actions tests for new processCombatTick signature
- All 921 tests pass, all files under 400-line limit

Closes #259
2026-06-03 15:40:39 +02:00

51 lines
1.8 KiB
TypeScript

// ─── Golem Combat Pipeline ─────────────────────────────────────────────────────
// Extracts golem combat setup from gameStore.ts tick()
// to keep the coordinator under the 400-line file limit.
import { useCombatStore } from '../combatStore';
import { useManaStore } from '../manaStore';
import { processGolemRoomDuration } from '../golem-combat-actions';
import type { ActiveGolem } from '../../types';
export interface GolemCombatContext {
addLog: (msg: string) => void;
ctx: {
combat: {
currentFloor: number;
currentRoom: { roomType: string; unknown: Array<{ name: string }> };
};
prestige: { signedPacts: number[] };
};
rawMana: number;
elements: Record<string, { current: number; max: number; unlocked: boolean }>;
maxMana: number;
}
export interface GolemCombatResult {
rawMana: number;
elements: Record<string, { current: number; max: number; unlocked: boolean }>;
}
/**
* Build the golem combat pipeline for the current tick.
* Returns golem state needed by processCombatTick.
*/
export function buildGolemCombatPipeline(_addLog: (msg: string) => void): {
activeGolems: ActiveGolem[];
golemApplyDamageToRoom: (dmg: number) => { floorHP: number; floorMaxHP: number; roomCleared: boolean };
} {
const activeGolems = useCombatStore.getState().golemancy?.activeGolems ?? [];
const golemApplyDamageToRoom = (dmg: number) => {
const cs = useCombatStore.getState();
if (dmg > 0) {
const newFloorHP = Math.max(0, cs.floorHP - dmg);
useCombatStore.setState({ floorHP: newFloorHP });
}
const roomCleared = useCombatStore.getState().floorHP <= 0;
return { floorHP: cs.floorHP, floorMaxHP: cs.floorMaxHP, roomCleared };
};
return { activeGolems, golemApplyDamageToRoom };
}