changements pour l'env (encore) + corrections de quelques bugs dans game_server
This commit is contained in:
@@ -249,6 +249,7 @@ export class GameSession {
|
||||
this._matchEnd(en.PlayerSide.right, true);
|
||||
}
|
||||
}
|
||||
|
||||
private async _matchEnd(winner: en.PlayerSide, forfeit_flag: boolean = false)
|
||||
{
|
||||
this.matchEnded = true;
|
||||
@@ -262,6 +263,19 @@ export class GameSession {
|
||||
|
||||
// TODO: mettre à jour la route pour gerer les forfaits (actuellement le plus haut score gagne par defaut)
|
||||
const gc = this.components;
|
||||
console.log("================================= MATCH ENDED");
|
||||
if (forfeit_flag) {
|
||||
if (winner === en.PlayerSide.left)
|
||||
{
|
||||
gc.scoreLeft = 3
|
||||
gc.scoreRight = 0
|
||||
}
|
||||
else
|
||||
{
|
||||
gc.scoreLeft = 0
|
||||
gc.scoreRight = 3
|
||||
}
|
||||
}
|
||||
await fetch(c.addressBackEnd + "/game/gameserver/updategame",
|
||||
{
|
||||
method: "POST",
|
||||
|
||||
@@ -397,6 +397,7 @@ export function clientTerminate(client: Client)
|
||||
if (client.gameSession)
|
||||
{
|
||||
client.gameSession.playersMap.delete(client.id);
|
||||
client.gameSession.spectatorsMap.delete(client.id);
|
||||
if (client.gameSession.playersMap.size === 0)
|
||||
{
|
||||
client.gameSession.destroy();
|
||||
|
||||
Reference in New Issue
Block a user