merge: 최신 main의 발령 작업을 대상 지도 브랜치에 통합
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import type { CommandMapData, CommandOption } from './types';
|
||||
|
||||
export const commandCityOptions = (
|
||||
commandKey: string,
|
||||
options: readonly CommandOption[],
|
||||
mapData?: CommandMapData | null
|
||||
): CommandOption[] => {
|
||||
if (commandKey !== 'che_발령' || typeof mapData?.myNation !== 'number') return [...options];
|
||||
|
||||
const nationByCityId = new Map(mapData.cityList.map(([cityId, , , nationId]) => [cityId, nationId]));
|
||||
return options
|
||||
.map((option, index) => ({ option, index }))
|
||||
.sort((left, right) => {
|
||||
const leftOwned =
|
||||
typeof left.option.value === 'number' && nationByCityId.get(left.option.value) === mapData.myNation;
|
||||
const rightOwned =
|
||||
typeof right.option.value === 'number' && nationByCityId.get(right.option.value) === mapData.myNation;
|
||||
return Number(rightOwned) - Number(leftOwned) || left.index - right.index;
|
||||
})
|
||||
.map(({ option }) => option);
|
||||
};
|
||||
@@ -2,6 +2,7 @@
|
||||
import { computed, reactive, watch, type CSSProperties } from 'vue';
|
||||
import MapViewer from './MapViewer.vue';
|
||||
import { commandArgumentPresentation, resolveCommandArgumentMapTarget } from '../command/commandArgumentPresentation';
|
||||
import { commandCityOptions } from '../command/commandArgumentOptions';
|
||||
import {
|
||||
commandArgumentFieldContract,
|
||||
shouldPreserveCommandArgumentValue,
|
||||
@@ -64,6 +65,9 @@ const optionsFor = (field: CommandInputField): CommandOption[] => {
|
||||
if (field.optionSource === 'nations') {
|
||||
return props.options.nationTargets?.[props.commandKey] ?? props.options.nations;
|
||||
}
|
||||
if (field.optionSource === 'cities') {
|
||||
return commandCityOptions(props.commandKey, props.options.cities, props.mapData);
|
||||
}
|
||||
if (field.optionSource === 'items') {
|
||||
return props.options.items[String(values.itemType ?? '')] ?? [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user