gameServer bugfix.

BUG: In case of all the players leave Nest server never know match ended
FIX: Now alway send matchEnd to Nest.
This commit is contained in:
LuckyLaszlo
2023-01-17 19:03:34 +01:00
parent 88188d397f
commit 1dc3ce8517

View File

@@ -80,6 +80,10 @@ export class GameSession {
s.pause(); s.pause();
if (!s.matchEnded) {
s._matchEnd(en.PlayerSide.noSide, true);
}
s.spectatorsMap.forEach((client) => { s.spectatorsMap.forEach((client) => {
clientTerminate(client); clientTerminate(client);
}); });
@@ -224,7 +228,6 @@ export class GameSession {
{ {
if (this.playersMap.size !== 2) if (this.playersMap.size !== 2)
{ {
this.matchEnded = true;
if (this.playersMap.size != 0) { if (this.playersMap.size != 0) {
this._forfeit(); this._forfeit();
} }
@@ -237,7 +240,6 @@ export class GameSession {
} }
private _forfeit() private _forfeit()
{ {
this.matchEnded = true;
console.log("Forfeit Ending"); console.log("Forfeit Ending");
const gc = this.components; const gc = this.components;
const luckyWinner: ClientPlayer = this.playersMap.values().next().value; const luckyWinner: ClientPlayer = this.playersMap.values().next().value;
@@ -307,8 +309,11 @@ export class GameSession {
if (winner === en.PlayerSide.left) { if (winner === en.PlayerSide.left) {
console.log("Player Left WIN"); console.log("Player Left WIN");
} }
else { else if (winner === en.PlayerSide.right) {
console.log("Player Right WIN"); console.log("Player Right WIN");
} }
else {
console.log("Match end Draw");
}
} }
} }