tournament-js / ffa

Free-for-all elimination tournaments
MIT License
9 stars 5 forks source link

Not properly checking whether advancers are unambiguous #4

Closed Kauhsa closed 6 years ago

Kauhsa commented 6 years ago

Hey,

I'm involved in our local dance gaming community, and was exploring what choices do we have software-wise for running FFA style tournaments. Quick search turned nothing, but I found this module and started making a simple UI on top of this, since this seemed very interesting!

Anyway, it seems like the module doesn't quite check properly for invalid scores:

const FFA = require('ffa')
const tournament = new FFA(8, { sizes: [8, 4], advancers: [4] });
tournament.unscorable(tournament.matches[0].id, [0, 0, 0, 0, 5, 0, 0, 0]); // null, meaning the score is valid?

In this case positions 2-4 are still ambiguous, unless I have misunderstood something. Reason for this seems to be that FFA.prototype._verify doesn't sort the scores before doing its check.

I'll try to make a proper test case and a patch as well, if my observations are correct :)

clux commented 6 years ago

Hey, this is a nice catch! Thanks a lot for this report!

This totally looks like a bug. There's no way to tell 2-4 here, and _verify was designed to catch this. Maybe all my test cases uses ordered scores :-(

clux commented 6 years ago

Released in ffa@3.2.1 - thanks again :-)