feat: Refactor General and Nation Turn Command types and importers for improved structure and consistency

This commit is contained in:
2026-01-01 19:12:50 +00:00
parent bfbcb4472e
commit 6d421e81a0
2 changed files with 43 additions and 91 deletions
@@ -20,62 +20,6 @@ import type * as VolunteerRecruitModule from './che_의병모집.js';
import type * as RecruitModule from './che_징병.js';
import type * as RestModule from './휴식.js';
export type GeneralTurnCommandKey =
| 'che_거병'
| 'che_임관'
| 'che_건국'
| 'che_훈련'
| 'che_사기진작'
| 'che_요양'
| 'che_출병'
| 'che_주민선정'
| 'che_농지개간'
| 'che_상업투자'
| 'che_기술연구'
| 'che_치안강화'
| 'che_수비강화'
| 'che_성벽보수'
| 'che_화계'
| 'che_인재탐색'
| 'che_의병모집'
| 'che_징병'
| '휴식';
export const GENERAL_TURN_COMMAND_KEYS: GeneralTurnCommandKey[] = [
'che_거병',
'che_임관',
'che_건국',
'che_훈련',
'che_사기진작',
'che_요양',
'che_출병',
'che_주민선정',
'che_농지개간',
'che_상업투자',
'che_기술연구',
'che_치안강화',
'che_수비강화',
'che_성벽보수',
'che_화계',
'che_인재탐색',
'che_의병모집',
'che_징병',
'휴식',
];
export const isGeneralTurnCommandKey = (
value: string
): value is GeneralTurnCommandKey =>
(GENERAL_TURN_COMMAND_KEYS as string[]).includes(value);
export interface GeneralTurnCommandSpec {
key: GeneralTurnCommandKey;
category: string;
reqArg: boolean;
args: Record<string, unknown>;
createDefinition(env: TurnCommandEnv): GeneralActionDefinition;
}
export type GeneralTurnCommandModule =
| typeof UprisingModule
| typeof AppointmentModule
@@ -99,10 +43,7 @@ export type GeneralTurnCommandModule =
export type GeneralTurnCommandImporter = () => Promise<GeneralTurnCommandModule>;
const defaultImporters: Record<
GeneralTurnCommandKey,
GeneralTurnCommandImporter
> = {
const defaultImporters = {
che_거병: async () => import('./che_거병.js'),
che_임관: async () => import('./che_임관.js'),
che_건국: async () => import('./che_건국.js'),
@@ -122,7 +63,27 @@ const defaultImporters: Record<
che_의병모집: async () => import('./che_의병모집.js'),
che_징병: async () => import('./che_징병.js'),
휴식: async () => import('./휴식.js'),
};
} as const satisfies Record<string, GeneralTurnCommandImporter>;
export type GeneralTurnCommandKey = keyof typeof defaultImporters;
export const GENERAL_TURN_COMMAND_KEYS: readonly GeneralTurnCommandKey[] = [
...Object.keys(defaultImporters),
] as GeneralTurnCommandKey[];
export const isGeneralTurnCommandKey = (
value: string
): value is GeneralTurnCommandKey =>
(GENERAL_TURN_COMMAND_KEYS as string[]).includes(value);
export interface GeneralTurnCommandSpec {
key: GeneralTurnCommandKey;
category: string;
reqArg: boolean;
args: Record<string, unknown>;
createDefinition(env: TurnCommandEnv): GeneralActionDefinition;
}
export class GeneralTurnCommandLoader {
constructor(
@@ -130,7 +91,7 @@ export class GeneralTurnCommandLoader {
GeneralTurnCommandKey,
GeneralTurnCommandImporter
> = defaultImporters
) {}
) { }
async load(
key: GeneralTurnCommandKey
+20 -29
View File
@@ -5,18 +5,26 @@ import type * as AwardModule from './che_포상.js';
import type * as AssignmentModule from './che_발령.js';
import type * as DeclarationModule from './che_선전포고.js';
export type NationTurnCommandKey =
| '휴식'
| 'che_포상'
| 'che_발령'
| 'che_선전포고';
export const NATION_TURN_COMMAND_KEYS: NationTurnCommandKey[] = [
'휴식',
'che_포상',
'che_발령',
'che_선전포고',
];
export type NationTurnCommandModule =
| typeof NationRestModule
| typeof AwardModule
| typeof AssignmentModule
| typeof DeclarationModule;
export type NationTurnCommandImporter = () => Promise<NationTurnCommandModule>;
const defaultImporters = {
휴식: async () => import('./휴식.js'),
che_포상: async () => import('./che_포상.js'),
che_발령: async () => import('./che_발령.js'),
che_선전포고: async () => import('./che_선전포고.js'),
} as const satisfies Record<string, NationTurnCommandImporter>;
export type NationTurnCommandKey = keyof typeof defaultImporters;
export const NATION_TURN_COMMAND_KEYS: readonly NationTurnCommandKey[] = [...Object.keys(defaultImporters)] as NationTurnCommandKey[];
export const isNationTurnCommandKey = (
value: string
@@ -31,23 +39,6 @@ export interface NationTurnCommandSpec {
createDefinition(env: TurnCommandEnv): GeneralActionDefinition;
}
export type NationTurnCommandModule =
| typeof NationRestModule
| typeof AwardModule
| typeof AssignmentModule
| typeof DeclarationModule;
export type NationTurnCommandImporter = () => Promise<NationTurnCommandModule>;
const defaultImporters: Record<
NationTurnCommandKey,
NationTurnCommandImporter
> = {
휴식: async () => import('./휴식.js'),
che_포상: async () => import('./che_포상.js'),
che_발령: async () => import('./che_발령.js'),
che_선전포고: async () => import('./che_선전포고.js'),
};
export class NationTurnCommandLoader {
constructor(
@@ -55,7 +46,7 @@ export class NationTurnCommandLoader {
NationTurnCommandKey,
NationTurnCommandImporter
> = defaultImporters
) {}
) { }
async load(
key: NationTurnCommandKey