feat: Refactor General and Nation Turn Command types and importers for improved structure and consistency
This commit is contained in:
@@ -20,62 +20,6 @@ import type * as VolunteerRecruitModule from './che_의병모집.js';
|
|||||||
import type * as RecruitModule from './che_징병.js';
|
import type * as RecruitModule from './che_징병.js';
|
||||||
import type * as RestModule from './휴식.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 =
|
export type GeneralTurnCommandModule =
|
||||||
| typeof UprisingModule
|
| typeof UprisingModule
|
||||||
| typeof AppointmentModule
|
| typeof AppointmentModule
|
||||||
@@ -99,10 +43,7 @@ export type GeneralTurnCommandModule =
|
|||||||
|
|
||||||
export type GeneralTurnCommandImporter = () => Promise<GeneralTurnCommandModule>;
|
export type GeneralTurnCommandImporter = () => Promise<GeneralTurnCommandModule>;
|
||||||
|
|
||||||
const defaultImporters: Record<
|
const defaultImporters = {
|
||||||
GeneralTurnCommandKey,
|
|
||||||
GeneralTurnCommandImporter
|
|
||||||
> = {
|
|
||||||
che_거병: async () => import('./che_거병.js'),
|
che_거병: async () => import('./che_거병.js'),
|
||||||
che_임관: async () => import('./che_임관.js'),
|
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'),
|
||||||
che_징병: async () => import('./che_징병.js'),
|
che_징병: async () => import('./che_징병.js'),
|
||||||
휴식: async () => import('./휴식.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 {
|
export class GeneralTurnCommandLoader {
|
||||||
constructor(
|
constructor(
|
||||||
@@ -130,7 +91,7 @@ export class GeneralTurnCommandLoader {
|
|||||||
GeneralTurnCommandKey,
|
GeneralTurnCommandKey,
|
||||||
GeneralTurnCommandImporter
|
GeneralTurnCommandImporter
|
||||||
> = defaultImporters
|
> = defaultImporters
|
||||||
) {}
|
) { }
|
||||||
|
|
||||||
async load(
|
async load(
|
||||||
key: GeneralTurnCommandKey
|
key: GeneralTurnCommandKey
|
||||||
|
|||||||
@@ -5,18 +5,26 @@ import type * as AwardModule from './che_포상.js';
|
|||||||
import type * as AssignmentModule from './che_발령.js';
|
import type * as AssignmentModule from './che_발령.js';
|
||||||
import type * as DeclarationModule from './che_선전포고.js';
|
import type * as DeclarationModule from './che_선전포고.js';
|
||||||
|
|
||||||
export type NationTurnCommandKey =
|
|
||||||
| '휴식'
|
|
||||||
| 'che_포상'
|
|
||||||
| 'che_발령'
|
|
||||||
| 'che_선전포고';
|
|
||||||
|
|
||||||
export const NATION_TURN_COMMAND_KEYS: NationTurnCommandKey[] = [
|
|
||||||
'휴식',
|
export type NationTurnCommandModule =
|
||||||
'che_포상',
|
| typeof NationRestModule
|
||||||
'che_발령',
|
| typeof AwardModule
|
||||||
'che_선전포고',
|
| 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 = (
|
export const isNationTurnCommandKey = (
|
||||||
value: string
|
value: string
|
||||||
@@ -31,23 +39,6 @@ export interface NationTurnCommandSpec {
|
|||||||
createDefinition(env: TurnCommandEnv): GeneralActionDefinition;
|
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 {
|
export class NationTurnCommandLoader {
|
||||||
constructor(
|
constructor(
|
||||||
@@ -55,7 +46,7 @@ export class NationTurnCommandLoader {
|
|||||||
NationTurnCommandKey,
|
NationTurnCommandKey,
|
||||||
NationTurnCommandImporter
|
NationTurnCommandImporter
|
||||||
> = defaultImporters
|
> = defaultImporters
|
||||||
) {}
|
) { }
|
||||||
|
|
||||||
async load(
|
async load(
|
||||||
key: NationTurnCommandKey
|
key: NationTurnCommandKey
|
||||||
|
|||||||
Reference in New Issue
Block a user