CHE 아이템 상태 동결로 인한 턴 정지 수정
This commit is contained in:
@@ -28,6 +28,7 @@ import {
|
||||
addOccupiedUniqueItemKeys,
|
||||
buildGenericUniqueSeed,
|
||||
countOccupiedUniqueItems,
|
||||
cloneItemInventory,
|
||||
createItemModuleRegistry,
|
||||
loadItemModules,
|
||||
resolveUniqueConfig,
|
||||
@@ -317,6 +318,7 @@ const readConfigNumber = (config: ScenarioConfig, key: string, fallback: number)
|
||||
|
||||
const cloneTurnGeneral = (general: TurnGeneral): TurnGeneral => ({
|
||||
...general,
|
||||
...(general.itemInventory ? { itemInventory: cloneItemInventory(general.itemInventory) } : {}),
|
||||
...(general.inheritancePoints ? { inheritancePoints: { ...general.inheritancePoints } } : {}),
|
||||
stats: { ...general.stats },
|
||||
role: {
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { ConstantRNG, RandUtil } from '@sammo-ts/common';
|
||||
import { LogFormat } from '@sammo-ts/logic';
|
||||
import {
|
||||
LogFormat,
|
||||
equipNewItem,
|
||||
getEquippedItemInstance,
|
||||
loadActionModuleBundle,
|
||||
} from '@sammo-ts/logic';
|
||||
import type { TurnSchedule } from '@sammo-ts/logic/turn/calendar.js';
|
||||
import type { TurnGeneral, TurnWorldSnapshot, TurnWorldState } from '../src/turn/types.js';
|
||||
import { createTurnTestHarness } from './helpers/turnTestHarness.js';
|
||||
@@ -247,6 +252,29 @@ describe('legacy general-turn execution contract', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps multi-use item state mutable across consecutive general turns', async () => {
|
||||
const general = makeGeneral({ injury: 30 });
|
||||
equipNewItem(general, 'item', 'che_치료_환약', { charges: 3 });
|
||||
const actionModules = await loadActionModuleBundle();
|
||||
const commandEnv = buildCommandEnv(makeSnapshot(general).scenarioConfig);
|
||||
commandEnv.generalActionModules = actionModules.general;
|
||||
const harness = await createTurnTestHarness({
|
||||
snapshot: makeSnapshot(general),
|
||||
state: makeState(),
|
||||
schedule,
|
||||
map,
|
||||
commandEnv,
|
||||
});
|
||||
|
||||
await harness.runOneTick();
|
||||
expect(getEquippedItemInstance(harness.world.getGeneralById(1)!, 'item')?.state.charges).toBe(2);
|
||||
|
||||
harness.world.updateGeneral(1, { injury: 30 });
|
||||
await harness.runOneTick();
|
||||
|
||||
expect(getEquippedItemInstance(harness.world.getGeneralById(1)!, 'item')?.state.charges).toBe(1);
|
||||
});
|
||||
|
||||
it('fails closed instead of silently resting on an unknown queued command', async () => {
|
||||
const harness = await createTurnTestHarness({
|
||||
snapshot: makeSnapshot(makeGeneral()),
|
||||
|
||||
@@ -75,6 +75,7 @@ export type TurnTestHarnessOptions = {
|
||||
onActionResolved?: Parameters<typeof createReservedTurnHandler>[0]['onActionResolved'];
|
||||
onActionProfiled?: Parameters<typeof createReservedTurnHandler>[0]['onActionProfiled'];
|
||||
commandRngFactory?: Parameters<typeof createReservedTurnHandler>[0]['commandRngFactory'];
|
||||
commandEnv?: Parameters<typeof createReservedTurnHandler>[0]['commandEnv'];
|
||||
wrapGeneralTurnHandler?: (handler: GeneralTurnHandler) => GeneralTurnHandler;
|
||||
extraCalendarHandlers?: TurnCalendarHandler[];
|
||||
collectLogs?: boolean;
|
||||
@@ -115,6 +116,7 @@ export const createTurnTestHarness = async (options: TurnTestHarnessOptions) =>
|
||||
onActionResolved: options.onActionResolved,
|
||||
onActionProfiled: options.onActionProfiled,
|
||||
commandRngFactory: options.commandRngFactory,
|
||||
commandEnv: options.commandEnv,
|
||||
});
|
||||
|
||||
const generalTurnHandler = options.wrapGeneralTurnHandler ? options.wrapGeneralTurnHandler(handler) : handler;
|
||||
|
||||
Reference in New Issue
Block a user