swisser v0.2.0
Swisser
The minimal TypeScript library to manage swiss pairings for tournaments.
Table of contents
Features
Currently, Swisser supports the following:
- JSDoc
- Vanilla JavaScript (no dependencies)
- npm install
- TypeScript
Installation
Adding Swisser to your project is incredibly simple:
1. Link build/swisser.min.js to your project or run npm install swisser --save
Create a Tournament
makeTournament(players)Returns a new tournament object from an array of players: ['Player A', 'Player B', 'Player C'].
| Parameter | Type | Description |
|---|---|---|
players | array of strings | A list of player names. |
Drop Players
dropPlayers(tournament, players)Returns a new tournament object identical to tournament without the given
players. The players are not present in the returned tournament's list of
players and are represented its results graph.
| Parameter | Type | Description |
|---|---|---|
tournament | tournament object | The tournament object to drop against. |
players | array of player indexes | A list of players to drop in tournament by index. |
Make Pairings
makePairings(tournament)Returns a matching of players for the next round of play.
Note makePairings will throw if the current round is not complete.
| Parameter | Type | Description |
|---|---|---|
tournament | tournament object | The tournament object to generate pairings from. |
Record Result
recordResult(tournament, ixP1, gamesP1, ixP2, gamesP2)Returns a new tournament object where the player at position ixP1 won
gamesP1 against the player at position ixP2, similarly the ixP2 player
won gamesP2 against the player at ixP1, Note that recordResult allows you
to fix a previously recorded result as well as record a new result.
Note recordResult will throw a RangeError if ixP1 === ixP2.
| Parameter | Type | Description |
|---|---|---|
tournament | tournament object | The tournament object to drop against. |
ixP1 | number | Index of player 1. |
gamesP1 | number | Games player 1 won. |
ixP2 | number | Index of player 2. |
gamesP2 | number | Games player 2 won. |