fix: pass rawMana to activate() in DisciplinesTab to allow discipline reactivation after stop
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m18s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m18s
This commit is contained in:
@@ -85,15 +85,16 @@ export const DisciplinesTab: React.FC = () => {
|
||||
const [activeAttunement, setActiveAttunement] = useState<string>('base');
|
||||
|
||||
const elements = useManaStore((s) => s.elements);
|
||||
const rawMana = useManaStore((s) => s.rawMana);
|
||||
const signedPacts = usePrestigeStore((s) => s.signedPacts);
|
||||
|
||||
const handleToggle = useCallback((id: string, paused: boolean) => {
|
||||
if (paused) {
|
||||
activate(id, { elements, signedPacts });
|
||||
activate(id, { elements, rawMana, signedPacts });
|
||||
} else {
|
||||
deactivate(id);
|
||||
}
|
||||
}, [activate, deactivate, elements, signedPacts]);
|
||||
}, [activate, deactivate, elements, rawMana, signedPacts]);
|
||||
|
||||
const activeTab = ATTUNEMENT_TABS.find((t) => t.key === activeAttunement);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ function resetDisciplineStore() {
|
||||
describe('DisciplineStore — reactivate after deactivate (bug #163)', () => {
|
||||
beforeEach(resetDisciplineStore);
|
||||
|
||||
it('BUG: should reactivate a raw discipline after deactivate (requires rawMana in gameState)', () => {
|
||||
it('should reactivate a raw discipline after deactivate when rawMana is sufficient', () => {
|
||||
// First activation succeeds because disciplineState is undefined (optimistic)
|
||||
useDisciplineStore.getState().activate('raw-mastery');
|
||||
expect(useDisciplineStore.getState().activeIds).toContain('raw-mastery');
|
||||
@@ -25,16 +25,29 @@ describe('DisciplineStore — reactivate after deactivate (bug #163)', () => {
|
||||
expect(useDisciplineStore.getState().activeIds).not.toContain('raw-mastery');
|
||||
expect(useDisciplineStore.getState().disciplines['raw-mastery'].paused).toBe(true);
|
||||
|
||||
// Reactivate WITHOUT rawMana — reproduces the bug (silently fails)
|
||||
useDisciplineStore.getState().activate('raw-mastery', { elements: {}, signedPacts: [] });
|
||||
expect(useDisciplineStore.getState().activeIds).not.toContain('raw-mastery'); // BUG: still inactive
|
||||
|
||||
// Reactivate WITH rawMana — the fix
|
||||
// Reactivate WITH sufficient rawMana — should succeed
|
||||
useDisciplineStore.getState().activate('raw-mastery', { rawMana: 1000, elements: {}, signedPacts: [] });
|
||||
expect(useDisciplineStore.getState().activeIds).toContain('raw-mastery');
|
||||
expect(useDisciplineStore.getState().disciplines['raw-mastery'].paused).toBe(false);
|
||||
});
|
||||
|
||||
it('should NOT reactivate a raw discipline when rawMana is insufficient', () => {
|
||||
// Activate and build up XP
|
||||
useDisciplineStore.getState().activate('raw-mastery');
|
||||
useDisciplineStore.getState().processTick({ rawMana: 1000, elements: {} });
|
||||
useDisciplineStore.getState().processTick({ rawMana: 1000, elements: {} });
|
||||
const xp = useDisciplineStore.getState().disciplines['raw-mastery'].xp;
|
||||
expect(xp).toBeGreaterThan(0);
|
||||
|
||||
// Deactivate
|
||||
useDisciplineStore.getState().deactivate('raw-mastery');
|
||||
expect(useDisciplineStore.getState().activeIds).not.toContain('raw-mastery');
|
||||
|
||||
// Reactivate with insufficient rawMana (0) — should fail
|
||||
useDisciplineStore.getState().activate('raw-mastery', { rawMana: 0, elements: {}, signedPacts: [] });
|
||||
expect(useDisciplineStore.getState().activeIds).not.toContain('raw-mastery');
|
||||
});
|
||||
|
||||
it('should reactivate a discipline with elements after deactivating it', () => {
|
||||
useDisciplineStore.getState().activate('attune-fire', {
|
||||
elements: { fire: { unlocked: true, current: 100, max: 100, baseMax: 100 } },
|
||||
|
||||
@@ -48,7 +48,7 @@ export interface DisciplineStoreState {
|
||||
}
|
||||
|
||||
export interface DisciplineStoreActions {
|
||||
activate: (id: string, gameState?: { elements?: Record<string, ElementState>; signedPacts?: number[] }) => void;
|
||||
activate: (id: string, gameState?: { elements?: Record<string, ElementState>; rawMana?: number; signedPacts?: number[] }) => void;
|
||||
deactivate: (id: string) => void;
|
||||
processTick: (mana: { rawMana: number; elements: Record<string, ElementState> }) => {
|
||||
rawMana: number;
|
||||
|
||||
Reference in New Issue
Block a user