/* * Copyright (C) 2012-2020 CypherCore * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ using Framework.Constants; using Game.BattleFields; using Game.Networking.Packets; namespace Game { public partial class WorldSession { /// /// This send to player windows for invite player to join the war. /// /// The queue id of Bf /// The zone where the battle is (4197 for wg) /// Time in second that the player have for accept public void SendBfInvitePlayerToWar(ulong queueId, uint zoneId, uint acceptTime) { BFMgrEntryInvite bfMgrEntryInvite = new(); bfMgrEntryInvite.QueueID = queueId; bfMgrEntryInvite.AreaID = (int)zoneId; bfMgrEntryInvite.ExpireTime = GameTime.GetGameTime() + acceptTime; SendPacket(bfMgrEntryInvite); } /// /// This send invitation to player to join the queue. /// /// The queue id of Bf /// Battlefield State public void SendBfInvitePlayerToQueue(ulong queueId, BattlefieldState battleState) { BFMgrQueueInvite bfMgrQueueInvite = new(); bfMgrQueueInvite.QueueID = queueId; bfMgrQueueInvite.BattleState = battleState; SendPacket(bfMgrQueueInvite); } /// /// This send packet for inform player that he join queue. /// /// The queue id of Bf /// The zone where the battle is (4197 for wg) /// Battlefield status /// if able to queue /// on log in send queue status public void SendBfQueueInviteResponse(ulong queueId, uint zoneId, BattlefieldState battleStatus, bool canQueue = true, bool loggingIn = false) { BFMgrQueueRequestResponse bfMgrQueueRequestResponse = new(); bfMgrQueueRequestResponse.QueueID = queueId; bfMgrQueueRequestResponse.AreaID = (int)zoneId; bfMgrQueueRequestResponse.Result = (sbyte)(canQueue ? 1 : 0); bfMgrQueueRequestResponse.BattleState = battleStatus; bfMgrQueueRequestResponse.LoggingIn = loggingIn; SendPacket(bfMgrQueueRequestResponse); } /// /// This is call when player accept to join war. /// /// The queue id of Bf /// Whether player is added to Bf on the spot or teleported from queue /// Whether player belongs to attacking team or not public void SendBfEntered(ulong queueId, bool relocated, bool onOffense) { BFMgrEntering bfMgrEntering = new(); bfMgrEntering.ClearedAFK = _player.IsAFK(); bfMgrEntering.Relocated = relocated; bfMgrEntering.OnOffense = onOffense; bfMgrEntering.QueueID = queueId; SendPacket(bfMgrEntering); } /// /// This is call when player leave battlefield zone. /// /// The queue id of Bf /// Battlefield status /// Whether player is added to Bf on the spot or teleported from queue /// Reason why player left battlefield public void SendBfLeaveMessage(ulong queueId, BattlefieldState battleState, bool relocated, BFLeaveReason reason = BFLeaveReason.Exited) { BFMgrEjected bfMgrEjected = new(); bfMgrEjected.QueueID = queueId; bfMgrEjected.Reason = reason; bfMgrEjected.BattleState = battleState; bfMgrEjected.Relocated = relocated; SendPacket(bfMgrEjected); } /// /// Send by client on clicking in accept or refuse of invitation windows for join game. /// //[WorldPacketHandler(ClientOpcodes.BfMgrEntryInviteResponse)] void HandleBfEntryInviteResponse(BFMgrEntryInviteResponse bfMgrEntryInviteResponse) { BattleField bf = Global.BattleFieldMgr.GetBattlefieldByQueueId(bfMgrEntryInviteResponse.QueueID); if (bf == null) return; // If player accept invitation if (bfMgrEntryInviteResponse.AcceptedInvite) { bf.PlayerAcceptInviteToWar(GetPlayer()); } else { if (GetPlayer().GetZoneId() == bf.GetZoneId()) bf.KickPlayerFromBattlefield(GetPlayer().GetGUID()); } } /// /// Send by client when he click on accept for queue. /// //[WorldPacketHandler(ClientOpcodes.BfMgrQueueInviteResponse)] void HandleBfQueueInviteResponse(BFMgrQueueInviteResponse bfMgrQueueInviteResponse) { BattleField bf = Global.BattleFieldMgr.GetBattlefieldByQueueId(bfMgrQueueInviteResponse.QueueID); if (bf == null) return; if (bfMgrQueueInviteResponse.AcceptedInvite) bf.PlayerAcceptInviteToQueue(GetPlayer()); } /// /// Send by client when exited battlefield /// //[WorldPacketHandler(ClientOpcodes.BfMgrQueueExitRequest)] void HandleBfExitRequest(BFMgrQueueExitRequest bfMgrQueueExitRequest) { BattleField bf = Global.BattleFieldMgr.GetBattlefieldByQueueId(bfMgrQueueExitRequest.QueueID); if (bf == null) return; bf.AskToLeaveQueue(GetPlayer()); } } }