fix: break circular dependency between combat-descent and non-combat-room actions
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 1m2s

This commit is contained in:
2026-06-04 19:32:22 +02:00
parent ee24227d62
commit b54b10a899
5 changed files with 45 additions and 24 deletions
+16 -16
View File
@@ -7,10 +7,10 @@ import { useDisciplineStore } from './discipline-slice';
import { useManaStore } from './manaStore';
import { useAttunementStore } from './attunementStore';
import { PUZZLE_ROOMS } from '../constants';
import { advanceRoomOrFloor } from './combat-descent-actions';
type GetFn = () => CombatStore;
type SetFn = (state: Partial<CombatState>) => void;
type AdvanceFn = (get: GetFn, set: SetFn) => void;
// ─── Room Entry Handlers ──────────────────────────────────────────────────────
@@ -105,22 +105,22 @@ export function onEnterPuzzleRoom(get: GetFn, set: SetFn): void {
// ─── Tick Handlers ────────────────────────────────────────────────────────────
export function tickNonCombatRoom(get: GetFn, set: SetFn, hours: number): void {
export function tickNonCombatRoom(get: GetFn, set: SetFn, hours: number, advance: AdvanceFn): void {
const s = get();
const rt = s.currentRoom.roomType as string;
if (rt === 'library') {
tickLibraryRoom(get, set, hours);
tickLibraryRoom(get, set, hours, advance);
} else if (rt === 'recovery') {
tickRecoveryRoom(get, set, hours);
tickRecoveryRoom(get, set, hours, advance);
} else if (rt === 'treasure') {
tickTreasureRoom(get, set, hours);
tickTreasureRoom(get, set, hours, advance);
} else if (rt === 'puzzle') {
tickPuzzleRoom(get, set, hours);
tickPuzzleRoom(get, set, hours, advance);
}
}
function tickLibraryRoom(get: GetFn, set: SetFn, hours: number): void {
function tickLibraryRoom(get: GetFn, set: SetFn, hours: number, advance: AdvanceFn): void {
const s = get();
const room = s.currentRoom;
const progress = (room.libraryProgress || 0) + hours;
@@ -150,13 +150,13 @@ function tickLibraryRoom(get: GetFn, set: SetFn, hours: number): void {
if (progress >= required) {
set({ currentRoom: { ...room, libraryProgress: progress } });
advanceRoomOrFloor(get, set);
advance(get, set);
} else {
set({ currentRoom: { ...room, libraryProgress: progress } });
}
}
function tickRecoveryRoom(get: GetFn, set: SetFn, hours: number): void {
function tickRecoveryRoom(get: GetFn, set: SetFn, hours: number, advance: AdvanceFn): void {
const s = get();
const room = s.currentRoom;
const progress = (room.recoveryProgress || 0) + hours;
@@ -164,13 +164,13 @@ function tickRecoveryRoom(get: GetFn, set: SetFn, hours: number): void {
if (progress >= required) {
set({ currentRoom: { ...room, recoveryProgress: progress } });
advanceRoomOrFloor(get, set);
advance(get, set);
} else {
set({ currentRoom: { ...room, recoveryProgress: progress } });
}
}
function tickTreasureRoom(get: GetFn, set: SetFn, hours: number): void {
function tickTreasureRoom(get: GetFn, set: SetFn, hours: number, advance: AdvanceFn): void {
const s = get();
const room = s.currentRoom;
const progress = (room.treasureProgress || 0) + hours;
@@ -228,13 +228,13 @@ function tickTreasureRoom(get: GetFn, set: SetFn, hours: number): void {
if (progress >= required) {
set({ currentRoom: { ...room, treasureProgress: progress, treasureLootClaimed: Array.from(claimedSet) } });
advanceRoomOrFloor(get, set);
advance(get, set);
} else {
set({ currentRoom: { ...room, treasureProgress: progress, treasureLootClaimed: Array.from(claimedSet) } });
}
}
function tickPuzzleRoom(get: GetFn, set: SetFn, hours: number): void {
function tickPuzzleRoom(get: GetFn, set: SetFn, hours: number, advance: AdvanceFn): void {
const s = get();
const room = s.currentRoom;
const progress = (room.puzzleProgress || 0) + hours;
@@ -243,7 +243,7 @@ function tickPuzzleRoom(get: GetFn, set: SetFn, hours: number): void {
if (progress >= required) {
set({ currentRoom: { ...room, puzzleProgress: progress } });
get().addActivityLog('puzzle_solved', `Puzzle solved on Floor ${s.currentFloor}!`);
advanceRoomOrFloor(get, set);
advance(get, set);
} else {
set({ currentRoom: { ...room, puzzleProgress: progress } });
}
@@ -251,12 +251,12 @@ function tickPuzzleRoom(get: GetFn, set: SetFn, hours: number): void {
// ─── Player Actions ───────────────────────────────────────────────────────────
export function skipNonCombatRoom(get: GetFn, set: SetFn): void {
export function skipNonCombatRoom(get: GetFn, set: SetFn, advance: AdvanceFn): void {
const s = get();
const rt = s.currentRoom.roomType as string;
if (rt === 'library' || rt === 'recovery' || rt === 'treasure') {
get().addActivityLog('floor_transition', `Skipped ${rt} room on Floor ${s.currentFloor}`);
advanceRoomOrFloor(get, set);
advance(get, set);
}
}