ghamry03 / ft_transcendence

0 stars 0 forks source link

No Winner For Game #30

Closed karimomino closed 7 months ago

karimomino commented 7 months ago

If a game starts between 2 players (online game), and one player leaves as soon as the game starts.

Expected behavior:

Actual behavior:

[ { "game_id": 1, "my_score": 0, "opponents": [ { "opponent_id": 88336, "opponent_score": 0, "opponent_image_url": null } ], "timePassed": "20 seconds" } ]

this is the game record after the match has ended. Since no one scored before the user left, both players have the same score and so we are unable to identify the winner based on this response.

this response came from the endpoint game/matchhistory/88507

lde-alen commented 7 months ago

@karimomino I will look into the details of all these and see if I can fix once I am done doing uat part, I wanna avoid touching code during uat.

@MehrinFirdousi if there is a way to know which player disconnected then we could cover the winner / loser situation. If not maybe we could consider putting both as "canceled" or maybe implement "draw" or "tie" for the cases where someone disconnects. For the sake of time and to avoid too many changes in the UIs I think the easiest and fastest one would be to just add a case for when no one has scored yet.

Two things to consider tho in these cases:

  1. We are saving this game but since there is no winner/loser or the game has no score should we really display it on the match history? for changes purposes I would recommend not to add it to the history because then we need to do changes on the ui, very minor but still changes.
  2. If we decide to display it to the end user then we need to add an other color for the history, UX wise color should be gray and not green or red.

PS: Keep in mind that, if this happens in a tournament then the behavior should be different. The person who remained must be a winner and the one who disconnected must be a loser because the tournament cannot be in a stall state and someone must move to the next bracket.

@karimomino can you test that in the tournament please, that scenario is covered in the uat but this could add more insights on how @MehrinFirdousi should / would cater for this case and potentially implement something that applies for both game + tournament?

MehrinFirdousi commented 7 months ago

@lde-alen This case is handled in the tournament by assigning the WIN_SCORE to the person who stayed connected and the tournament will proceed. Will add the same logic to the game as well so there's a winner always.

@karimomino To confirm, not just 0-0 but even 2-2, or any "draw" score for that matter wouldn't work, yes?

lde-alen commented 7 months ago

Yeah that is fine It was just to avoid the issue but I also remember that you did add that for the tournament. If the the exact same behavior can be done for the normal game that is perfect so we keep an unified behavior. Thanks @MehrinFirdousi