A simple library to manage tournament brackets (round-robin, single elimination, double elimination).
It contains all the logic needed to manage tournaments.
For more information, see the documentation.
const { JsonDatabase } = require('brackets-json-db');
const { BracketsManager } = require('brackets-manager');
const storage = new JsonDatabase();
const manager = new BracketsManager(storage);
// Create an elimination stage for tournament `3`.
await manager.create.stage({
tournamentId: 3,
name: 'Elimination stage',
type: 'double_elimination',
seeding: ['Team 1', 'Team 2', 'Team 3', 'Team 4'],
settings: { grandFinal: 'double' },
});
await manager.update.match({
id: 0, // First match of winner bracket (round 1)
opponent1: { score: 16, result: 'win' },
opponent2: { score: 12 },
});
Rendered with the viewer:
As you can see, the manager is composed of submodules, which themselves have methods:
create
module: manager.create.stage()
get
module: manager.get.seeding()
, manager.get.finalStandings()
, ...update
module: manager.update.match()
, manager.update.confirmSeeding()
, ...reset
module: manager.reset.seeding()
, manager.reset.matchGame()
, ...delete
module: manager.delete.stage()
find
module: manager.find.match()
, manager.find.nextMatches()
, ...storage
module: this gives you access to the abstract storage interface. Use it as a last resort.You can navigate the API documentation here: BracketsManager
class documentation
All the helpers defined by the library are available here:
const { helpers } = require('brackets-manager');
This library has been created to be used by the Nantarena.
It has been inspired by: