tournament-js / duel

Duel elimination tournaments
MIT License
20 stars 2 forks source link

Duel help wanted #13

Closed SeVeNDuS closed 8 years ago

SeVeNDuS commented 8 years ago

Hi,

I have created a duel tournament with the following configuration

var Duel = require('duel'); var trn = new Duel(5);

Getting the currentRound with trn.currentRound() i always get a match with the following data: { id: { s: 2, r: 1, m: 1 }, p: [ 0, 0 ] }

So, using unscorable I got the following reason: LB R1 M1 not ready - missing players

What I am doing wrong??

Regards

clux commented 8 years ago

Hey.

currentRound is one of those helpers that's not necessarily been used a lot by people.

It can take a section argument the bracket number in this case (see https://github.com/clux/tournament/blob/master/doc/base.md#trncurrentroundsection--round ), however, it appears that in the Duel case with a bronze final, the currentRound will actually contain the bronze final, until it's done.

This is not ideal, but currentRound wasn't really designed around this. Bronze finals are kind of a weird special case in the design. You're best of specifying trn.currentRound(Duel.WB) for what to play in the winners bracket.

SeVeNDuS commented 8 years ago

Understood.

The problem now is that never got trn.isDone() === true due to that undesired match is there

This is my code: ` var _ = require('underscore');

var Duel = require('duel'); var trn = new Duel(15);

console.log(trn); var finished = false; while(!finished) { finished = scoreRound(trn); }

function scoreRound (trn) { var currentRound = trn.currentRound(Duel.WB);
console.log('ROUND'); console.log(currentRound); currentRound.forEach(function (m) { var scores = []; if (_.indexOf(m.p, -1) === -1) {
m.p.forEach(function (player) { scores.push(Math.floor(Math.random() * (100 - 50 + 1)) + 50); });
if (scores[0] === scores[1]) { scores[0] += 1; } console.log(m.id.r, m.id.s, m.p, scores);
var reason = trn.unscorable(m.id, scores);
if (reason !== null) { console.log(reason); // either invalid parameters or complaining about rewriting history } else { trn.score(m.id, scores); } }
}); //console.log('RESULTADO RONDA', trn.matches); return trn.isDone(); }; `

clux commented 8 years ago

If you don't want the bronze final, you can leave it out entirely by passing {short: true} to the Duel constructor as a second argument.

SeVeNDuS commented 8 years ago

Ok.

Thanks for your time.