fix: attunement system spec-vs-code discrepancies (issue #331)
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m24s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m24s
- Fix conversion rate level scaling from linear (1+level*0.5) to exponential (1.5^(level-1)) in conversion-rates.ts - Fix getAttunementLevelMultiplier formula to match spec §4.3 - Add level-up logging in attunementStore.ts via combat store addActivityLog - Clarify getAttunementConversionRate returns flat base rate (level scaling applied separately) - Update spec §8 to describe time-based puzzle room system matching code implementation - Add 17 regression tests verifying exponential scaling, base rate behavior, and spec table values
This commit is contained in:
@@ -5,7 +5,8 @@ import { create } from 'zustand';
|
||||
import { persist } from 'zustand/middleware';
|
||||
import { createSafeStorage } from '../utils/safe-persist';
|
||||
import type { AttunementState } from '../types';
|
||||
import { getAttunementXPForLevel, MAX_ATTUNEMENT_LEVEL } from '../data/attunements';
|
||||
import { getAttunementXPForLevel, MAX_ATTUNEMENT_LEVEL, ATTUNEMENTS_DEF } from '../data/attunements';
|
||||
import { useCombatStore } from './combatStore';
|
||||
|
||||
export interface AttunementStoreState {
|
||||
attunements: Record<string, AttunementState>;
|
||||
@@ -48,6 +49,19 @@ export const useAttunementStore = create<AttunementStoreState>()(
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Log level-up (outside set to avoid nested state updates)
|
||||
if (newLevel > attState.level) {
|
||||
const def = ATTUNEMENTS_DEF[attunementId];
|
||||
const name = def?.name || attunementId;
|
||||
// Use setTimeout to log after state update completes
|
||||
setTimeout(() => {
|
||||
useCombatStore.getState().addActivityLog(
|
||||
'attunement',
|
||||
`${name} reached level ${newLevel}!`
|
||||
);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
return {
|
||||
attunements: {
|
||||
|
||||
Reference in New Issue
Block a user