Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
tournament
Advanced tools
Readme
Tournament provides a base class for stateful tournament types of fixed size tournaments.
All tournaments have a huge amount of common logic so the helper methods included on this base class is worth reading about even if you don't use this module directly.
You should read at least one of:
Implementions:
For multi stage tournaments, or if you need to grab functionality from multiple implementations, there is also a module for that:
Create a new tournament instance from one of the separate implementations, then interact with helper functions to score and calculate results.
var Duel = require('duel');
var d = new Duel(4); // 4 players - single elimination
d.matches; // in playable order
[ { id: { s: 1, r: 1, m: 1 }, // semi 1
p: [ 1, 4 ] },
{ id: { s: 1, r: 1, m: 2 }, // semi 2
p: [ 3, 2 ] },
{ id: { s: 1, r: 2, m: 1 }, // grand final
p: [ 0, 0 ] },
{ id: { s: 2, r: 1, m: 1 }, // bronze final
p: [ 0, 0 ] } ]
// let's pretend we scored these individually in a more realistic manner
d.matches.forEach(function (m) {
d.score(m.id, [1, 0]);
});
// now winners are propagated and map scores are recorded
d.matches;
[ { id: { s: 1, r: 1, m: 1 },
p: [ 1, 4 ],
m: [ 1, 0 ] },
{ id: { s: 1, r: 1, m: 2 },
p: [ 3, 2 ],
m: [ 1, 0 ] },
{ id: { s: 1, r: 2, m: 1 }, // 1 and 3 won their matches and play the final
p: [ 1, 3 ],
m: [ 1, 0 ] },
{ id: { s: 2, r: 1, m: 1 }, // 4 and 2 lost and play the bronze final
p: [ 4, 2 ],
m: [ 1, 0 ] } ]
// can view results at every stage of the tournament, here are the final ones
d.results();
[ { seed: 1, wins: 2, for: 2, against: 0, pos: 1 },
{ seed: 3, wins: 1, for: 1, against: 1, pos: 2 },
{ seed: 4, wins: 1, for: 1, against: 1, pos: 3 },
{ seed: 2, wins: 0, for: 0, against: 2, pos: 4 } ]
For specific tournament usage, install the modules you want:
$ npm install duel ffa groupstage tiebreaker --save
To use these on in the browser, bundle it up with browserify
$ npm dedupe
$ browserify -r duel -r ffa -r groupstage -r tiebreaker > bundle.js
MIT-Licensed. See LICENSE file for details.
FAQs
Tournament interface
The npm package tournament receives a total of 360 weekly downloads. As such, tournament popularity was classified as not popular.
We found that tournament demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.