diff --git a/extensions/battleroyale/standalone.mjs b/extensions/battleroyale/standalone.mjs index 23b476ed..83ad9aa2 100644 --- a/extensions/battleroyale/standalone.mjs +++ b/extensions/battleroyale/standalone.mjs @@ -367,7 +367,19 @@ class Standalone { // No location? Just skip. return; } - + if (msg.removed) { + console.log(`${playerID} disconnect`) + // player disconnect, remove player if exists + if (this.participatePlayerIDs.has(playerID)) { + this.participatePlayerIDs.delete(playerID); + } + if (this.playerOldPosition.has(playerID)) { + this.playerOldPosition.delete(playerID); + } + if (this.participatePlayerIDs.size <= 1) { + await this.terminateGame(); + } + } const bullets = this.helper.gameMap.getCell(mapCoord, LAYER_BULLET.layerName); if (bullets) { await this.killPlayer(playerID); diff --git a/extensions/bombman/standalone.mjs b/extensions/bombman/standalone.mjs index a53b1ac0..8ffd72d5 100644 --- a/extensions/bombman/standalone.mjs +++ b/extensions/bombman/standalone.mjs @@ -273,6 +273,20 @@ class Standalone { // No location? Just skip. return; } + + if (msg.removed) { + // player disconnect, remove player if exists + if (this.participatePlayerIDs.has(playerID)) { + this.participatePlayerIDs.delete(playerID); + } + if (this.playerOldPosition.has(playerID)) { + this.playerOldPosition.delete(playerID); + } + if (this.participatePlayerIDs.size <= 1) { + await this.terminateGame(); + } + } + const explodeCell = this.helper.gameMap.getCell(mapCoord, LAYER_BOMB_EXPLODE.layerName); if (explodeCell) { // if walk into bomb => teleport to somewhere await this.killPlayer(playerID);