fix: 선택 불가 국가 성향을 입력 목록에서 제외
Ref의 availableNationType 13개를 공용 목록으로 정의하고 건국, NPC/AI 건국, 전투 시뮬레이터 입력과 검증에 적용한다.
This commit is contained in:
@@ -19,6 +19,17 @@ export const NATION_TRAIT_KEYS = [
|
||||
|
||||
export type NationTraitKey = (typeof NATION_TRAIT_KEYS)[number];
|
||||
|
||||
// Ref GameConst::$availableNationType excludes the neutral storage/default trait.
|
||||
// Founding, NPC founding, and the battle simulator must only expose this list.
|
||||
export type AvailableNationTraitKey = Exclude<NationTraitKey, 'che_중립'>;
|
||||
|
||||
export const AVAILABLE_NATION_TRAIT_KEYS: readonly AvailableNationTraitKey[] = NATION_TRAIT_KEYS.filter(
|
||||
(key): key is Exclude<NationTraitKey, 'che_중립'> => key !== 'che_중립'
|
||||
);
|
||||
|
||||
export const isAvailableNationTraitKey = (value: string): value is AvailableNationTraitKey =>
|
||||
AVAILABLE_NATION_TRAIT_KEYS.includes(value as AvailableNationTraitKey);
|
||||
|
||||
export type NationTraitModule = TraitModule;
|
||||
|
||||
export type NationTraitImporter = () => Promise<TraitModuleExport>;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { NATION_TRAIT_KEYS } from '@sammo-ts/logic/actionModules/traits/nation/index.js';
|
||||
import { isAvailableNationTraitKey } from '@sammo-ts/logic/actionModules/traits/nation/index.js';
|
||||
import { getLegacyStringWidth } from '@sammo-ts/logic/troop/management.js';
|
||||
import { z } from 'zod';
|
||||
|
||||
@@ -38,14 +38,12 @@ export const NATION_COLORS = [
|
||||
'#A9A9A9',
|
||||
] as const;
|
||||
|
||||
const SELECTABLE_NATION_TYPES = new Set<string>(NATION_TRAIT_KEYS.filter((key) => key !== 'che_중립'));
|
||||
|
||||
export const FOUNDING_ARGS_SCHEMA = z.object({
|
||||
nationName: z
|
||||
.string()
|
||||
.min(1)
|
||||
.refine((value) => getLegacyStringWidth(value) <= 18),
|
||||
nationType: z.string().refine((value) => SELECTABLE_NATION_TYPES.has(value)),
|
||||
nationType: z.string().refine(isAvailableNationTraitKey),
|
||||
colorType: z
|
||||
.number()
|
||||
.int()
|
||||
|
||||
Reference in New Issue
Block a user