diff --git a/gameserver/commands/OnLeaveCommand.ts b/gameserver/commands/OnLeaveCommand.ts index 0aed803..4dcd03b 100644 --- a/gameserver/commands/OnLeaveCommand.ts +++ b/gameserver/commands/OnLeaveCommand.ts @@ -7,6 +7,5 @@ export class OnLeaveCommand extends Command { execute({ client, message, gameManager }: CommandPayload) { const sessionId = client.sessionId; this.state.removePlayer(sessionId, gameManager!); - this.state.tilemap.updateOwnershipMap(this.state.getPlayers()); } } diff --git a/public/scenes/GameScene.ts b/public/scenes/GameScene.ts index 8bfef3f..107de7d 100644 --- a/public/scenes/GameScene.ts +++ b/public/scenes/GameScene.ts @@ -703,9 +703,9 @@ export class GameScene extends BaseScene { `obj_captureFlag_${player.id}_${newFlag.id}` ); if (!flag) return; - this.DestroyObjectById(`obj_captureFlag_${player.id}_${newFlag.id}`); + this.DestroyObjectById(`obj_captureFlag_${player.id}_${flag.id}`); this.DestroyStateChangeListener( - `statechange_captureFlag_${player.id}_${newFlag.id}` + `statechange_captureFlag_${player.id}_${flag.id}` ); }) ); @@ -714,10 +714,10 @@ export class GameScene extends BaseScene { this.AddStateChangeListener( state.players.onRemove((player) => { const kingdomId = `obj_playerCastle_${player.id}`; + this.DestroyObjectById(kingdomId); this.events.emit(PacketType.ByServer.PLAYER_LEFT, { playerState: player, }); - this.DestroyObjectById(kingdomId); }) ); diff --git a/public/scenes/PlayerStatisticHUD.ts b/public/scenes/PlayerStatisticHUD.ts index d2befc7..4bd231a 100644 --- a/public/scenes/PlayerStatisticHUD.ts +++ b/public/scenes/PlayerStatisticHUD.ts @@ -9,6 +9,7 @@ import { NetworkManager } from "../NetworkManager"; import { PlayerState } from "../../gameserver/schema/PlayerState"; import { Spearman } from "../soldiers/Spearman"; import CONSTANTS from "../constant"; +import { CaptureFlag } from "../gameObjects/CaptureFlag"; const textStyle: Phaser.Types.GameObjects.Text.TextStyle = { color: "#fff", @@ -198,6 +199,11 @@ export class PlayerStatisticHUD extends BaseScene { gameScene.onSoldierRemoved(soldier.id, playerObject.id); }); + const captureFlags = gameScene.GetObjectsWithKeyPrefix( + `obj_captureFlag_${playerObject.id}` + ); + captureFlags.forEach((flag) => flag.destroy(true)); + soldierCount.setText( `Total Soldiers: ${[...state.players.values()].reduce((acc, curr) => { acc = acc + curr.soldiers.size;