fix: resetGame button doesn't fully reset game state
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m18s

This commit is contained in:
2026-06-12 09:05:35 +02:00
parent 608d4c4ff7
commit 4b8cdb97d7
6 changed files with 376 additions and 14 deletions
+67
View File
@@ -0,0 +1,67 @@
// ─── Combat Reset Helper ───────────────────────────────────────────────────────
// Generates the full default combat store state for resetCombat().
// Keeps combatStore.ts under the 400-line limit.
import type { RuntimeActiveGolem } from '../types';
import { getFloorMaxHP } from '../utils';
import { generateSpireFloorState, getRoomsForFloor } from '../utils/spire-utils';
import { makeInitialSpells } from './combat-actions';
import type { CombatState } from './combat-state.types';
export function createDefaultCombatState(
startFloor: number,
spellsToKeep: string[] = [],
): Partial<CombatState> {
const startSpells = makeInitialSpells(spellsToKeep);
const seed = startFloor * 12345;
const rooms = getRoomsForFloor(startFloor, seed);
const startRoom = generateSpireFloorState(startFloor, 0, rooms, 0);
return {
currentFloor: startFloor,
floorHP: getFloorMaxHP(startFloor),
floorMaxHP: getFloorMaxHP(startFloor),
maxFloorReached: startFloor,
activeSpell: 'manaBolt',
currentAction: 'meditate',
castProgress: 0,
spireMode: false,
currentRoom: startRoom,
clearedFloors: {},
climbDirection: null,
isDescending: false,
startFloor,
exitFloor: startFloor,
currentRoomIndex: 0,
roomsPerFloor: rooms,
runId: 0,
descentPeak: null,
roomResetState: {},
clearedRooms: {},
isDescentComplete: false,
golemancy: {
golemDesigns: {},
golemLoadout: [],
activeGolems: [] as RuntimeActiveGolem[],
lastSummonFloor: 0,
},
equipmentSpellStates: [],
weaponCastProgress: {},
comboHitCount: 0,
floorHitCount: 0,
meleeSwordProgress: {},
guardianShield: 0,
guardianShieldMax: 0,
guardianBarrier: 0,
guardianBarrierMax: 0,
spells: startSpells,
activityLog: [],
achievements: {
unlocked: [],
progress: {},
},
totalSpellsCast: 0,
totalDamageDealt: 0,
totalCraftsCompleted: 0,
};
}