fix: 유산 전투 특기 고정과 내역 스크롤 수정
초기화 시 전투 특기를 null로 정규화하고 이전 특기 배열을 보존해 다음 월 고정 배정이 daemon 재시작 없이 동작하게 한다. 다중 변경 내역이 문서 높이를 늘리도록 하고 API, 월간 persistence, 실제 Chromium 회귀 검증을 추가한다.
This commit is contained in:
@@ -72,6 +72,11 @@ const parseBuffRecord = (raw: unknown): Record<string, number> => {
|
||||
|
||||
const serializeBuffRecord = (buff: Record<string, number>): string => JSON.stringify(buff);
|
||||
|
||||
const readStringList = (raw: unknown): string[] => {
|
||||
const parsed = typeof raw === 'string' ? parseJson<unknown>(raw) : raw;
|
||||
return Array.isArray(parsed) ? parsed.filter((entry): entry is string => typeof entry === 'string') : [];
|
||||
};
|
||||
|
||||
const readBuffLevel = (buff: Record<string, number>, key: InheritBuffType): number => {
|
||||
const compatibilityKey = key === 'domesticSuccessProb' ? 'success' : key === 'domesticFailProb' ? 'fail' : null;
|
||||
return Math.max(0, Math.min(5, Math.floor(buff[key] ?? (compatibilityKey ? buff[compatibilityKey] : 0) ?? 0)));
|
||||
@@ -133,7 +138,7 @@ const patchGeneral = async (
|
||||
strength?: number;
|
||||
intelligence?: number;
|
||||
};
|
||||
specialWar?: string;
|
||||
specialWar?: string | null;
|
||||
}
|
||||
): Promise<void> => {
|
||||
const result = await ctx.turnDaemon.requestCommand({
|
||||
@@ -530,16 +535,15 @@ export const inheritRouter = router({
|
||||
}
|
||||
|
||||
const meta = asRecord(general.meta);
|
||||
const prevList =
|
||||
parseJson<string[]>(typeof meta.prev_types_special2 === 'string' ? meta.prev_types_special2 : null) ?? [];
|
||||
const prevList = readStringList(meta.prev_types_special2);
|
||||
prevList.push(general.special2Code);
|
||||
|
||||
await patchGeneral(ctx, general.id, {
|
||||
specialWar: 'None',
|
||||
specialWar: null,
|
||||
meta: {
|
||||
...meta,
|
||||
inheritResetSpecialWar: nextLevel,
|
||||
prev_types_special2: JSON.stringify(prevList),
|
||||
prev_types_special2: prevList,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user