수정: 인사 명령에서 유저장을 먼저 정렬
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import type { CommandOption } from './types';
|
||||
|
||||
const npcStateOf = (option: CommandOption): number => option.npcState ?? 0;
|
||||
|
||||
/** 장수 선택지는 유저장부터 NPC 종류순으로 묶고, 명령별 우선순위는 같은 종류 안에서만 적용한다. */
|
||||
export const sortCommandGeneralOptions = (
|
||||
commandKey: string,
|
||||
options: readonly CommandOption[],
|
||||
isGold: boolean
|
||||
): CommandOption[] => {
|
||||
const resourceKey = isGold ? 'gold' : 'rice';
|
||||
return options
|
||||
.map((option, index) => ({ option, index }))
|
||||
.sort((left, right) => {
|
||||
const typeOrder = npcStateOf(left.option) - npcStateOf(right.option);
|
||||
if (typeOrder !== 0) return typeOrder;
|
||||
|
||||
if (commandKey === 'che_포상') {
|
||||
const resourceOrder = (left.option[resourceKey] ?? 0) - (right.option[resourceKey] ?? 0);
|
||||
if (resourceOrder !== 0) return resourceOrder;
|
||||
}
|
||||
if (commandKey === 'che_몰수') {
|
||||
const resourceOrder = (right.option[resourceKey] ?? 0) - (left.option[resourceKey] ?? 0);
|
||||
if (resourceOrder !== 0) return resourceOrder;
|
||||
}
|
||||
if (commandKey === 'che_부대탈퇴지시') {
|
||||
const availabilityOrder = Number(right.option.availableNow) - Number(left.option.availableNow);
|
||||
if (availabilityOrder !== 0) return availabilityOrder;
|
||||
}
|
||||
return left.index - right.index;
|
||||
})
|
||||
.map(({ option }) => option);
|
||||
};
|
||||
@@ -4,6 +4,7 @@ import MapViewer from './MapViewer.vue';
|
||||
import NationColorSelect from './NationColorSelect.vue';
|
||||
import { commandArgumentPresentation, resolveCommandArgumentMapTarget } from '../command/commandArgumentPresentation';
|
||||
import { commandCityOptions } from '../command/commandArgumentOptions';
|
||||
import { sortCommandGeneralOptions } from '../command/commandGeneralOptions';
|
||||
import {
|
||||
commandArgumentFieldContract,
|
||||
shouldPreserveCommandArgumentValue,
|
||||
@@ -44,18 +45,7 @@ const visibleFields = computed(() => props.fields.filter((entry) => entry.kind !
|
||||
const amountPreset = computed(() => props.options.amountPresets?.[props.commandKey]);
|
||||
|
||||
const sortGeneralOptions = (options: CommandOption[]): CommandOption[] => {
|
||||
const result = [...options];
|
||||
const resourceKey = values.isGold === false ? 'rice' : 'gold';
|
||||
if (props.commandKey === 'che_포상') {
|
||||
return result.sort((left, right) => (left[resourceKey] ?? 0) - (right[resourceKey] ?? 0));
|
||||
}
|
||||
if (props.commandKey === 'che_몰수') {
|
||||
return result.sort((left, right) => (right[resourceKey] ?? 0) - (left[resourceKey] ?? 0));
|
||||
}
|
||||
if (props.commandKey === 'che_부대탈퇴지시') {
|
||||
return result.sort((left, right) => Number(right.availableNow) - Number(left.availableNow));
|
||||
}
|
||||
return result;
|
||||
return sortCommandGeneralOptions(props.commandKey, options, values.isGold !== false);
|
||||
};
|
||||
|
||||
const optionsFor = (field: CommandInputField): CommandOption[] => {
|
||||
|
||||
Reference in New Issue
Block a user