fix: 개인 기록에 장수별 실행 시각을 보존
로그 발생 시각과 트랜잭션 flush 시각을 분리하고, 정규 및 즉시 장수 행동 로그에는 실행 전 장수 턴 시각을 기록한다. 기존 로그 행은 변경하지 않는다.
This commit is contained in:
@@ -814,7 +814,11 @@ export class InMemoryTurnWorld {
|
||||
};
|
||||
}
|
||||
|
||||
pushLog(entry: LogEntryDraft): void {
|
||||
pushLog(entry: LogEntryDraft, occurredAt?: Date): void {
|
||||
if (occurredAt && !entry.occurredAt) {
|
||||
this.logs.push({ ...entry, occurredAt: new Date(occurredAt.getTime()) });
|
||||
return;
|
||||
}
|
||||
this.logs.push(entry);
|
||||
}
|
||||
|
||||
@@ -1382,7 +1386,12 @@ export class InMemoryTurnWorld {
|
||||
this.dirtyNationIds.add(result.nation.id);
|
||||
}
|
||||
if (result.logs && result.logs.length > 0) {
|
||||
this.logs.push(...result.logs);
|
||||
// Ref command logs use the executing general's pre-advance turntime.
|
||||
// Preserve that per-entry occurrence time instead of replacing every
|
||||
// log in the transaction with the shared completion cursor at flush.
|
||||
for (const log of result.logs) {
|
||||
this.pushLog(log, currentGeneral.turnTime);
|
||||
}
|
||||
}
|
||||
if (result.messages && result.messages.length > 0) {
|
||||
this.messages.push(...result.messages);
|
||||
|
||||
@@ -2245,10 +2245,13 @@ export const createImmediateGeneralActionExecutor = async (options: {
|
||||
definition.formatConstraintFailure?.(reason, constraintCtx, args, view) ??
|
||||
`${reason} ${definition.name} 실패.`;
|
||||
if (input.actionKey === 'che_접경귀환' || input.actionKey === 'che_등용수락') {
|
||||
options.world.pushLog({
|
||||
...createActionLog(failureText),
|
||||
generalId: general.id,
|
||||
});
|
||||
options.world.pushLog(
|
||||
{
|
||||
...createActionLog(failureText),
|
||||
generalId: general.id,
|
||||
},
|
||||
general.turnTime
|
||||
);
|
||||
}
|
||||
return { ok: false, reason: failureText };
|
||||
}
|
||||
@@ -2325,7 +2328,7 @@ export const createImmediateGeneralActionExecutor = async (options: {
|
||||
|
||||
if (input.actionKey === 'che_접경귀환' && (resolution.general as TurnGeneral).cityId === general.cityId) {
|
||||
for (const log of resolution.logs) {
|
||||
options.world.pushLog(log);
|
||||
options.world.pushLog(log, general.turnTime);
|
||||
}
|
||||
return { ok: false, reason: '가까운 아국 도시가 없습니다.' };
|
||||
}
|
||||
@@ -2409,7 +2412,7 @@ export const createImmediateGeneralActionExecutor = async (options: {
|
||||
options.world.removeTroop(troopId);
|
||||
}
|
||||
for (const log of [...resolution.logs, ...progressionLogs]) {
|
||||
options.world.pushLog(log);
|
||||
options.world.pushLog(log, general.turnTime);
|
||||
}
|
||||
options.world.updateGeneral(input.generalId, nextGeneral);
|
||||
return { ok: true };
|
||||
|
||||
Reference in New Issue
Block a user