fix: 유산 유니크 경매 기본 풀과 제한을 복구
Ref 기본 유니크 풀을 상태 조회·개설·마감에서 공유하고 API와 데몬 양쪽에서 입찰 부위 제한을 재검증한다. 실제 Chromium 및 개설·경쟁 입찰·마감 통합 회귀를 추가한다.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { createItemModuleRegistry, ItemLoader, ITEM_KEYS, loadItemModules } from '@sammo-ts/logic/items/index.js';
|
||||
import type { ItemModule } from '@sammo-ts/logic/items/types.js';
|
||||
import type { UniqueItemPool } from './uniqueLottery.js';
|
||||
import { resolveUniqueConfig, type UniqueItemPool, type UniqueLotteryConfig } from './uniqueLottery.js';
|
||||
|
||||
const LEGACY_UNIQUE_ITEM_KEYS: Readonly<Record<ItemModule['slot'], readonly string[]>> = {
|
||||
horse: [
|
||||
@@ -125,3 +126,38 @@ export const buildLegacyDefaultUniqueItemPool = (itemRegistry: Map<string, ItemM
|
||||
}
|
||||
return pool;
|
||||
};
|
||||
|
||||
let legacyDefaultUniqueItemPoolPromise: Promise<UniqueItemPool> | null = null;
|
||||
|
||||
const cloneUniqueItemPool = (pool: UniqueItemPool): UniqueItemPool =>
|
||||
Object.fromEntries(Object.entries(pool).map(([slot, entries]) => [slot, { ...entries }]));
|
||||
|
||||
export const loadLegacyDefaultUniqueItemPool = async (loader?: ItemLoader): Promise<UniqueItemPool> => {
|
||||
if (loader) {
|
||||
const modules = await loadItemModules([...ITEM_KEYS], loader);
|
||||
return buildLegacyDefaultUniqueItemPool(createItemModuleRegistry(modules));
|
||||
}
|
||||
|
||||
legacyDefaultUniqueItemPoolPromise ??= loadItemModules([...ITEM_KEYS], new ItemLoader()).then((modules) =>
|
||||
buildLegacyDefaultUniqueItemPool(createItemModuleRegistry(modules))
|
||||
);
|
||||
return cloneUniqueItemPool(await legacyDefaultUniqueItemPoolPromise);
|
||||
};
|
||||
|
||||
/**
|
||||
* Ref의 GameConst 기본값은 시나리오가 allItems를 덮어쓰지 않아도 항상 존재합니다.
|
||||
* 오래된 Core snapshot의 생략값/문자열 빈 객체도 같은 기본 풀로 해석합니다.
|
||||
*/
|
||||
export const resolveLegacyCompatibleUniqueConfig = async (
|
||||
configConst: Record<string, unknown>,
|
||||
loader?: ItemLoader
|
||||
): Promise<UniqueLotteryConfig> => {
|
||||
const config = resolveUniqueConfig(configConst);
|
||||
if (Object.keys(config.allItems).length > 0) {
|
||||
return config;
|
||||
}
|
||||
return {
|
||||
...config,
|
||||
allItems: await loadLegacyDefaultUniqueItemPool(loader),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user