chore: golemancy redesign cleanup — remove orphaned legacy code and update docs
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m19s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m19s
This commit is contained in:
@@ -190,6 +190,13 @@ export const useGameStore = create<GameCoordinatorStore>()(
|
||||
if (!elements[elem].unlocked) elements[elem] = { ...elements[elem], unlocked: true };
|
||||
elements[elem] = { ...elements[elem], current: Math.min(elements[elem].max, elements[elem].current + entry.finalRate * HOURS_PER_TICK) };
|
||||
}
|
||||
// Compute per-element net regen: produced rate - drain from being used as component
|
||||
const elementRegen: Record<string, number> = {};
|
||||
for (const [elem, entry] of Object.entries(conversionResult.rates)) {
|
||||
const produced = entry.finalRate;
|
||||
const drained = conversionResult.elementDrain[elem] || 0;
|
||||
elementRegen[elem] = produced - drained;
|
||||
}
|
||||
// Net raw regen = gross regen - conversion drains - incursion
|
||||
const netRawRegen = Math.max(0, baseRegen * (1 - incursionStrength) * meditationMultiplier - conversionResult.totalRawDrain);
|
||||
const actualRegen = Math.floor(Math.min(netRawRegen * HOURS_PER_TICK, maxMana - rawMana) * 1000) / 1000;
|
||||
@@ -305,7 +312,7 @@ export const useGameStore = create<GameCoordinatorStore>()(
|
||||
|
||||
// Phase 3: Write
|
||||
writes.game = { day, hour, incursionStrength };
|
||||
writes.mana = { rawMana, meditateTicks, totalManaGathered, elements };
|
||||
writes.mana = { rawMana, meditateTicks, totalManaGathered, elements, elementRegen };
|
||||
|
||||
applyTickWrites(writes, storeSetters);
|
||||
} catch (error: unknown) {
|
||||
|
||||
@@ -19,6 +19,8 @@ export interface ManaState {
|
||||
meditateTicks: number;
|
||||
totalManaGathered: number;
|
||||
elements: Record<string, ElementState>;
|
||||
/** Per-element net regen rates (from unified conversion system) */
|
||||
elementRegen: Record<string, number>;
|
||||
}
|
||||
|
||||
// ─── Mana Actions ────────────────────────────────────────────────────────────
|
||||
@@ -40,6 +42,7 @@ export interface ManaActions {
|
||||
spendElementMana: (element: string, amount: number) => Result<void>;
|
||||
setElementMax: (max: number) => void;
|
||||
computeElementMaxWithBonuses: (perElementBonuses: Record<string, number>) => void;
|
||||
setElementRegen: (regen: Record<string, number>) => void;
|
||||
|
||||
// Reset
|
||||
resetMana: (prestigeUpgrades: Record<string, number>) => void;
|
||||
@@ -66,6 +69,7 @@ export const useManaStore = create<ManaStore>()(
|
||||
}
|
||||
])
|
||||
) as Record<string, ElementState>,
|
||||
elementRegen: {},
|
||||
|
||||
setRawMana: (amount: number) => {
|
||||
set({ rawMana: Math.max(0, amount) });
|
||||
@@ -148,17 +152,21 @@ export const useManaStore = create<ManaStore>()(
|
||||
});
|
||||
},
|
||||
|
||||
setElementRegen: (regen: Record<string, number>) => {
|
||||
set({ elementRegen: regen });
|
||||
},
|
||||
|
||||
resetMana: (prestigeUpgrades: Record<string, number>) => {
|
||||
const elementMax = 10 + (prestigeUpgrades.elementalAttune || 0) * 25;
|
||||
const startingMana = 10 + (prestigeUpgrades.manaStart || 0) * 10;
|
||||
set({ rawMana: startingMana, meditateTicks: 0, totalManaGathered: 0, elements: makeInitialElements(elementMax, prestigeUpgrades) });
|
||||
set({ rawMana: startingMana, meditateTicks: 0, totalManaGathered: 0, elements: makeInitialElements(elementMax, prestigeUpgrades), elementRegen: {} });
|
||||
},
|
||||
}),
|
||||
{
|
||||
storage: createSafeStorage(),
|
||||
name: 'mana-loop-mana',
|
||||
version: 2,
|
||||
partialize: (state) => ({ rawMana: state.rawMana, meditateTicks: state.meditateTicks, totalManaGathered: state.totalManaGathered, elements: state.elements }),
|
||||
partialize: (state) => ({ rawMana: state.rawMana, meditateTicks: state.meditateTicks, totalManaGathered: state.totalManaGathered, elements: state.elements, elementRegen: state.elementRegen }),
|
||||
migrate: (persistedState: any, _version) => {
|
||||
if (persistedState && persistedState.elements) {
|
||||
for (const k of Object.keys(persistedState.elements)) {
|
||||
|
||||
Reference in New Issue
Block a user