tournament-generator

1.4.1 • Public • Published

Tournament generator

Javascript package to generate tournaments automatically.

Installation

With npm

npm i tournament-generator --save

With yarn

yarn add tournament-generator

How to use

The next code snippet shows how to create a double-round competition.

// Import tournament generator
import generator from 'tournament-generator';

// List of all teams
const teams = ['Team1', 'Team2', 'Team3', 'Team4'];

// Generate and get games
const { data: games } = generator(teams, { type: 'double-round' });

The next snippet shows the possible content of the games entity.

games = [
  { awayTeam: 'Team1', homeTeam: 'Team3', round: 1 },
  { awayTeam: 'Team4', homeTeam: 'Team2', round: 1 },
  { awayTeam: 'Team2', homeTeam: 'Team1', round: 2 },
  { awayTeam: 'Team3', homeTeam: 'Team4', round: 2 },
  { awayTeam: 'Team1', homeTeam: 'Team4', round: 3 },
  { awayTeam: 'Team3', homeTeam: 'Team2', round: 3 },
  { awayTeam: 'Team3', homeTeam: 'Team1', round: 4 },
  { awayTeam: 'Team2', homeTeam: 'Team4', round: 4 },
  { awayTeam: 'Team1', homeTeam: 'Team2', round: 5 },
  { awayTeam: 'Team4', homeTeam: 'Team3', round: 5 },
  { awayTeam: 'Team4', homeTeam: 'Team1', round: 6 },
  { awayTeam: 'Team2', homeTeam: 'Team3', round: 6 }
]

Properties

At the moment the only supported property is the type and there are three possible tournament types to generate:

  • double-round: A championship competition where teams play against each other twice, one at home and one away.

  • single-round: A championship competition where teams play against each other one single time.

  • simple-cup: A cup competition that basically generates the first round (or the first two rounds) randomly.

You can see a better description of the competition types here.

Test

To run the package tests, you just need to execute:

npm test

or

yarn test

Package Sidebar

Install

npm i tournament-generator

Weekly Downloads

15

Version

1.4.1

License

MIT

Unpacked Size

38.4 kB

Total Files

28

Last publish

Collaborators

  • nunovieira220