diff --git a/README.md b/README.md index 40c4b3a..3a27d2b 100644 --- a/README.md +++ b/README.md @@ -21,63 +21,126 @@ Under the hood is driven by the [Round-robin](https://en.wikipedia.org/wiki/Roun ### Manual integration - Download the source code [from Github](https://github.com/ndPPPhz/Fixture-Generator/archive/main.zip) - Import it into your project + +### Implementation +There are actually two ways for generating fixtures: +1. Using `generateRandomFixture`. It will return only one random fixture + ```javascript -const { generateRandomFixture } = require('.roundrobin.js') +const { generateRandomFixture } = require('.fixtureGenerator.js') /* @param {Array} array The array containing all the attendees - @param {Number} n The number of tournaments that needs to be randomly generated */ -const tournaments = generateRandomFixture([1,2,3,4], 2) +const tournaments = generateRandomFixture([1,2,3,4]) console.log(tournaments) /* [ - [ - { - "MatchDay 0": [ { - teamA: 1, - teamB: 3, + name: "MatchDay 1", + value: [ + { + teamA: 1, + teamB: 3, + }, + { + teamA: 2, + teamB: 4, + }, + ], }, { - teamA: 2, - teamB: 4, + name: "MatchDay 2", + value: [ + { + teamA: 1, + teamB: 2, + }, + { + teamA: 4, + teamB: 3, + }, + ], }, - ], - }, - { - "MatchDay 1": [ { - teamA: 1, - teamB: 2, - }, + name: "MatchDay 3", + value: [ + { + teamA: 1, + teamB: 4, + }, + { + teamA: 3, + teamB: 2, + }, + ], + } + ] +*/ + +``` + +2. `generateRandomFixtureFromAllPermutations` takes as argument the number of fixtures you want to generate. +```javascript +const { generateRandomFixtureFromAllPermutations } = require('.fixtureGenerator.js') + +/* + @param {Array} array The array containing all the attendees + @param {Number} n The number of tournaments that needs to be randomly generated +*/ +const tournaments = generateRandomFixture([1,2,3,4], 2) + +console.log(tournaments) + +/* + // First calendar + [.....], + // Second calendar + [ { - teamA: 4, - teamB: 3, + name: "MatchDay 1", + value: [ + { + teamA: 1, + teamB: 3, + }, + { + teamA: 2, + teamB: 4, + }, + ], }, - ], - }, - { - "MatchDay 2": [ { - teamA: 1, - teamB: 4, + name: "MatchDay 2", + value: [ + { + teamA: 1, + teamB: 2, + }, + { + teamA: 4, + teamB: 3, + }, + ], }, { - teamA: 3, - teamB: 2, - }, - ], - }, - ], - [ ...... ] + name: "MatchDay 3", + value: [ + { + teamA: 1, + teamB: 4, + }, + { + teamA: 3, + teamB: 2, + }, + ], + } + ] */ -``` - - ## License [![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](http://badges.mit-license.org)