fix: restore ref map hover details and title
This commit is contained in:
@@ -10,6 +10,11 @@ export type BaseMapResult = {
|
||||
startYear: number;
|
||||
year: number;
|
||||
month: number;
|
||||
techLevelLimit: {
|
||||
maxLevel: number;
|
||||
initialLevel: number;
|
||||
increaseYears: number;
|
||||
};
|
||||
cityList: MapCityCompact[];
|
||||
nationList: MapNationCompact[];
|
||||
};
|
||||
@@ -64,6 +69,23 @@ const readState = (meta: Record<string, unknown>): number => {
|
||||
return 0;
|
||||
};
|
||||
|
||||
const readPositiveInteger = (value: unknown, fallback: number): number => {
|
||||
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
||||
return fallback;
|
||||
}
|
||||
const normalized = Math.floor(value);
|
||||
return normalized > 0 ? normalized : fallback;
|
||||
};
|
||||
|
||||
const resolveTechLevelLimit = (worldState: WorldStateRow): BaseMapResult['techLevelLimit'] => {
|
||||
const constValues = asRecord(asRecord(worldState.config).const);
|
||||
return {
|
||||
maxLevel: readPositiveInteger(constValues.maxTechLevel, 12),
|
||||
initialLevel: readPositiveInteger(constValues.initialAllowedTechLevel, 1),
|
||||
increaseYears: readPositiveInteger(constValues.techLevelIncYear, 5),
|
||||
};
|
||||
};
|
||||
|
||||
const normalizeNumberRecord = (value: unknown): Record<number, number> => {
|
||||
if (!isRecord(value)) {
|
||||
return {};
|
||||
@@ -180,6 +202,7 @@ const loadBaseMap = async (
|
||||
startYear: resolveStartYear(worldState),
|
||||
year: worldState.currentYear,
|
||||
month: worldState.currentMonth,
|
||||
techLevelLimit: resolveTechLevelLimit(worldState),
|
||||
cityList,
|
||||
nationList,
|
||||
};
|
||||
|
||||
@@ -26,7 +26,13 @@ const buildContext = () => {
|
||||
findFirst: vi.fn(async () => ({
|
||||
currentYear: 190,
|
||||
currentMonth: 3,
|
||||
config: {},
|
||||
config: {
|
||||
const: {
|
||||
maxTechLevel: 10,
|
||||
initialAllowedTechLevel: 2,
|
||||
techLevelIncYear: 4,
|
||||
},
|
||||
},
|
||||
meta: { scenarioMeta: { startYear: 184 } },
|
||||
})),
|
||||
},
|
||||
@@ -38,12 +44,8 @@ const buildContext = () => {
|
||||
},
|
||||
$queryRaw: vi
|
||||
.fn()
|
||||
.mockResolvedValueOnce([
|
||||
{ id: 1, level: 5, nationId: 1, region: 1, supplyState: 1, meta: { state: 0 } },
|
||||
])
|
||||
.mockResolvedValueOnce([
|
||||
{ id: 1, name: '촉', color: '#ff0000', capitalCityId: 1, meta: {} },
|
||||
]),
|
||||
.mockResolvedValueOnce([{ id: 1, level: 5, nationId: 1, region: 1, supplyState: 1, meta: { state: 0 } }])
|
||||
.mockResolvedValueOnce([{ id: 1, name: '촉', color: '#ff0000', capitalCityId: 1, meta: {} }]),
|
||||
};
|
||||
const context: GameApiContext = {
|
||||
db: db as unknown as DatabaseClient,
|
||||
@@ -70,6 +72,11 @@ describe('public.getCachedMap', () => {
|
||||
expect(result).toMatchObject({
|
||||
year: 190,
|
||||
month: 3,
|
||||
techLevelLimit: {
|
||||
maxLevel: 10,
|
||||
initialLevel: 2,
|
||||
increaseYears: 4,
|
||||
},
|
||||
history: [
|
||||
{ id: 9, text: '<Y>최근 정세</>' },
|
||||
{ id: 8, text: '이전 정세' },
|
||||
|
||||
Reference in New Issue
Block a user