fix(game-api): 시나리오 아이템 표시 순서 통일
JSONB에 저장된 품목과 수량을 유지하며 원본 시나리오 순서로 구매·명장일람·유산·전투 시뮬레이터 선택지를 구성한다.
This commit is contained in:
1 parent
908ae72cba
commit
f5264352f9
10 files changed
+222
-44
No files matched your search
@@ -3,6 +3,10 @@ import { z } from 'zod';
|
||||
|
||||
import { asRecord } from '@sammo-ts/common';
|
||||
import { getDexLevel } from '@sammo-ts/logic';
|
||||
import {
|
||||
resolveLegacyCompatibleUniqueConfig,
|
||||
resolveLegacyPurchasableItemKeys,
|
||||
} from '@sammo-ts/logic/rewards/legacyUniqueItemPool.js';
|
||||
|
||||
import {
|
||||
accessAuthedInputProcedure,
|
||||
@@ -25,6 +29,7 @@ import {
|
||||
loadBattleSimTraitOptions,
|
||||
} from '../../battleSim/simulatorOptions.js';
|
||||
import { getMyGeneral } from '../shared/general.js';
|
||||
import { loadScenarioItemOrder } from '../../services/scenarioItemOrder.js';
|
||||
|
||||
const readNumber = (value: unknown, fallback = 0): number => {
|
||||
if (typeof value === 'number' && Number.isFinite(value)) {
|
||||
@@ -98,7 +103,17 @@ export const battleRouter = router({
|
||||
}
|
||||
|
||||
const environment = await buildBattleSimEnvironment(worldState, ctx.profile.id);
|
||||
const [traits, items] = await Promise.all([loadBattleSimTraitOptions(), loadBattleSimItemOptions()]);
|
||||
const configConst = asRecord(asRecord(worldState.config).const);
|
||||
const [traits, itemOrder, uniqueConfig] = await Promise.all([
|
||||
loadBattleSimTraitOptions(),
|
||||
loadScenarioItemOrder(worldState.scenarioCode),
|
||||
resolveLegacyCompatibleUniqueConfig(configConst),
|
||||
]);
|
||||
const allowedItems = new Set([
|
||||
...resolveLegacyPurchasableItemKeys(configConst),
|
||||
...Object.values(uniqueConfig.allItems).flatMap((entries) => Object.keys(entries ?? {})),
|
||||
]);
|
||||
const items = await loadBattleSimItemOptions(allowedItems, itemOrder);
|
||||
|
||||
return {
|
||||
world: {
|
||||
|
||||
Reference in new issue
Block a user