Have ideas to improve npm?Join in the discussion! »

    tournament-generator

    1.2.0 • 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

    Future work

    In the future, the objective is to:

    • Add draw pots to cup competitions which brings the objective of creating cups based on groups.
    • Add plugin support for entire competitions like Champions League or Europa League. **
    • Add full competition management like classifications, leaderboards, etc. **

    ** Not sure if it makes sense to be integrated in this package or on a different one.

    Install

    npm i tournament-generator

    DownloadsWeekly Downloads

    76

    Version

    1.2.0

    License

    MIT

    Unpacked Size

    32.2 kB

    Total Files

    28

    Last publish

    Collaborators

    • avatar