Closed fluidpb closed 1 month ago
Did you try without balanceByes
?
I ended up with a different approach altogether. Found a script that generate seeding with null if it's not a power of 2:
const changeIntoBye = (seed: number, participantsCount: number) => {
return seed <= participantsCount ? seed : null;
}
const generateSeeding = (participants: any[]) => {
const participantsCount = participants.length,
rounds = Math.ceil(Math.log(participantsCount) / Math.log(2)),
bracketSize = Math.pow(2, rounds);
if (participantsCount < 2) {
return [];
}
let matches: any = [[1,2]];
for (let round: number = 1; round < rounds; round++) {
let roundMatches = [],
sum = Math.pow(2, round + 1) + 1;
for (let i: number = 0; i < matches.length; i++) {
let home = changeIntoBye(matches[i][0], participantsCount),
away = changeIntoBye(sum - matches[i][0], participantsCount);
roundMatches.push([home, away]);
home = changeIntoBye(sum - matches[i][1], participantsCount);
away = changeIntoBye(matches[i][1], participantsCount);
roundMatches.push([home, away]);
}
matches = roundMatches;
}
return matches;
}
This will generate something like this [ 1, null ], [ 5, 4 ], [ 3, 6 ], [ null, 2 ]
. I don't think brackets-manager supports non power of 2 participant list so this is a workaround.
Lastly,
const seeding = generateSeeding(participants);
const newParticipants: any[] = [];
const seedOrder: any[] = [];
seeding.forEach((seed: any) => {
seedOrder.push(seed[0], seed[1]);
});
seedOrder.forEach((seed: number | null) => {
if (seed === null) {
newParticipants.push(null);
}
else {
newParticipants.push(participants[seed - 1])
}
});
await manager.create.stage({
name: 'Elimination',
tournamentId: bracket.id,
type: 'single_elimination',
settings: {
grandFinal: 'none',
seedOrdering: ['natural']
},
seeding: newParticipants
});
Let me know if this is ok. I've tested several different ways and it worked nicely.
FYI, this is the software in action. https://app.fluidpb.com/tournaments/bracket/dd3df6a1-d9b2-47a9-b25e-fefa2d4072ca/playoff. We had to modify the viewer and a few other things to work with Pickleball.
Cool! I like the app you made! I'll close the issue since you managed to find a custom way 👍
I'm trying to setup a single elimination bracket where seed 1-2 have a bye. This is my data:
For some reason, seed 1 and 3 are getting bye instead. How do I resolve this?