feat: Implement attunement mana conversion
Some checks failed
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 1m26s

- Add auto-conversion of raw mana to primary mana types in tick
- Each attunement converts raw mana at its defined rate
- Conversion scales with attunement level (+10% per level)
- Update state in tick to track primaryMana changes
This commit is contained in:
2026-03-27 16:01:52 +00:00
parent d459276dcc
commit 75026fcb0b

View File

@@ -467,6 +467,35 @@ export const useGameStore = create<GameStore>()(
// Increment total ticks early (needed for study tracking) // Increment total ticks early (needed for study tracking)
const newTotalTicks = state.totalTicks + 1; const newTotalTicks = state.totalTicks + 1;
// ─── Attunement Mana Conversion ───
// Auto-convert raw mana to primary mana types based on unlocked attunements
let primaryMana = { ...state.primaryMana };
const attunements = state.attunements;
for (const [attunementType, attunementState] of Object.entries(attunements)) {
if (!attunementState.unlocked) continue;
const def = ATTUNEMENTS[attunementType as AttunementType];
if (!def || !def.primaryManaType) continue; // Skip Invoker (no primary)
const manaType = def.primaryManaType;
const currentPrimary = primaryMana[manaType] || 0;
const maxPrimary = state.primaryManaMax[manaType] || 50;
if (currentPrimary >= maxPrimary) continue; // Already at max
// Calculate conversion: autoConvertRate per hour, scaled by level
const conversionRate = def.autoConvertRate * (1 + attunementState.level * 0.1);
const conversionAmount = conversionRate * HOURS_PER_TICK;
// Convert from raw mana (costs 1 raw per 1 primary)
if (rawMana >= conversionAmount) {
const actualConvert = Math.min(conversionAmount, maxPrimary - currentPrimary);
rawMana -= actualConvert;
primaryMana[manaType] = Math.min(currentPrimary + actualConvert, maxPrimary);
}
}
// Study progress // Study progress
let currentStudyTarget = state.currentStudyTarget; let currentStudyTarget = state.currentStudyTarget;
let skills = state.skills; let skills = state.skills;
@@ -937,6 +966,7 @@ export const useGameStore = create<GameStore>()(
achievements, achievements,
totalDamageDealt, totalDamageDealt,
totalSpellsCast, totalSpellsCast,
primaryMana,
}); });
return; return;
} }
@@ -970,6 +1000,7 @@ export const useGameStore = create<GameStore>()(
consecutiveStudyHours, consecutiveStudyHours,
studyStartedAt, studyStartedAt,
lastStudyCost, lastStudyCost,
primaryMana,
...craftingUpdates, ...craftingUpdates,
}); });
}, },