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
255 stars 40 forks source link

Both player loss in elimination tournament #214

Open ckocank opened 1 week ago

ckocank commented 1 week ago

Due to https://github.com/Drarig29/brackets-manager.js/issues/160 I know there can't be 2 player lose at the same time but I want to make this case works, any idea how? image Both player will be eliminated at the same time.

Drarig29 commented 1 week ago

Can you give more context? What game is it? How can both of them lose?

ckocank commented 1 week ago

Can you give more context? What game is it? How can both of them lose?

I have a condition that both player must have met before the match start. If one player fail to match the condition, the other will win. So both player fail to match the condition, they will be eliminated. In round-robin, I can set a match draw but not elimination.

Drarig29 commented 1 week ago

Can you forfeit them instead?

ckocank commented 1 week ago

Can you forfeit them instead?

https://drarig29.github.io/brackets-docs/reference/manager/functions/helpers.setForfeits.html Is this the fuction you are talking about?

Drarig29 commented 1 week ago

https://drarig29.github.io/brackets-docs/reference/manager/functions/helpers.setForfeits.html Is this the fuction you are talking about?

No, generally you should not have to use helpers. I'm talking about using the usual manager.update.match() method.

You can pass forfeits there:

await manager.update.match({
    id: YOUR_MATCH_ID,
    opponent1: { forfeit: true },
    opponent2: { forfeit: true },
});

See unit tests:

https://github.com/Drarig29/brackets-manager.js/blob/8c2efdc6e5b4371002e5a647b974bad70d875f0c/test/round-robin.spec.js#L212-L225

Drarig29 commented 1 week ago

I have a condition that both player must have met before the match start.

I'm going to close the issue because this is the only solution, and you can say that "players failing to match those conditions will be forfeited". Cheers! 🥂

ckocank commented 1 week ago

Thanks for your replied. I tried

await manager.update.match({
          id: match.id,
          opponent1: { id: match.opponent1.id, forfeit: true },
          opponent2: { id: match.opponent2.id, forfeit: true },
        });

But it return Error: There are two forfeits. I can only forfeit 1 player.

Drarig29 commented 1 week ago

Ha... OK I think I designed it this way (double forfeits are only supported in round-robin), but I agree there is a use case.

I'll try to fix this so you are able to have 2 forfeits.