0.2.0 • Published 4 years ago

swisser v0.2.0

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

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'].

ParameterTypeDescription
playersarray of stringsA 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.

ParameterTypeDescription
tournamenttournament objectThe tournament object to drop against.
playersarray of player indexesA 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.

ParameterTypeDescription
tournamenttournament objectThe 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.

ParameterTypeDescription
tournamenttournament objectThe tournament object to drop against.
ixP1numberIndex of player 1.
gamesP1numberGames player 1 won.
ixP2numberIndex of player 2.
gamesP2numberGames player 2 won.
0.1.2

4 years ago

0.2.0

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago