g-loot / react-tournament-brackets

React component library for displaying bracket leaderboards
https://sleepy-kare-d8538d.netlify.app/?path=/story/components-bracket--bracket
GNU Lesser General Public License v2.1
220 stars 69 forks source link

A quick questions #9

Closed theHazzard closed 3 years ago

theHazzard commented 3 years ago

Sorry again for bothering you with this.

I'm generating a single_elimination bracket but with a bronze match, by default, the GSDuel Library generates a lower bracket with the last match (even if it's a single bracket tournament) is there any way to represent this as a single_elimination?

for example, put that before the last match on the list, using a dual elimination with only one game on the lower bracket, or something similar?

this is the data I'm using, I don't know why they use the lower bracket even if it's a single-elimination tournament :(

[
  {
    "id": 1,
    "name": "WB R1 M1",
    "nextMatchId": 2,
    "startTime": null,
    "tournamentRound": "R1",
    "tournamentRoundText": 1,
    "state": "WALK_OVER",
    "participants": [
      {
        "id": "408246f7-35a8-4b5f-864a-3cba884f0728",
        "resultText": null,
        "isWinner": true,
        "status": "WALK_OVER",
        "name": "Brown 7"
      },
      {
        "id": null,
        "resultText": "",
        "isWinner": false,
        "status": null,
        "name": "--------------"
      }
    ]
  },
  {
    "id": 2,
    "name": "WB R1 M2",
    "nextMatchId": 2,
    "startTime": "2021-08-09T16:00:00.413+00:00",
    "tournamentRound": "R1",
    "tournamentRoundText": 1,
    "state": "SCORE_DONE",
    "participants": [
      {
        "id": "11ed77de-0e1f-4f49-a002-23e753739da2",
        "resultText": "1",
        "isWinner": true,
        "status": "PLAYED",
        "name": "Gold 5"
      },
      {
        "id": "9f88f9e7-7127-48c7-90ba-7f61d81c30a9",
        "resultText": "0",
        "isWinner": false,
        "status": "PLAYED",
        "name": "Orange 4"
      }
    ]
  },
  {
    "id": 3,
    "name": "WB R1 M3",
    "nextMatchId": 6,
    "startTime": "2021-08-09T16:00:00.413+00:00",
    "tournamentRound": "R1",
    "tournamentRoundText": 1,
    "state": "SCORE_DONE",
    "participants": [
      {
        "id": "79d23b5b-be83-428e-8098-49b303a0fec9",
        "resultText": "1",
        "isWinner": true,
        "status": "PLAYED",
        "name": "Yellow 9"
      },
      {
        "id": "095e9918-1bbe-41b7-a49c-98c77529ea01",
        "resultText": "0",
        "isWinner": false,
        "status": "PLAYED",
        "name": "Black 6"
      }
    ]
  },
  {
    "id": 4,
    "name": "WB R1 M4",
    "nextMatchId": 6,
    "startTime": null,
    "tournamentRound": "R1",
    "tournamentRoundText": 1,
    "state": "WALK_OVER",
    "participants": [
      {
        "id": null,
        "resultText": "",
        "isWinner": false,
        "status": null,
        "name": "--------------"
      },
      {
        "id": "ea34ad0f-e758-483e-b28b-28d0fd275656",
        "resultText": null,
        "isWinner": true,
        "status": "WALK_OVER",
        "name": "Purple 8"
      }
    ]
  },
  {
    "id": 2,
    "name": "WB R2 M1",
    "nextMatchId": 7,
    "startTime": "2021-08-09T14:00:00.413+00:00",
    "tournamentRound": "R2",
    "tournamentRoundText": 2,
    "state": "SCORE_DONE",
    "participants": [
      {
        "id": "408246f7-35a8-4b5f-864a-3cba884f0728",
        "resultText": "1",
        "isWinner": true,
        "status": "PLAYED",
        "name": "Brown 7"
      },
      {
        "id": "11ed77de-0e1f-4f49-a002-23e753739da2",
        "resultText": "0",
        "isWinner": false,
        "status": "PLAYED",
        "name": "Gold 5"
      }
    ],
    "nextLooserMatchId": 4
  },
  {
    "id": 6,
    "name": "WB R2 M2",
    "nextMatchId": 7,
    "startTime": "2021-08-09T17:00:00.413+00:00",
    "tournamentRound": "R2",
    "tournamentRoundText": 2,
    "state": "SCORE_DONE",
    "participants": [
      {
        "id": "79d23b5b-be83-428e-8098-49b303a0fec9",
        "resultText": "1",
        "isWinner": true,
        "status": "PLAYED",
        "name": "Yellow 9"
      },
      {
        "id": "ea34ad0f-e758-483e-b28b-28d0fd275656",
        "resultText": "0",
        "isWinner": false,
        "status": "PLAYED",
        "name": "Purple 8"
      }
    ],
    "nextLooserMatchId": 4
  },
  {
    "id": 7,
    "name": "WB R3 M1",
    "nextMatchId": null,
    "startTime": "2021-08-09T18:00:00.413+00:00",
    "tournamentRound": "R3",
    "tournamentRoundText": 3,
    "state": "SCORE_DONE",
    "participants": [
      {
        "id": "408246f7-35a8-4b5f-864a-3cba884f0728",
        "resultText": "0",
        "isWinner": false,
        "status": "PLAYED",
        "name": "Brown 7"
      },
      {
        "id": "79d23b5b-be83-428e-8098-49b303a0fec9",
        "resultText": "1",
        "isWinner": true,
        "status": "PLAYED",
        "name": "Yellow 9"
      }
    ]
  },
  {
    "id": 4,
    "name": "LB R1 M1",
    "nextMatchId": null,
    "startTime": "2021-08-09T13:00:00.413+00:00",
    "tournamentRound": "R1",
    "tournamentRoundText": 1,
    "state": "SCORE_DONE",
    "participants": [
      {
        "id": "11ed77de-0e1f-4f49-a002-23e753739da2",
        "resultText": "0",
        "isWinner": false,
        "status": "PLAYED",
        "name": "Gold 5"
      },
      {
        "id": "ea34ad0f-e758-483e-b28b-28d0fd275656",
        "resultText": "1",
        "isWinner": true,
        "status": "PLAYED",
        "name": "Purple 8"
      }
    ]
  }
]

if I feed that (obviously, because I think it has something to do with that extra game) I get an infinite rendering issue, I guess it haves something to do with the other game belonging to the loser bracket.

Shenato commented 3 years ago

Hey,

I don't think you provided the full data here. The matches nextMatchId don't add up on your list.

I can't really do much about this issue in the library since this doesn't sound like a bug with the library, more an issue with the data you're providing.

In my head it makes sense for you to concatenate both the upper and Lower bracket for the single elimination bracket and see what happens. As long as the tree of matches is filled properly with nextMatchId and ids that all link together it should work just fine!

Hope this helps!

theHazzard commented 3 years ago

thanks! I'll take a look

Shenato commented 3 years ago

Alright I'll close this issue!