mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-08 20:26:08 -05:00
Handle counting SE rounds
This commit is contained in:
@@ -27,6 +27,13 @@ CountBracketRounds("Counts bracket (DE - 16)", () => {
|
||||
assert.equal(count, { winners: 6, losers: 6 });
|
||||
});
|
||||
|
||||
CountBracketRounds("Counts bracket (SE - 16)", () => {
|
||||
const bracket = eliminationBracket(16, "SE");
|
||||
const count = countRounds(bracket);
|
||||
|
||||
assert.equal(count, { winners: 5, losers: 0 });
|
||||
});
|
||||
|
||||
RoundNames("No bracket reset round for SE", () => {
|
||||
const bracketSE = getRoundNames(eliminationBracket(16, "SE"));
|
||||
const bracketDE = getRoundNames(eliminationBracket(16, "DE"));
|
||||
|
||||
@@ -109,12 +109,15 @@ export function getRoundNames(bracket: Bracket): EliminationBracket<string[]> {
|
||||
}
|
||||
|
||||
export function countRounds(bracket: Bracket): EliminationBracket<number> {
|
||||
let winners = 2;
|
||||
const isDE = bracket.losers.length > 0;
|
||||
let winners = 1 + Number(isDE);
|
||||
|
||||
for (let i = bracket.participantsWithByesCount; i > 1; i /= 2) {
|
||||
winners++;
|
||||
}
|
||||
|
||||
if (!isDE) return { winners, losers: 0 };
|
||||
|
||||
const losersMatchIds = new Set(bracket.losers.map((match) => match.id));
|
||||
let losers = 0;
|
||||
let losersMatch = bracket.losers[bracket.losers.length - 1];
|
||||
|
||||
Reference in New Issue
Block a user