왕조 연감에 해당 기수의 지도 레이아웃을 적용한다

This commit is contained in:
2026-09-24 16:03:51 +00:00
parent 8823434610
commit 2b2edeaeff
5 changed files with 90 additions and 12 deletions
+9 -2
View File
@@ -66,8 +66,10 @@ const resolveMapName = async (
}
};
export const loadMapLayout = async (scenario: string, options: MapLayoutLoaderOptions = {}): Promise<MapLayout> => {
const mapName = await resolveMapName(scenario, options.loadScenario ?? loadScenarioDefinitionById);
export const loadMapLayoutByName = async (
mapName: string,
options: MapLayoutLoaderOptions = {}
): Promise<MapLayout> => {
const useCache = !options.loadScenario && !options.loadMap && !options.loadRegionMap;
const cached = useCache ? layoutCache.get(mapName) : undefined;
if (cached) {
@@ -98,3 +100,8 @@ export const loadMapLayout = async (scenario: string, options: MapLayoutLoaderOp
}
return layout;
};
export const loadMapLayout = async (scenario: string, options: MapLayoutLoaderOptions = {}): Promise<MapLayout> => {
const mapName = await resolveMapName(scenario, options.loadScenario ?? loadScenarioDefinitionById);
return loadMapLayoutByName(mapName, options);
};
+13
View File
@@ -6,6 +6,7 @@ import { asRecord, isRecord } from '@sammo-ts/common';
import { LogCategory, LogScope } from '@sammo-ts/logic';
import type { GameApiContext } from '../../context.js';
import { loadMapLayout, loadMapLayoutByName } from '../../maps/mapLayout.js';
import { loadPublicMap, type BaseMapResult } from '../../maps/worldMap.js';
import {
formatGeneralAccessLimitMessage,
@@ -339,11 +340,23 @@ export const yearbookRouter = router({
const firstYearMonth = firstRow ? joinYearMonth(firstRow.year, firstRow.month) : fallbackYearMonth;
const lastYearMonth = lastRow ? joinYearMonth(lastRow.year, lastRow.month) : fallbackYearMonth;
const selectedYearMonth = target.isCurrentProfile ? currentYearMonth : lastYearMonth;
// Ref v_history.php resolves an archived generation's map from ng_games.map.
const mapLayout = target.isCurrentProfile
? await loadMapLayout(ctx.profile.scenario)
: await loadMapLayoutByName(
(
await ctx.db.gameHistory.findUnique({
where: { serverId: target.archiveKey },
select: { map: true },
})
)?.map || 'che'
);
return {
firstYearMonth,
lastYearMonth,
currentYearMonth: selectedYearMonth,
mapLayout,
};
}),
getHistory: authedProcedure