- Added `actionContextBuilder` to multiple turn action files to utilize the default action context builder. - Implemented specific context builders for actions requiring additional context, such as war configurations, world summaries, and general statistics. - Created new `actionContext.ts` and `actionContextHelpers.ts` files to define interfaces and helper functions for managing action contexts. - Enhanced context handling for nation and general actions, ensuring proper data injection for turn execution.
20 lines
576 B
TypeScript
20 lines
576 B
TypeScript
import type {
|
|
ActionContextBase,
|
|
ActionContextBuilder,
|
|
ActionContextOptions,
|
|
ActionResolveContext,
|
|
} from '@sammo-ts/logic';
|
|
|
|
export type ActionContextBuilderMap = Map<string, ActionContextBuilder>;
|
|
|
|
// 커맨드 모듈에서 제공한 컨텍스트 빌더로 확장한다.
|
|
export const buildActionContext = (
|
|
key: string,
|
|
base: ActionContextBase,
|
|
options: ActionContextOptions,
|
|
builders?: ActionContextBuilderMap
|
|
): ActionResolveContext | null => {
|
|
const builder = builders?.get(key);
|
|
return builder ? builder(base, options) : base;
|
|
};
|