턴 대상의 원본 이름과 누락값 표시를 분리해 검색 정확도 개선

This commit is contained in:
2026-09-14 14:24:59 +00:00
parent 8760eab1a9
commit 7522f5100e
11 changed files with 220 additions and 29 deletions
+2 -1
View File
@@ -365,7 +365,7 @@ export const getTurnCommandTable = async (ctx: GameApiContext, generalId: number
id: entry.id,
name: entry.name,
color: entry.color,
capitalName: entry.capitalCityId ? (cityById.get(entry.capitalCityId)?.name ?? '-') : '-',
capitalName: entry.capitalCityId ? cityById.get(entry.capitalCityId)?.name : undefined,
level: entry.level,
power: readGeneralMetaNumber(entry.meta, 'power') ?? 0,
generalCount: generalCountByNation.get(entry.id) ?? 0,
@@ -402,6 +402,7 @@ export const getTurnCommandTable = async (ctx: GameApiContext, generalId: number
cities: cities.map((entry) => ({
value: entry.id,
label: `${entry.name} (${nationById.get(entry.nationId)?.name ?? '무주'})`,
targetNames: { name: entry.name, nationName: nationById.get(entry.nationId)?.name ?? null },
})),
nations: nationTargetOptions.nations,
nationTargets: nationTargetOptions.nationTargets,
+8
View File
@@ -20,6 +20,14 @@ export type TurnCommandOptionValue = string | number;
export interface TurnCommandOption {
value: TurnCommandOptionValue;
label: string;
/** 원본 이름. 없는 소속/부대/수도는 null이며 대체 문구는 화면에서 표시한다. */
targetNames?: {
name: string;
nationName?: string | null;
cityName?: string | null;
troopName?: string | null;
capitalName?: string | null;
};
color?: string;
description?: string;
availableNow?: boolean;
+11 -12
View File
@@ -24,7 +24,7 @@ export interface NationTargetSource {
id: number;
name: string;
color: string;
capitalName: string;
capitalName?: string;
level: number;
power: number;
generalCount: number;
@@ -60,9 +60,6 @@ export const buildRefGeneralTargetOptions = (options: {
const toOption = (entry: GeneralTargetSource, action?: string): TurnCommandOption => {
const troopName = entry.troopId ? options.troopNames?.get(entry.troopId) : undefined;
const cityName = options.cityNames.get(entry.cityId) ?? '재야';
const troopLabel = entry.troopId
? `${troopName ?? `#${entry.troopId}`}${entry.troopId === entry.id ? ' (부대장)' : ''}`
: '부대 없음';
const isTroopMember = Boolean(entry.troopId && entry.troopId !== entry.id);
const isTroopExit = action === 'che_부대탈퇴지시';
const availableNow = isTroopExit ? isTroopMember && entry.id !== options.actorId : undefined;
@@ -77,18 +74,12 @@ export const buildRefGeneralTargetOptions = (options: {
entry.crew === undefined ? null : `병력 ${entry.crew.toLocaleString()}`,
entry.train === undefined ? null : `훈련 ${entry.train.toLocaleString()}`,
entry.atmos === undefined ? null : `사기 ${entry.atmos.toLocaleString()}`,
action === 'che_발령' || action === 'che_포상' || action === 'che_몰수'
? null
: entry.troopId
? `탑승 부대 ${troopLabel}`
: '탑승 부대 없음',
].filter((value): value is string => Boolean(value));
// 발령 후보는 Ref처럼 능력치와 병력 준비 상태를 함께 비교한다.
// 예약 요약에 쓰는 label은 그대로 두고, 같은 국가 후보의 상세 정보만 보강한다.
const assignmentDetails =
action === 'che_발령'
? [
entry.troopId ? `탑승 부대 ${troopLabel}` : '탑승 부대 없음',
[
entry.leadership === undefined ? null : `통솔 ${entry.leadership.toLocaleString()}`,
entry.strength === undefined ? null : `무력 ${entry.strength.toLocaleString()}`,
@@ -119,6 +110,12 @@ export const buildRefGeneralTargetOptions = (options: {
return {
value: entry.id,
label,
targetNames: {
name: entry.name,
nationName: options.nationNames.get(entry.nationId) ?? null,
cityName: options.cityNames.get(entry.cityId) ?? null,
troopName: troopName ?? null,
},
description: assignmentDetails ?? details.join(' · '),
...(availableNow === undefined ? {} : { availableNow }),
...(entry.gold === undefined ? {} : { gold: entry.gold }),
@@ -212,8 +209,9 @@ export const buildRefNationTargetOptions = (options: {
const baseOptions = options.nations.map<TurnCommandOption>((entry) => ({
value: entry.id,
label: entry.name,
targetNames: { name: entry.name, capitalName: entry.capitalName ?? null },
color: entry.color,
description: `수도 ${entry.capitalName} · 국력 ${entry.power.toLocaleString()} · 도시 ${entry.cityCount.toLocaleString()} · 장수 ${entry.generalCount.toLocaleString()}`,
description: `수도 ${entry.capitalName ?? '-'} · 국력 ${entry.power.toLocaleString()} · 도시 ${entry.cityCount.toLocaleString()} · 장수 ${entry.generalCount.toLocaleString()}`,
}));
const nationTargets: Record<string, TurnCommandOption[]> = {};
for (const action of NATION_TARGET_COMMANDS) {
@@ -225,9 +223,10 @@ export const buildRefNationTargetOptions = (options: {
return {
value: entry.id,
label: entry.name,
targetNames: { name: entry.name, capitalName: entry.capitalName ?? null },
color: entry.color,
availableNow: availability.available,
description: `${availability.reason} · ${relation}${term} · 수도 ${entry.capitalName} · 국력 ${entry.power.toLocaleString()} · 도시 ${entry.cityCount.toLocaleString()} · 장수 ${entry.generalCount.toLocaleString()}`,
description: `${availability.reason} · ${relation}${term} · 수도 ${entry.capitalName ?? '-'} · 국력 ${entry.power.toLocaleString()} · 도시 ${entry.cityCount.toLocaleString()} · 장수 ${entry.generalCount.toLocaleString()}`,
power: entry.power,
} as TurnCommandOption & { power: number };
})