Drarig29 / brackets-manager.js

A simple library to manage tournament brackets (round-robin, single elimination, double elimination).
https://drarig29.github.io/brackets-docs
MIT License
245 stars 38 forks source link

currentMatches() fails even with `single_elimination` #163

Closed mikhail closed 1 year ago

mikhail commented 1 year ago
    name: "My tournament",
    tournamentId,
    type: "single_elimination",
    seeding: [
      "Team 1",
      "Team 2",
      "Team 3",
      "Team 4",
      "Team 5",
      "Team 6",
      "Team 7",
      "Team 8",
    ],
    settings: {grandFinal: "simple"}, 
  });

fails on this line (my modified string)

if (stage.type !== 'single_elimination')
            throw Error('currentMatches() Not implemented for "'+stage.type+'", round robin and double elimination. Ask if n    eeded.');

saying: ⚠ functions: Error: currentMatches() Not implemented for "double_elimination", round robin and double elimination. Ask if needed.

Cannot figure out why it thinks type is double_elimination even though I set it to single

mikhail commented 1 year ago

Nevermind. This was a weird artifact of using Firebase function local emulator + JsonDatabase + bad assumption. Not likely to be an issue anywhere outside of this particular setup

mikhail commented 1 year ago

The README creates a stage using manager.create but the name is "My Tournament" . So without reading documentation it's fair to assume that manager.create creates and returns a Tournament object. Using this object's id to further search stages creates a confusing flow of data

Drarig29 commented 1 year ago

Hi @mikhail, good point on the README. I'll change this.