feat: 토너먼트 조별 전투 로그를 복원한다

예선과 본선 조별 경기의 최신 전투 로그를 저장하고 화면에 여덟 조 모두 표시한다. 결선은 최근 완료 경기와 종료 후 결승 로그를 유지하며 기존 대진 난수 순서를 보존한다.
This commit is contained in:
2026-08-22 04:51:46 +00:00
parent a41eb16bb9
commit e7fed61fb3
9 changed files with 345 additions and 30 deletions
+17 -1
View File
@@ -371,9 +371,14 @@ export const fillParticipants = async (options: {
};
export type TournamentMatchOutcome = {
groupId: number;
attackerId: number;
defenderId: number;
result: 'attacker' | 'defender' | 'draw';
winnerId?: number;
log: string[];
logEntries: NonNullable<TournamentMatchEntry['logEntries']>;
lastEnergy?: NonNullable<TournamentMatchEntry['lastEnergy']>;
};
export const applyGroupMatch = (
@@ -419,10 +424,18 @@ export const applyGroupMatch = (
const glDelta = Math.round((result.totalDamage.defender - result.totalDamage.attacker) / 50);
const lastLogEntry = result.logEntries.at(-1);
const outcome: TournamentMatchOutcome = {
groupId: matchIndex,
attackerId: attacker.id,
defenderId: defender.id,
result: result.draw ? 'draw' : result.winnerId === attacker.id ? 'attacker' : 'defender',
winnerId: result.winnerId ?? undefined,
log: result.log,
logEntries: result.logEntries,
lastEnergy: lastLogEntry
? { attacker: lastLogEntry.attackerEnergy, defender: lastLogEntry.defenderEnergy }
: undefined,
};
return {
@@ -572,7 +585,10 @@ export const buildNextMatches = (stage: number, matches: TournamentMatchEntry[])
throw new Error('다음 라운드를 만들 수 없습니다.');
}
const nextIdBase = matches.reduce((max, entry) => Math.max(max, entry.id), 0) + 1;
// 조별 최신 로그도 matches projection에 함께 보존하지만 결선 match ID는
// 전투 RNG seed의 일부이므로 기존 결선 경기만으로 연속 번호를 계산합니다.
const nextIdBase =
matches.filter((entry) => entry.stage >= 7).reduce((max, entry) => Math.max(max, entry.id), 0) + 1;
const nextStageValue = nextStage(stage);
const result: TournamentMatchEntry[] = [];