Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ndPPPhz committed Feb 27, 2021
1 parent c80ef00 commit 89cb25c
Showing 1 changed file with 98 additions and 35 deletions.
133 changes: 98 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 89cb25c

Please sign in to comment.