Exemplo n.º 1
0
 /// <summary>Enqueues players in a battleground queue.</summary>
 /// <param name="chr">the character who enqueued</param>
 /// <param name="bgId">the type of battleground</param>
 /// <param name="instanceId">the instance id of the battleground</param>
 /// <param name="asGroup">whether or not to enqueue the character or his/her group</param>
 internal static void EnqueuePlayers(Character chr, BattlegroundId bgId, uint instanceId, bool asGroup)
 {
     if (!chr.Battlegrounds.HasAvailableQueueSlots)
     {
         BattlegroundHandler.SendBattlegroundError((IPacketReceiver)chr, BattlegroundJoinError.Max3Battles);
     }
     else
     {
         if (chr.Battlegrounds.IsEnqueuedFor(bgId))
         {
             return;
         }
         BattlegroundTemplate template = BattlegroundMgr.GetTemplate(bgId);
         if (template == null)
         {
             return;
         }
         template.TryEnqueue(chr, asGroup, instanceId);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Enqueues players in a battleground queue.
        /// </summary>
        /// <param name="chr">the character who enqueued</param>
        /// <param name="bgId">the type of battleground</param>
        /// <param name="instanceId">the instance id of the battleground</param>
        /// <param name="asGroup">whether or not to enqueue the character or his/her group</param>
        internal static void EnqueuePlayers(Character chr, BattlegroundId bgId, uint instanceId, bool asGroup)
        {
            if (!chr.Battlegrounds.HasAvailableQueueSlots)
            {
                BattlegroundHandler.SendBattlegroundError(chr, BattlegroundJoinError.Max3Battles);
                return;
            }
            // cannot enqueue twice for the same bg
            if (chr.Battlegrounds.IsEnqueuedFor(bgId))
            {
                return;
            }

            var template = GetTemplate(bgId);

            // TODO: Is Character just updating an existing queue slot?
            if (template != null)
            {
                template.TryEnqueue(chr, asGroup, instanceId);
            }
        }
Exemplo n.º 3
0
        public ICharacterSet GetCharacterSet(Character chr, bool asGroup)
        {
            if (asGroup)
            {
                Group group = chr.Group;
                if (group == null || !group.IsLeader(chr))
                {
                    GroupHandler.SendResult((IPacketReceiver)chr, GroupResult.DontHavePermission);
                }
                else
                {
                    Character[] allCharacters = group.GetAllCharacters();
                    if (allCharacters.Length == 0)
                    {
                        return((ICharacterSet)chr);
                    }
                    if (allCharacters.Length > this._parentQueue.Template.MaxPlayersPerTeam)
                    {
                        BattlegroundHandler.SendBattlegroundError((IPacketReceiver)chr,
                                                                  BattlegroundJoinError.GroupJoinedNotEligible);
                        return((ICharacterSet)null);
                    }

                    foreach (Character character in allCharacters)
                    {
                        if (character != null && character.Battlegrounds.IsDeserter)
                        {
                            BattlegroundHandler.SendBattlegroundError((IPacketReceiver)group,
                                                                      BattlegroundJoinError.Deserter);
                            return((ICharacterSet)null);
                        }
                    }

                    SynchronizedCharacterList synchronizedCharacterList =
                        new SynchronizedCharacterList(this.Side.GetFactionGroup());
                    foreach (Character chr1 in allCharacters)
                    {
                        if (chr1.IsInWorld && (chr1.GodMode || this._parentQueue.CanEnter(chr1)))
                        {
                            synchronizedCharacterList.Add(chr1);
                        }
                        else
                        {
                            BattlegroundHandler.SendBattlegroundError((IPacketReceiver)chr1,
                                                                      BattlegroundJoinError.GroupJoinedNotEligible);
                        }
                    }

                    return((ICharacterSet)synchronizedCharacterList);
                }
            }
            else
            {
                if (!chr.Battlegrounds.IsDeserter)
                {
                    return((ICharacterSet)chr);
                }
                BattlegroundHandler.SendBattlegroundError((IPacketReceiver)chr, BattlegroundJoinError.Deserter);
            }

            return((ICharacterSet)null);
        }
Exemplo n.º 4
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                var err = trigger.Text.NextEnum(BattlegroundJoinError.None);

                BattlegroundHandler.SendBattlegroundError(trigger.Args.Character, err);
            }
Exemplo n.º 5
0
        public ICharacterSet GetCharacterSet(Character chr, bool asGroup)
        {
            // we are working with a non-synchronized Character object here
            if (asGroup)
            {
                var group = chr.Group;
                if (group == null || !group.IsLeader(chr))
                {
                    // invalid request
                    GroupHandler.SendResult(chr, GroupResultType.Swap, GroupResult.DontHavePermission);
                }
                else
                {
                    var chrs = group.GetAllCharacters();

                    // if no characters in the group, return the original character
                    if (chrs.Length == 0)
                    {
                        return(chr);
                    }

                    // make sure the group isn't bigger than the max team size for this BG
                    if (chrs.Length > _parentQueue.Template.MaxPlayersPerTeam)
                    {
                        BattlegroundHandler.SendBattlegroundError(chr, BattlegroundJoinError.GroupJoinedNotEligible);
                        return(null);
                    }

                    // make sure there are no deserters
                    foreach (Character groupChr in chrs)
                    {
                        if (groupChr != null && groupChr.Battlegrounds.IsDeserter)
                        {
                            BattlegroundHandler.SendBattlegroundError(group, BattlegroundJoinError.Deserter);
                            return(null);
                        }
                    }

                    var list = new SynchronizedCharacterList(Side.GetFactionGroup());

                    foreach (var groupChr in chrs)
                    {
                        if (groupChr.IsInWorld && (groupChr.GodMode || _parentQueue.CanEnter(groupChr)))
                        {
                            list.Add(groupChr);
                        }
                        else
                        {
                            // cannot join the same team
                            BattlegroundHandler.SendBattlegroundError(groupChr, BattlegroundJoinError.GroupJoinedNotEligible);
                        }
                    }

                    return(list);
                }
            }
            else
            {
                // enqueue the character if they aren't a deserter
                if (!chr.Battlegrounds.IsDeserter)
                {
                    return(chr);
                }

                BattlegroundHandler.SendBattlegroundError(chr, BattlegroundJoinError.Deserter);
            }

            return(null);
        }