예제 #1
0
        public BattleTeam(GenericReader reader)
        {
            int version = reader.ReadInt();

            PlayerStats = new List <VvVPlayerBattleStats>();

            Guild  = reader.ReadGuild() as Guild;
            Score  = reader.ReadInt();
            Silver = reader.ReadInt();

            Kills   = reader.ReadInt();
            Assists = reader.ReadInt();
            Deaths  = reader.ReadInt();
            Stolen  = reader.ReadInt();

            ViceReturned   = reader.ReadInt();
            VirtueReturned = reader.ReadInt();
            Disarmed       = reader.ReadInt();

            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                PlayerMobile         pm    = reader.ReadMobile() as PlayerMobile;
                VvVPlayerBattleStats stats = new VvVPlayerBattleStats(reader, pm);

                if (pm != null)
                {
                    PlayerStats.Add(stats);
                }
            }
        }
예제 #2
0
        public VvVPlayerBattleStats GetPlayerStats(PlayerMobile pm)
        {
            if (pm == null || pm.Guild == null)
            {
                return(null);
            }

            Guild g = pm.Guild as Guild;

            BattleTeam           team  = GetTeam(g);
            VvVPlayerBattleStats stats = team.PlayerStats.FirstOrDefault(s => s.Player == pm);

            if (stats == null)
            {
                stats = new VvVPlayerBattleStats(pm);
                team.PlayerStats.Add(stats);
            }

            return(stats);
        }
예제 #3
0
        public void Update(VvVPlayerEntry victim, VvVPlayerEntry killer, UpdateType type)
        {
            if (killer == null || killer.Player == null || killer.Guild == null)
            {
                return;
            }

            VvVPlayerBattleStats killerStats = GetPlayerStats(killer.Player);
            VvVPlayerBattleStats victimStats = victim == null ? null : GetPlayerStats(victim.Player);

            BattleTeam killerTeam = GetTeam(killer.Guild);
            BattleTeam victimTeam = null;

            if (victim != null)
            {
                victimTeam = GetTeam(victim.Guild);
            }

            switch (type)
            {
            case UpdateType.Kill:
                if (killerStats != null)
                {
                    killerStats.Kills++;
                }
                if (victimStats != null)
                {
                    victimStats.Deaths++;
                }

                if (killerTeam != null)
                {
                    killerTeam.Kills++;
                }

                if (victimTeam != null)
                {
                    victimTeam.Deaths++;
                }

                if (victim != null && victim.Player != null)
                {
                    if (!KillCooldown.ContainsKey(victim.Player) || KillCooldown[victim.Player] < DateTime.UtcNow)
                    {
                        if (killerTeam != null)
                        {
                            killerTeam.Score  += (int)KillPoints;
                            killerTeam.Silver += AwardSilver(KillSilver + (OppositionCount(killer.Guild) * 50));
                        }

                        SendStatusMessage(String.Format("{0} has killed {1}!", killer.Player.Name, victim.Player.Name));
                        KillCooldown[victim.Player] = DateTime.UtcNow + TimeSpan.FromMinutes(KillCooldownDuration);
                    }
                }

                break;

            case UpdateType.Assist:
                if (killerStats != null)
                {
                    killerStats.Assists++;
                }

                if (killerTeam != null)
                {
                    killerTeam.Assists++;
                }

                break;

            case UpdateType.Steal:
                if (killerStats != null)
                {
                    killerStats.Stolen++;
                    SendStatusMessage(String.Format("{0} has stolen the sigil!", killer.Player.Name));
                }

                if (killerTeam != null)
                {
                    killerTeam.Stolen++;
                }

                break;

            case UpdateType.TurnInVice:
            case UpdateType.TurnInVirtue:
                if (killerTeam != null)
                {
                    killerTeam.Score  += (int)TurnInPoints;
                    killerTeam.Silver += AwardSilver(TurnInSilver + (OppositionCount(killer.Guild) * 50));
                }

                if (killerStats != null && killerTeam != null)
                {
                    if (type == UpdateType.TurnInVirtue)
                    {
                        killerStats.VirtueReturned++;
                        killerTeam.VirtueReturned++;
                    }
                    else
                    {
                        killerStats.ViceReturned++;
                        killerTeam.ViceReturned++;
                    }
                }

                SendStatusMessage(String.Format("{0} has returned the sigil!", killer.Player.Name));

                NextSigilSpawn = DateTime.UtcNow + TimeSpan.FromMinutes(1);
                RemovePriests();

                break;

            case UpdateType.Disarm:
                SendStatusMessage(String.Format("{0} has disarmed a trap!", killer.Player.Name));

                if (killerStats != null)
                {
                    killerStats.Disarmed++;
                }

                if (killerTeam != null)
                {
                    killerTeam.Silver += AwardSilver(DisarmSilver + (OppositionCount(killer.Guild) * 50));
                    killerTeam.Disarmed++;
                }
                break;
            }

            CheckScore();
        }
예제 #4
0
        public void TallyStats()
        {
            BattleTeam   leader = GetLeader();
            List <Guild> added  = new List <Guild>();

            if (leader == null || leader.Guild == null)
            {
                return;
            }

            leader.Silver += AwardSilver(WinSilver + (OppositionCount(leader.Guild) * 50));

            foreach (Mobile m in Region.GetEnumeratedMobiles())
            {
                Guild g = m.Guild as Guild;

                if (g == null)
                {
                    continue;
                }

                PlayerMobile pm = m as PlayerMobile;

                if (pm != null)
                {
                    BattleTeam           team  = GetTeam(g);
                    VvVPlayerBattleStats stats = GetPlayerStats(pm);
                    VvVPlayerEntry       entry = ViceVsVirtueSystem.Instance.GetPlayerEntry <VvVPlayerEntry>(pm);

                    if (entry != null)
                    {
                        entry.Score          += team.Score;
                        entry.Points         += team.Silver;
                        entry.Kills          += stats.Kills;
                        entry.Deaths         += stats.Deaths;
                        entry.Assists        += stats.Assists;
                        entry.ReturnedSigils += stats.ReturnedSigils;
                        entry.DisarmedTraps  += stats.Disarmed;
                        entry.StolenSigils   += stats.Stolen;

                        if (added.Contains(g))
                        {
                            continue;
                        }
                        else
                        {
                            added.Add(g);
                        }

                        if (!ViceVsVirtueSystem.Instance.GuildStats.ContainsKey(g))
                        {
                            ViceVsVirtueSystem.Instance.GuildStats[g] = new VvVGuildStats(g);
                        }

                        VvVGuildStats gstats = ViceVsVirtueSystem.Instance.GuildStats[g];

                        gstats.Kills          += team.Kills;
                        gstats.ReturnedSigils += team.ReturnedSigils;
                        gstats.Score          += team.Score;
                    }
                }
            }

            ColUtility.Free(added);
        }