Skip to content

Commit

Permalink
Npm package generation fixes + readme updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
Renan Verissimo de vasconcelos committed Nov 19, 2018
1 parent 8571393 commit 5d8fe2e
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 11 deletions.
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build
docs
examples
src
.babelrc
gulpfile.babel.js
67 changes: 66 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,66 @@
# bracketzada
# bracketzada
A JavaScript library for tournament brackets generation. Design your own way, Bracketzada do the rest. Live example: https://katreque.github.io/bracketzada/

## Why?
Most of tournament bracket generators/libs implement algorithms and create components for you. Bracketzada has the idea to provide an API to generate and manage tournaments while you create and design your own frontend. The freedom you want, the power you need.

## Types
Implemented:
- Simple Elimination

Future:
- Double Elimination
- Swiss Brackets


## Quick Start
Install bracketzada via npm on your project:

```
npm install bracketzada --save
```

Import both Player and Tournament classes and generate Tournament Brackets object, with all the info you need.

```javascript
let {Player, Tournament} = require('bracketzada');
let players = [
new Player(0, 'Kappa'),
new Player(1, 'Keppo'),
new Player(2, 'PogChamp'),
new Player(3, '4Head')
];
let championship = new Tournament();
let brackets = championship.generateBrackets();

/*
brackets:
[ Node {
id: 0,
idChildren: [ 1 ],
playerLeft: undefined,
playerRight: undefined },
Node {
id: 1,
idChildren: [ 2, 3 ],
playerLeft: undefined,
playerRight: undefined },
Node {
id: 2,
idChildren: [],
playerLeft: Player { id: 0, name: 'Kappa' },
playerRight: Player { id: 1, name: 'Keppo' } },
Node {
id: 3,
idChildren: [],
playerLeft: Player { id: 2, name: 'PogChamp' },
playerRight: Player { id: 3, name: '4Head' } } ]
*/
```

## Methods


## License
[MIT](https://github.com/Katreque/bracketzada/blob/master/LICENSE)

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
6 changes: 3 additions & 3 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import uglify from 'gulp-uglify';
import rename from 'gulp-rename';
import del from 'del';

gulp.task('build_commonjs', function (done) {
gulp.task('build', function (done) {
return gulp.src('./build/bracketzada.js')
.pipe(babel({
presets: [
Expand All @@ -16,7 +16,7 @@ gulp.task('build_commonjs', function (done) {
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('dist/commonjs'))
.pipe(gulp.dest('./dist'))
.on('end', () => done())
});

Expand All @@ -36,5 +36,5 @@ gulp.task('del', function () {
gulp.task('build', gulp.series(
'del',
'unit_test',
'build_commonjs'
'build'
));
3 changes: 3 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = require('./dist/bracketzada.min.js');
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "bracketzada",
"version": "0.1.1",
"version": "0.1.2",
"description": "",
"main": "bracketzada.js",
"main": "main.js",
"scripts": {
"test": "tsc && gulp unit_test",
"build": "tsc && gulp build"
Expand Down
8 changes: 4 additions & 4 deletions src/bracketzada.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ export class Tournament {
}

private _setPlayers(graph: Array<Node>, players: Array<Player>) : Array<Node> {
if (!players.length) {
throw new Error("Players array can't be empty.");
}

if (players.length === 1) {
throw new Error("Must have more then 1 player.");
}
Expand All @@ -95,6 +91,10 @@ export class Tournament {
}

public generateBrackets(): Array<Node> {
if (!this.players || !this.players.length) {
throw new Error("Players array can't be empty.");
}

return this._generateGraph(this.numberNodes());
}

Expand Down

0 comments on commit 5d8fe2e

Please sign in to comment.