Set Opponent1 forfeit should reset Opponent2 forfeit and vice versa #128
-
Scenario: Update parent match manually which has match_games ( 1st update: The match by forfeiting the
This works correctly. Result from `window.inMemoryDatabase.data` after 1st update
{
"id": 1,
"number": 2,
"stage_id": 0,
"group_id": 0,
"round_id": 0,
"child_count": 3,
"status": 4,
"opponent1": {
"id": 1,
"position": 2,
"result": "win",
"forfeit": true
},
"opponent2": {
"id": 2,
"position": 3,
"result": "loss",
"forfeit": true
}
} 2nd update: Reverse by forfeiting {
"groupId": 0,
"roundNumber": 1,
"matchNumber": 2,
"opponent1": {
"forfeit": false,
"result": "win"
},
"opponent2": {
"forfeit": true,
"result": null
},
"id": 1
} Result from `window.inMemoryDatabase.data` after 2nd update
{
"id": 1,
"number": 2,
"stage_id": 0,
"group_id": 0,
"round_id": 0,
"child_count": 3,
"status": 4,
"opponent1": {
"id": 1,
"position": 2,
"result": "win",
"forfeit": true
},
"opponent2": {
"id": 2,
"position": 3,
"result": "loss",
"forfeit": true
}
} This led to getting the error:
I can escape this error while updating the match without child
But this reset doesn't work with a match has child brackets-manager.js/src/reset.ts Lines 18 to 19 in b84e02b Source: Suspect the code below doesn't reset the other opponent's forfeit & result when one opponent is forfeited (Line 1006 & 1013). brackets-manager.js/src/helpers.ts Lines 1002 to 1016 in 14df8eb Proposed Source Code:
export function setForfeits(stored: MatchResults, match: Partial<MatchResults>): void {
if (match.opponent1?.forfeit === true
&& match.opponent2?.forfeit === true) {
throw Error("There are two forfeits.");
}
if (match.opponent1?.forfeit === true) {
if (stored.opponent1) {
stored.opponent1.forfeit = true;
stored.opponent1.result = null;
}
if (stored.opponent2) {
stored.opponent2.forfeit = null;
stored.opponent2.result = 'win';
}
else {
stored.opponent2 = { id: null, result: 'win' };
}
}
if (match.opponent2?.forfeit === true) {
if (stored.opponent2) {
stored.opponent2.forfeit = true;
stored.opponent2.result = null;
}
if (stored.opponent1) {
stored.opponent1.forfeit = null;
stored.opponent1.result = 'win';
}
else {
stored.opponent1 = { id: null, result: 'win' };
}
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
It might be something I haven't tested yet. I'll try what you propose. Thanks for the suggestion! |
Beta Was this translation helpful? Give feedback.
-
I fixed this, in the way that I find the most appropriate. I don't want to change the way I handle forfeit input right now, this would be another feature. Moreover, a double forfeit isn't possible in elimination brackets, but it is possible in round-robin tournaments. I think you should do what is already supported: resetting results before, then set the other forfeit. So I fixed the error that You can take a look at the commit I just did, which adds a big comment about how I view forfeit working with a parent match and its child games: 89a9cd7 |
Beta Was this translation helpful? Give feedback.
I fixed this, in the way that I find the most appropriate.
I don't want to change the way I handle forfeit input right now, this would be another feature. Moreover, a double forfeit isn't possible in elimination brackets, but it is possible in round-robin tournaments.
I think you should do what is already supported: resetting results before, then set the other forfeit.
So I fixed the error that
reset.matchResults()
was throwing when a match had child games instead.You can take a look at the commit I just did, which adds a big comment about how I view forfeit working with a parent match and its child games: 89a9cd7