refactor(logic): replace arbitrary action hooks with typed events
This commit is contained in:
@@ -211,7 +211,7 @@ const projectReferenceLogs = (trace: ReferenceMonthlyTrace) => [
|
||||
})),
|
||||
];
|
||||
|
||||
const buildCoreWorld = async (generalActionModules: GeneralActionModule[]): Promise<InMemoryTurnWorld> => {
|
||||
const buildCoreWorld = async (generalActionModules: ReadonlyArray<GeneralActionModule>): Promise<InMemoryTurnWorld> => {
|
||||
const state: TurnWorldState = {
|
||||
id: 1,
|
||||
currentYear: 193,
|
||||
|
||||
@@ -462,10 +462,7 @@ const generalActiveActionInheritanceCases: GeneralActiveActionInheritanceCase[]
|
||||
},
|
||||
];
|
||||
|
||||
const readActiveActionPoints = (
|
||||
snapshot: { generals: Array<Record<string, unknown>> },
|
||||
generalId: number
|
||||
): number => {
|
||||
const readActiveActionPoints = (snapshot: { generals: Array<Record<string, unknown>> }, generalId: number): number => {
|
||||
const general = snapshot.generals.find((entry) => entry.id === generalId);
|
||||
const value = general?.inheritActiveActionPoints;
|
||||
return typeof value === 'number' && Number.isFinite(value) ? value : 0;
|
||||
@@ -1691,6 +1688,13 @@ const militaryPreparationBoundaryCases: MilitaryPreparationBoundaryCase[] = [
|
||||
actorPatch: { itemWeapon: 'che_무기_11_고정도' },
|
||||
completed: true,
|
||||
},
|
||||
{
|
||||
name: 'equipment trade applies the dogi sale side effect before removing it',
|
||||
action: 'che_장비매매',
|
||||
args: { itemType: 'item', itemCode: 'None' },
|
||||
actorPatch: { itemExtra: 'che_보물_도기' },
|
||||
completed: true,
|
||||
},
|
||||
{
|
||||
name: 'disband rejects zero crew',
|
||||
action: 'che_소집해제',
|
||||
@@ -3524,7 +3528,12 @@ integration('general special reset constraint, state, unique lottery, and log pa
|
||||
referenceActor?.itemBook,
|
||||
referenceActor?.itemExtra,
|
||||
];
|
||||
const coreItems = [coreActor?.itemHorse, coreActor?.itemWeapon, coreActor?.itemBook, coreActor?.itemExtra];
|
||||
const coreItems = [
|
||||
coreActor?.itemHorse,
|
||||
coreActor?.itemWeapon,
|
||||
coreActor?.itemBook,
|
||||
coreActor?.itemExtra,
|
||||
];
|
||||
expect(referenceItems.some((item) => item && item !== 'None')).toBe(true);
|
||||
expect(coreItems).toEqual(referenceItems);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user