Ejemplo n.º 1
0
 public virtual IEnumerable <PlayerMobile> GetQueued(PvPTeam team)
 {
     foreach (var kvp in Queue.Where(kvp => kvp.Value == team))
     {
         yield return(kvp.Key);
     }
 }
Ejemplo n.º 2
0
 public virtual void TeamEject(PvPTeam team)
 {
     if (team != null && !team.Deleted)
     {
         team.ForEachMember(member => team.RemoveMember(member, true));
     }
 }
Ejemplo n.º 3
0
 public void ResetStatistics(PvPTeam t)
 {
     if (t != null)
     {
         t.Statistics.Clear();
     }
 }
Ejemplo n.º 4
0
        public bool UpdateStatistics(PvPTeam t, PlayerMobile pm, Action <PvPProfileHistoryEntry> update)
        {
            if (t == null || t.Deleted || pm == null || update == null)
            {
                return(false);
            }

            var s = t.GetStatistics(pm);

            if (s == null)
            {
                return(false);
            }

            var success = true;

            VitaNexCore.TryCatch(
                update,
                s,
                x =>
            {
                AutoPvP.CMOptions.ToConsole(x);
                success = false;
            });

            if (t.IsMember(pm))
            {
                t.UpdateActivity(pm);
            }

            return(success);
        }
Ejemplo n.º 5
0
 private void TransferStatistics(PvPTeam t)
 {
     if (t != null)
     {
         t.Statistics.ForEachReverse(o => TransferStatistics(o.Key, o.Value));
     }
 }
Ejemplo n.º 6
0
        public virtual void OnTeamMemberDeath(PvPTeam team, PlayerMobile pm)
        {
            LocalBroadcast("{0} has died.", pm.RawName);

            UpdateStatistics(team, pm, s => ++ s.Deaths);

            var pk = pm.FindMostRecentDamager(false) as PlayerMobile;

            if (pk != null && !pk.Deleted)
            {
                PvPTeam pkt;

                if (IsParticipant(pk, out pkt))
                {
                    if (KillPoints > 0 && !pk.Account.IsSharedWith(pm.Account))
                    {
                        RevokePoints(pm, KillPoints);
                    }

                    pm.LastKiller = pk;

                    UpdateStatistics(pkt, pk, s => ++ s.Kills);

                    if (KillPoints > 0 && !pk.Account.IsSharedWith(pm.Account))
                    {
                        AwardPoints(pk, KillPoints);
                    }
                }
            }

            TeleportToHomeBase(team, pm);
        }
Ejemplo n.º 7
0
 public virtual void TeleportToSpawnPoint(PvPTeam team, PlayerMobile pm)
 {
     if (pm != null && !pm.Deleted && team != null && !team.Deleted && team.IsMember(pm))
     {
         Teleport(pm, team.SpawnPoint, Options.Locations.Map);
     }
 }
Ejemplo n.º 8
0
        public virtual void Enqueue(PlayerMobile pm, PvPTeam team = null, bool party = true)
        {
            if (pm == null || pm.Deleted)
            {
                return;
            }

            if (!CanQueue(pm))
            {
                OnQueueReject(pm);
                return;
            }

            if (team != null && team.Deleted)
            {
                team = null;
            }

            if (!IsQueued(pm))
            {
                Queue.Add(pm, team);
                OnQueueJoin(pm, team);
            }
            else
            {
                Queue[pm] = team;
                OnQueueUpdate(pm, team);
            }

            if (party)
            {
                EnqueueParty(pm, Party.Get(pm), team);
            }
        }
Ejemplo n.º 9
0
        public virtual int CompareTeamRank(PvPTeam a, PvPTeam b)
        {
            int result = 0;

            if (a.CompareNull(b, ref result))
            {
                return(result);
            }

            if (a.Deleted && b.Deleted)
            {
                return(0);
            }

            if (b.Deleted)
            {
                return(-1);
            }

            if (a.Deleted)
            {
                return(1);
            }

            int retVal = a.Statistics.TotalKills.CompareTo(b.Statistics.TotalKills);

            return(retVal < 0 ? 1 : (retVal > 0 ? -1 : retVal));
        }
Ejemplo n.º 10
0
        public virtual void TeleportToSpawnPoint(PvPTeam team, PlayerMobile pm)
        {
            if (pm == null || pm.Deleted || team == null || team.Deleted || !team.IsMember(pm))
            {
                return;
            }

            var p = team.SpawnPoint;

            if (team.RespawnRangeMin > 0 && team.RespawnRangeMax > 0)
            {
                var i = 10;

                while (--i >= 0)
                {
                    p = team.SpawnPoint.GetRandomPoint3D(team.RespawnRangeMin, team.RespawnRangeMax);

                    if (Options.Locations.Map.CanSpawnMobile(p))
                    {
                        break;
                    }
                }

                if (i < 0)
                {
                    p = team.SpawnPoint;
                }
            }

            Teleport(pm, p, Options.Locations.Map);
        }
Ejemplo n.º 11
0
 public virtual void TeamRespawn(PvPTeam team)
 {
     if (team != null && !team.Deleted)
     {
         team.ForEachMember(team.Respawn);
     }
 }
Ejemplo n.º 12
0
 public void PlaySound(PvPTeam t, int soundID)
 {
     if (Options.Sounds.Enabled && t != null && !t.Deleted && soundID > 0)
     {
         t.PlaySound(soundID);
     }
 }
