feat: add double elimination match mode

This commit is contained in:
dahyeon committed 2026-06-26 05:00:08 -07:00
1 parent b9aaf55193
commit e12f182e7f
19 files changed
+3415 -58

No files matched your search

@@ -10,6 +10,9 @@ type TournamentResultServiceInternals = TournamentResultService & {
match: MatchDocument,
gameNumber: number,
): { teamAIndex: number; teamBIndex: number };
buildSeriesResults(
games: NonNullable<MatchDocument['result']>['games'],
): NonNullable<MatchDocument['result']>['seriesResults'];
};
function createService() {
@@ -100,6 +103,56 @@ describe('TournamentResultService round-robin scheduling', () => {
teamBIndex: 4,
});
});
it('keeps double-elimination rematches separated by bracket match id', () => {
const service = createService();
expect(
service.buildSeriesResults([
{
gameNumber: 1,
bracketMatchId: 'WB_FINAL',
riotMatchId: 'KR_1',
blueTeamIndex: 1,
redTeamIndex: 2,
winnerTeamIndex: 1,
winnerSide: 'blue',
gameCreation: 1,
gameDuration: 1800,
participants: [],
},
{
gameNumber: 2,
bracketMatchId: 'GF',
riotMatchId: 'KR_2',
blueTeamIndex: 1,
redTeamIndex: 2,
winnerTeamIndex: 2,
winnerSide: 'red',
gameCreation: 2,
gameDuration: 1800,
participants: [],
},
]),
).toEqual([
{
bracketMatchId: 'GF',
teamAIndex: 1,
teamBIndex: 2,
teamAWins: 0,
teamBWins: 1,
winnerTeamIndex: 2,
},
{
bracketMatchId: 'WB_FINAL',
teamAIndex: 1,
teamBIndex: 2,
teamAWins: 1,
teamBWins: 0,
winnerTeamIndex: 1,
},
]);
});
});
describe('TournamentResultService tournament code polling', () => {