Skip to main content

Rounds et fin de partie

Endpoint proposé : /ws/game. Le backend déclenche ces notifications selon la machine à états, avec l’enveloppe commune.

Notifications de rounds​

ÉvénementDirectionFonction, comportement serveur et restrictions
round.startedServeur → ClientsAnnoncer le round préparé, les joueurs réinitialisés et state: ROUND_ONGOING ; une seule notification après la préparation.
round.endedServeur → ClientsAnnoncer le vainqueur et les équipes avec scores actualisés en ROUND_ENDING ; aucune réapparition.
match.endedServeur → ClientsAnnoncer MATCH_ENDED, vainqueur, scores et statistiques finaux après sauvegarde ; une seule finalisation par partie.

Fin du round 2 :

{
"type": "round.ended",
"matchUid": "match_123",
"roundNumber": 2,
"data": {
"state": "ROUND_ENDING",
"winnerTeamId": 1,
"teams": [
{ "teamId": 1, "color": "bleu", "players": ["alice", "bob"], "score": 2 },
{ "teamId": 2, "color": "rouge", "players": ["chloe", "david"], "score": 0 }
]
}
}

Début du round suivant, avec les quatre joueurs restaurés (HP et spawns illustratifs) :

{
"type": "round.started",
"matchUid": "match_123",
"roundNumber": 3,
"data": {
"state": "ROUND_ONGOING",
"players": [
{
"username": "alice",
"teamId": 1,
"position": { "x": 0, "y": 0, "z": 0 },
"rotation": { "x": 0, "y": 90, "z": 0 },
"hp": 100
},
{
"username": "bob",
"teamId": 1,
"position": { "x": 0, "y": 0, "z": 2 },
"rotation": { "x": 0, "y": 90, "z": 0 },
"hp": 100
},
{
"username": "chloe",
"teamId": 2,
"position": { "x": 30, "y": 0, "z": 0 },
"rotation": { "x": 0, "y": 270, "z": 0 },
"hp": 100
},
{
"username": "david",
"teamId": 2,
"position": { "x": 30, "y": 0, "z": 2 },
"rotation": { "x": 0, "y": 270, "z": 0 },
"hp": 100
}
]
}
}

Exemple indépendant de fin de partie au round 3 (ce numéro n’est pas une règle de fin) :

{
"type": "match.ended",
"matchUid": "match_123",
"roundNumber": 3,
"data": {
"state": "MATCH_ENDED",
"winnerTeamId": 1,
"teams": [
{ "teamId": 1, "color": "bleu", "players": ["alice", "bob"], "score": 3 },
{ "teamId": 2, "color": "rouge", "players": ["chloe", "david"], "score": 0 }
],
"players": [
{
"username": "alice",
"stats": { "damage": 320, "kills": 3, "deaths": 0, "matchTime": 240, "aliveTime": 240 }
},
{
"username": "bob",
"stats": { "damage": 280, "kills": 3, "deaths": 0, "matchTime": 240, "aliveTime": 240 }
},
{
"username": "chloe",
"stats": { "damage": 0, "kills": 0, "deaths": 3, "matchTime": 240, "aliveTime": 120 }
},
{
"username": "david",
"stats": { "damage": 0, "kills": 0, "deaths": 3, "matchTime": 240, "aliveTime": 180 }
}
]
}
}

winnerTeamId peut être null uniquement si une règle d’égalité ou d’interruption est définie ultérieurement.

Séquence — transitions de rounds​

Voir les statistiques et la persistance pour les compteurs finaux et la confirmation de sauvegarde.