Ejemplo n.º 13
0
 public virtual void TeleportToHomeBase(PvPTeam team, PlayerMobile pm)
 {
     if (pm != null && !pm.Deleted && team != null && !team.Deleted)
     {
         Teleport(pm, team.HomeBase, Options.Locations.Map);
     }
 }
Ejemplo n.º 14
0
 public void ResetTeam(PvPTeam team)
 {
     if (team != null && !team.Deleted)
     {
         team.Reset();
     }
 }
Ejemplo n.º 15
0
 public virtual void RevokeTeamPoints(PvPTeam team)
 {
     if (team != null)
     {
         team.ForEachMember(pm => UpdateStatistics(team, pm, o => o.PointsLost += GetAwardPoints(team, pm)));
     }
 }
Ejemplo n.º 16
0
 public static void InvokeQueueUpdate(PvPBattle battle, PvPTeam team, PlayerMobile m)
 {
     if (OnQueueUpdate != null)
     {
         OnQueueUpdate(battle, team, m);
     }
 }
Ejemplo n.º 17
0
 public virtual void AwardTeamPoints(PvPTeam team, int points)
 {
     if (team != null && points > 0)
     {
         team.ForEachMember(pm => UpdateStatistics(team, pm, o => o.PointsGained += points));
     }
 }
Ejemplo n.º 18
0
        public virtual void OnTeamMemberDeath(PvPTeam team, PlayerMobile pm)
        {
            LocalBroadcast("{0} has died.", pm.RawName);

            EnsureStatistics(pm).Deaths++;

            /*if (KillPoints > 0)
             * {
             *      RevokePoints(pm, KillPoints);
             * }*/

            PlayerMobile pk = pm.FindMostRecentDamager(false) as PlayerMobile;

            if (pk != null && !pk.Deleted && IsParticipant(pk))
            {
                pm.LastKiller = pk;
                EnsureStatistics(pk).Kills++;

                if (KillPoints > 0 && pk.IsOnline() && pm.IsOnline() && pk.NetState.Address != pm.NetState.Address)
                {
                    AwardPoints(pk, KillPoints);
                }
            }

            TeleportToHomeBase(team, pm);
        }
Ejemplo n.º 19
0
        public double ComputeScorePotential(PvPTeam t)
        {
            double min = 0, max = 0, total = 0;

            ComputeScore(t, ref min, ref max, ref total);

            return(total);
        }
Ejemplo n.º 20
0
        public virtual double GetAssignPriority(PvPTeam team)
        {
            double weight;

            CalculateAssignPriority(team, out weight);

            return(weight);
        }
Ejemplo n.º 21
0
        public virtual string GetStatus(PvPTeam team)
        {
            if (!Enabled || Team.IsEmpty)
            {
                return(String.Empty);
            }

            return(Team.GetStatus(team));
        }
Ejemplo n.º 22
0
        public virtual double ComputeScore(PvPTeam team)
        {
            if (!Enabled || Team.IsEmpty)
            {
                return(0);
            }

            return(Team.ComputeScore(team));
        }
Ejemplo n.º 23
0
        public virtual int GetAwardPoints(PvPTeam team, PlayerMobile pm)
        {
            if (!IsRunning || team == null || team.Deleted || (pm != null && !team.IsMember(pm)))
            {
                return(0);
            }

            return(PointsBase);
        }
Ejemplo n.º 24
0
        protected double GetMissionsScore(PvPTeam team)
        {
            if (team != null)
            {
                return(team.GetMissionsScore());
            }

            return(0);
        }
Ejemplo n.º 25
0
        public virtual bool Completed(PvPTeam team)
        {
            if (!Enabled || Team.IsEmpty)
            {
                return(false);
            }

            return(Team.Completed(team));
        }
Ejemplo n.º 26
0
 public virtual void EnqueueParty(PlayerMobile pm, Party party, PvPTeam team = null)
 {
     if (pm != null && !pm.Deleted && party != null && party.Active && party.Leader == pm)
     {
         party.Members.Where(pmi => pmi != null && pmi.Mobile != null && !pmi.Mobile.Deleted && pmi.Mobile != pm)
         .Select(pmi => (PlayerMobile)pmi.Mobile)
         .ForEach(m => Enqueue(m, team, false));
     }
 }
Ejemplo n.º 27
0
        public virtual void OnTeamMemberAdded(PvPTeam team, PlayerMobile pm)
        {
            team.Broadcast("{0} has joined the battle.", pm.RawName);

            if (UseTeamColors)
            {
                pm.SolidHueOverride = team.Color;
            }
        }
Ejemplo n.º 28
0
        public bool RemoveTeam(PvPTeam team)
        {
            if (ContainsTeam(team) && Teams.Remove(team))
            {
                OnTeamRemoved(team);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 29
0
        public virtual void TeamWinEject(PvPTeam team)
        {
            if (team == null || team.Deleted)
            {
                return;
            }

            OnTeamWin(team);
            team.ForEachMember(pm => team.RemoveMember(pm, true));
        }
Ejemplo n.º 30
0
        public virtual void TeamLoseEject(PvPTeam team)
        {
            if (team == null || team.Deleted)
            {
                return;
            }

            OnTeamLose(team);
            team.ForEachMember(member => team.RemoveMember(member, true));
        }