fix: deduct component consumption from element pools in mana conversion
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m20s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m20s
Bug #293: elementDrain was computed but never subtracted from element pools. The tick pipeline now applies net regen (produced - drained) instead of gross production to element pools, matching the spec §8 regen deduction model.
This commit is contained in:
@@ -184,12 +184,6 @@ export const useGameStore = create<GameCoordinatorStore>()(
|
||||
}
|
||||
}
|
||||
|
||||
// Apply produced element mana (from active conversions)
|
||||
for (const [elem, entry] of Object.entries(conversionResult.rates)) {
|
||||
if (entry.paused || entry.finalRate <= 0 || !elements[elem]) continue;
|
||||
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)) {
|
||||
@@ -197,6 +191,18 @@ export const useGameStore = create<GameCoordinatorStore>()(
|
||||
const drained = conversionResult.elementDrain[elem] || 0;
|
||||
elementRegen[elem] = produced - drained;
|
||||
}
|
||||
// Apply net element regen to pools: produced - drained (component consumption)
|
||||
for (const [elem, entry] of Object.entries(conversionResult.rates)) {
|
||||
if (entry.paused || !elements[elem]) continue;
|
||||
if (!elements[elem].unlocked) elements[elem] = { ...elements[elem], unlocked: true };
|
||||
const netRate = elementRegen[elem];
|
||||
if (netRate === 0) continue;
|
||||
const delta = netRate * HOURS_PER_TICK;
|
||||
const newCurrent = delta >= 0
|
||||
? Math.min(elements[elem].max, elements[elem].current + delta)
|
||||
: Math.max(0, elements[elem].current + delta);
|
||||
elements[elem] = { ...elements[elem], current: newCurrent };
|
||||
}
|
||||
// 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;
|
||||
|
||||
Reference in New Issue
Block a user