CHE 아이템 상태 동결로 인한 턴 정지 수정
This commit is contained in:
@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest';
|
||||
|
||||
import type { General } from '../src/domain/entities.js';
|
||||
import {
|
||||
cloneItemInventory,
|
||||
consumeEquippedItemCharge,
|
||||
createItemInventoryFromSlots,
|
||||
equipNewItem,
|
||||
@@ -110,4 +111,23 @@ describe('GeneralItemInventory', () => {
|
||||
|
||||
expect(getEquippedItemInstance({ ...general, itemInventory: parsed }, 'item')?.state.charges).toBe(-1);
|
||||
});
|
||||
|
||||
it('clones an Immer-frozen inventory into mutable next-turn state', () => {
|
||||
const general = makeGeneral();
|
||||
equipNewItem(general, 'item', 'che_치료_환약', { charges: 3 });
|
||||
const inventory = general.itemInventory!;
|
||||
const instance = getEquippedItemInstance(general, 'item')!;
|
||||
Object.freeze(instance.state);
|
||||
Object.freeze(instance);
|
||||
Object.freeze(inventory.instances);
|
||||
Object.freeze(inventory.equipped);
|
||||
Object.freeze(inventory);
|
||||
|
||||
const cloned = cloneItemInventory(inventory);
|
||||
const nextGeneral = { ...general, itemInventory: cloned };
|
||||
|
||||
expect(consumeEquippedItemCharge(nextGeneral, 'item', 'che_치료_환약')).toBe(false);
|
||||
expect(getEquippedItemInstance(nextGeneral, 'item')?.state.charges).toBe(2);
|
||||
expect(instance.state.charges).toBe(3);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user