feat(game-ui): 사령턴 대상 지도를 인자 계약에 연결

도시·국가 선택 필드에서 지도 대상을 자동 판별하고 발령을 제외한 공개 사령턴 13종의 지도 선택과 보조 정보를 Chromium 회귀로 고정한다.
This commit is contained in:
2026-08-21 01:06:06 +00:00
parent 7b14585f0d
commit b0ab73e08b
5 changed files with 167 additions and 67 deletions
@@ -1,6 +1,10 @@
import type { CommandInputField } from './types';
export type CommandArgumentMapTarget = 'city' | 'nation' | 'capital';
export type CommandArgumentPresentation = {
lines: string[];
mapTarget?: 'city' | 'nation' | 'capital';
mapTarget?: CommandArgumentMapTarget;
};
const cityTarget = (lines: string[]): CommandArgumentPresentation => ({ lines, mapTarget: 'city' });
@@ -98,4 +102,18 @@ const PRESENTATIONS: Record<string, CommandArgumentPresentation> = {
export const commandArgumentPresentation = (commandKey: string): CommandArgumentPresentation =>
PRESENTATIONS[commandKey] ?? { lines: [] };
/**
* 대상 지도는 명령명 목록이 아니라 API가 내린 실제 인자 계약을 우선한다.
* 인자가 없는 증축·감축의 수도 확인 지도만 presentation의 명시적 target을 사용한다.
*/
export const resolveCommandArgumentMapTarget = (
commandKey: string,
fields: readonly CommandInputField[]
): CommandArgumentMapTarget | undefined => {
const selectableTargets = fields.filter((field) => field.kind === 'select');
if (selectableTargets.some((field) => field.optionSource === 'cities')) return 'city';
if (selectableTargets.some((field) => field.optionSource === 'nations')) return 'nation';
return commandArgumentPresentation(commandKey).mapTarget;
};
export const presentedCommandKeys = (): string[] => Object.keys(PRESENTATIONS);