cankatabaci / fixture-creator

fixture-creator is a Round-robin tournament based sports fixture creator

Home Page:https://www.npmjs.com/package/fixture-creator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fixture Creator

Node.js CI Publish Package to npmjs

Round-robin tournament based sports fixture creator

Install

npm i fixture-creator

Usage

import { FixtureCreator } from "fixture-creator";

const teams:string[] = ['Barcelona', 'Bayern Munich', 'Galatasaray'];
const fixtureCreator = new FixtureCreator();

console.log(fixtureCreator.createLeagueFixture(teams));

teams should be a array of team names as a string
teams must have at least 2 team
if teams length is odd, the team that will not play that week is shown to face 'BYE-THIS-WEEK'. If you prefer dash(-) instead of this text, you have to write false after team string

console.log(fixtureCreator.createLeagueFixture(teams, false));

fixtureCreator.createLeagueFixture(teams) returns fixture object. fixture object contains game weeks array.

{
   "weeks":[
      {
         "title":"1. Match Week",
         "matches":[
            {
               "home":"Galatasaray",
               "away":"Barcelona"
            },
            {
               "home":"Bayern Munich",
               "away":"BYE-THIS-WEEK"
            }
         ]
      },
      {
         "title":"2. Match Week",
         "matches":[
            {
               "home":"Galatasaray",
               "away":"BYE-THIS-WEEK"
            },
            {
               "home":"Barcelona",
               "away":"Bayern Munich"
            }
         ]
      },
      {
          ...
          ...
      }
   ]
}

Notes

I developed this package to use in
FIFA tournaments that we play with our friends.
We play our FIFA tournament like a classic league
so it creates(by default) a fixture that includes the return matches.

About

fixture-creator is a Round-robin tournament based sports fixture creator

https://www.npmjs.com/package/fixture-creator


Languages

Language:TypeScript 96.2%Language:JavaScript 3.8%