Example #1
0
        private static void OnEnhancedRulesEnabled()
        {
            if (Instance == null || !Enabled)
            {
                return;
            }

            Timer.DelayCall(TimeSpan.FromSeconds(1), () =>
            {
                foreach (PlayerMobile pm in World.Mobiles.Values.OfType <PlayerMobile>().Where(pm => IsVvV(pm)))
                {
                    VvVPlayerEntry entry = Instance.GetPlayerEntry <VvVPlayerEntry>(pm);

                    if (entry != null)
                    {
                        if (ShowNewRules == null)
                        {
                            ShowNewRules = new List <PlayerMobile>();
                        }

                        ShowNewRules.Add(pm);
                    }
                }
            });
        }
Example #2
0
        public void Update(Mobile m, UpdateType type)
        {
            VvVPlayerEntry entry = System.GetPlayerEntry <VvVPlayerEntry>(m);

            if (entry != null)
            {
                Update(null, entry, type);
            }
        }
Example #3
0
        public void HandlePlayerDeath(PlayerMobile victim)
        {
            VvVPlayerEntry ventry = GetPlayerEntry <VvVPlayerEntry>(victim);

            if (ventry != null && ventry.Active)
            {
                List <DamageEntry> list    = victim.DamageEntries.OrderBy(d => - d.DamageGiven).ToList();
                List <Mobile>      handled = new List <Mobile>();
                bool statloss = false;

                for (int i = 0; i < list.Count; i++)
                {
                    Mobile dam = list[i].Damager;

                    if (dam is BaseCreature && ((BaseCreature)dam).GetMaster() is PlayerMobile)
                    {
                        dam = ((BaseCreature)dam).GetMaster();
                    }

                    bool isEnemy = IsEnemy(victim, dam);

                    if (isEnemy && dam != null && Battle.IsInActiveBattle(dam, victim))
                    {
                        VvVPlayerEntry kentry = GetPlayerEntry <VvVPlayerEntry>(dam);

                        if (kentry != null && !handled.Contains(dam))
                        {
                            if (i == 0)
                            {
                                Battle.Update(ventry, kentry, UpdateType.Kill);
                            }
                            else
                            {
                                Battle.Update(ventry, kentry, UpdateType.Assist);
                            }

                            handled.Add(dam);
                        }
                    }

                    if (!statloss && isEnemy)
                    {
                        statloss = true;
                    }
                }

                if (statloss)
                {
                    Faction.ApplySkillLoss(victim);
                }

                ColUtility.Free(list);
                ColUtility.Free(handled);
            }
        }
Example #4
0
        public void CheckPendingJoin(PlayerMobile pm)
        {
            VvVPlayerEntry entry = GetPlayerEntry <VvVPlayerEntry>(pm);

            if (entry != null && entry.PendingJoinMessage)
            {
                pm.SendLocalizedMessage(1155564);                                                        // You have joined Vice vs Virtue!
                pm.SendLocalizedMessage(1063156, entry.Guild != null ? entry.Guild.Name : "your guild"); // The guild information for ~1_val~ has been updated.

                entry.PendingJoinMessage = false;
            }
        }
Example #5
0
        public void CheckResignation(PlayerMobile pm)
        {
            VvVPlayerEntry entry = GetPlayerEntry <VvVPlayerEntry>(pm);

            if (entry != null && entry.Resigning && entry.ResignExpiration < DateTime.UtcNow)
            {
                pm.PrivateOverheadMessage(MessageType.Regular, 1154, 1155561, pm.NetState); // You are no longer in Vice vs Virtue!

                entry.Active           = false;
                entry.ResignExpiration = DateTime.MinValue;
                pm.Delta(MobileDelta.Noto);
            }
        }
Example #6
0
        public void OnStolen(VvVPlayerEntry entry)
        {
            if (Battle != null && RootParentEntity == null)
            {
                Battle.SpawnPriests();
                Battle.Update(null, entry, UpdateType.Steal);

                LastStolen   = DateTime.UtcNow;
                HomeLocation = Location;

                Movable = true;
            }
        }
Example #7
0
        public static bool IsVvV(Mobile m, bool checkpet = true)
        {
            if (m is BaseCreature && checkpet)
            {
                if (((BaseCreature)m).GetMaster() is PlayerMobile)
                {
                    m = ((BaseCreature)m).GetMaster();
                }
            }

            VvVPlayerEntry entry = Instance.GetPlayerEntry <VvVPlayerEntry>(m as PlayerMobile);

            return(entry != null && entry.Active);
        }
Example #8
0
        public void OnRemovedFromGuild(Mobile m)
        {
            VvVPlayerEntry entry = GetPlayerEntry <VvVPlayerEntry>(m as PlayerMobile);

            if (entry != null)
            {
                if (m.AccessLevel == AccessLevel.Player)
                {
                    entry.ResignExpiration = DateTime.UtcNow + TimeSpan.FromDays(3);
                }
                else
                {
                    entry.ResignExpiration = DateTime.UtcNow;
                }
            }
        }
Example #9
0
        public int EnemyGuildCount(Mobile exclude = null)
        {
            List <Guild> guilds = new List <Guild>();

            foreach (NetState ns in NetState.Instances)
            {
                Mobile m = ns.Mobile;

                if (exclude != null && exclude == m)
                {
                    continue;
                }

                if (m != null)
                {
                    Guild          g     = m.Guild as Guild;
                    VvVPlayerEntry entry = GetPlayerEntry <VvVPlayerEntry>(m);

                    if (g != null && entry != null && entry.Guild == g && !guilds.Contains(g))
                    {
                        bool hasally = false;

                        foreach (Guild guild in guilds)
                        {
                            if (guild.IsAlly(g))
                            {
                                hasally = true;
                                break;
                            }
                        }

                        if (!hasally)
                        {
                            guilds.Add(g);
                        }
                    }
                }
            }

            int count = guilds.Count;

            guilds.Clear();
            guilds.TrimExcess();

            return(count);
        }
Example #10
0
        public static bool IsEnemy(Mobile from, Mobile to)
        {
            if (!Enabled || from == to)
            {
                return(false);
            }

            //TODO: Support for VvV city games regarding non-participants in the city, as well as ones who flagged
            if (from is BaseCreature && ((BaseCreature)from).GetMaster() is PlayerMobile)
            {
                from = ((BaseCreature)from).GetMaster();
            }

            if (to is BaseCreature && ((BaseCreature)to).GetMaster() is PlayerMobile)
            {
                to = ((BaseCreature)to).GetMaster();
            }

            if (from == to)
            {
                return(false);
            }

            VvVPlayerEntry fromentry = Instance.GetPlayerEntry <VvVPlayerEntry>(from);
            VvVPlayerEntry toentry   = Instance.GetPlayerEntry <VvVPlayerEntry>(to);

            if (fromentry == null || toentry == null || !fromentry.Active || !toentry.Active)
            {
                if (fromentry != null && toentry == null && FlaggedTo != null && FlaggedTo.ContainsKey(from) && FlaggedTo[from] == to)
                {
                    return(true);
                }

                return(false);
            }

            Guild fromguild = fromentry.Guild;
            Guild toguild   = toentry.Guild;

            if (toguild == null || fromguild == null)
            {
                return(true);
            }

            return(fromguild != toguild && !fromguild.IsAlly(toguild));
        }
Example #11
0
        public int EnemyGuildCount()
        {
            List <Guild> guilds = new List <Guild>();

            for (var index = 0; index < NetState.Instances.Count; index++)
            {
                NetState ns = NetState.Instances[index];

                Mobile m = ns.Mobile;

                if (m != null)
                {
                    Guild          g     = m.Guild as Guild;
                    VvVPlayerEntry entry = GetPlayerEntry <VvVPlayerEntry>(m);

                    if (g != null && entry != null && entry.Guild == g && !guilds.Contains(g))
                    {
                        bool hasAlly = false;

                        for (var i = 0; i < guilds.Count; i++)
                        {
                            Guild guild = guilds[i];

                            if (guild.IsAlly(g))
                            {
                                hasAlly = true;
                                break;
                            }
                        }

                        if (!hasAlly)
                        {
                            guilds.Add(g);
                        }
                    }
                }
            }

            int count = guilds.Count;

            guilds.Clear();
            guilds.TrimExcess();

            return(count - 1);
        }
        public static bool IsVvV(Mobile m, out VvVPlayerEntry entry, bool checkpet = true, bool guildedonly = false)
        {
            if (m is BaseCreature && checkpet)
            {
                if (((BaseCreature)m).GetMaster() is PlayerMobile)
                {
                    m = ((BaseCreature)m).GetMaster();
                }
            }

            entry = Instance.GetPlayerEntry <VvVPlayerEntry>(m as PlayerMobile);

            if (entry != null && !entry.Active)
            {
                entry = null;
            }

            return(entry.Active && (!guildedonly || entry.Guild != null));
        }
Example #13
0
        public override bool OnDragDrop(Mobile from, Item dropped)
        {
            if (ViceVsVirtueSystem.Instance == null || Battle == null)
            {
                return(false);
            }

            VvVPlayerEntry entry = ViceVsVirtueSystem.Instance.GetPlayerEntry <VvVPlayerEntry>(from);

            if (from.InRange(Location, 2) && entry != null && ViceVsVirtueSystem.IsVvV(from) && dropped is VvVSigil sigil)
            {
                Battle.Update(null, entry, VvVType == VvVType.Vice ? UpdateType.TurnInVice : UpdateType.TurnInVirtue);

                sigil.Delete();
                Battle.Sigil = null;
            }

            return(false);
        }
Example #14
0
        public void AddPlayer(PlayerMobile pm)
        {
            if (pm == null || pm.Guild == null)
            {
                return;
            }

            Guild          g     = pm.Guild as Guild;
            VvVPlayerEntry entry = GetEntry(pm, true) as VvVPlayerEntry;

            entry.Active = true;

            pm.SendLocalizedMessage(1155564);         // You have joined Vice vs Virtue!
            pm.SendLocalizedMessage(1063156, g.Name); // The guild information for ~1_val~ has been updated.

            pm.ProcessDelta();

            CheckBattleStatus(pm);
        }
Example #15
0
        public void OnResign(Mobile m, bool quitguild = false)
        {
            VvVPlayerEntry entry = GetPlayerEntry <VvVPlayerEntry>(m as PlayerMobile);

            if (entry != null && entry.Active && !entry.Resigning)
            {
                if (m.AccessLevel == AccessLevel.Player)
                {
                    entry.ResignExpiration = DateTime.UtcNow + TimeSpan.FromDays(3);
                }
                else
                {
                    entry.ResignExpiration = DateTime.UtcNow + TimeSpan.FromMinutes(1);
                }

                if (quitguild)
                {
                    m.SendLocalizedMessage(1155580); // You have quit a guild while participating in Vice vs Virtue.  You will be freely attackable by members of Vice vs Virtue until your resignation period has ended!
                }
            }
        }
Example #16
0
        public static bool IsVvV(Mobile m, bool checkpet = true, bool guildedonly = false)
        {
            if (!Enabled)
            {
                return(false);
            }

            if (m is BaseCreature creature && checkpet && creature.GetMaster() is PlayerMobile)
            {
                m = creature.GetMaster();
            }

            VvVPlayerEntry entry = Instance.GetPlayerEntry <VvVPlayerEntry>(m as PlayerMobile);

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

            return(entry.Active && (!guildedonly || entry.Guild != null));
        }
Example #17
0
        public void Update(VvVPlayerEntry victim, VvVPlayerEntry killer, UpdateType type)
        {
            VvVGuildBattleStats killerStats = GetGuildStats(killer.Guild);
            VvVGuildBattleStats victimStats = victim == null ? null : GetGuildStats(victim.Guild);

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

                if (victim != null && victim.Player != null)
                {
                    if (!KillCooldown.ContainsKey(victim.Player) || KillCooldown[victim.Player] < DateTime.UtcNow)
                    {
                        if (killerStats != null)
                        {
                            killerStats.Points += KillPoints;
                        }

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

                break;

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

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

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

            case UpdateType.TurnInVice:
                if (killerStats != null)
                {
                    killer.ReturnedSigils++;
                    killerStats.ViceReturned++;
                    killerStats.Points += TurnInPoints;
                    killerStats.Silver += TurnInSilver + (OppositionCount(killer.Guild) * 50);
                    SendStatusMessage(String.Format("{0} has returned the sigil!", killer.Player.Name));
                    NextSigilSpawn = DateTime.UtcNow + TimeSpan.FromMinutes(1);
                }
                RemovePriests();
                break;

            case UpdateType.TurnInVirtue:
                if (killerStats != null)
                {
                    killer.ReturnedSigils++;
                    killerStats.VirtueReturned++;
                    killerStats.Points += TurnInPoints;
                    killerStats.Silver += TurnInSilver + (OppositionCount(killer.Guild) * 50);
                    SendStatusMessage(String.Format("{0} has returned the sigil!", killer.Player.Name));
                    NextSigilSpawn = DateTime.UtcNow + TimeSpan.FromMinutes(1);
                }
                RemovePriests();
                break;

            case UpdateType.Disarm:
                if (killerStats != null)
                {
                    killerStats.Disarmed++;
                    killer.DisarmedTraps++;
                    killerStats.Silver += DisarmSilver + (OppositionCount(killer.Guild) * 50);
                    SendStatusMessage(String.Format("{0} has disarmed a trap!", killer.Player.Name));
                }
                break;
            }

            CheckScore();
        }
Example #18
0
        public static void Initialize()
        {
            if (!Enabled)
            {
                return;
            }

            EventSink.Login       += OnLogin;
            EventSink.PlayerDeath += OnPlayerDeath;

            Server.Commands.CommandSystem.Register("BattleProps", AccessLevel.GameMaster, e =>
            {
                if (Instance.Battle != null)
                {
                    e.Mobile.SendGump(new PropertiesGump(e.Mobile, Instance.Battle));
                }
            });

            Server.Commands.CommandSystem.Register("ForceStartBattle", AccessLevel.GameMaster, e =>
            {
                if (Instance.Battle != null && !Instance.Battle.OnGoing)
                {
                    Instance.Battle.Begin();
                }
            });

            Server.Commands.CommandSystem.Register("ExemptCities", AccessLevel.Administrator, e =>
            {
                e.Mobile.SendGump(new ExemptCitiesGump());
            });

            Server.Commands.CommandSystem.Register("VvVKick", AccessLevel.GameMaster, e =>
            {
                e.Mobile.SendMessage("Target the person you'd like to remove from VvV.");
                e.Mobile.BeginTarget(-1, false, Server.Targeting.TargetFlags.None, (from, targeted) =>
                {
                    if (targeted is PlayerMobile)
                    {
                        var pm = targeted as PlayerMobile;
                        VvVPlayerEntry entry = Instance.GetPlayerEntry <VvVPlayerEntry>(pm);

                        if (entry != null && entry.Active)
                        {
                            pm.PrivateOverheadMessage(MessageType.Regular, 1154, 1155561, pm.NetState);     // You are no longer in Vice vs Virtue!

                            entry.Active           = false;
                            entry.ResignExpiration = DateTime.MinValue;
                            pm.Delta(MobileDelta.Noto);
                            pm.ValidateEquipment();

                            from.SendMessage("{0} has been removed from VvV.", pm.Name);
                            pm.SendMessage("You have been removed from VvV.");
                        }
                        else
                        {
                            from.SendMessage("{0} is not an active VvV member.", pm.Name);
                        }
                    }
                });
            });

            if (!Instance.HasGenerated)
            {
                CreateSilverTraders();
            }
        }
Example #19
0
        public bool IsResigning(PlayerMobile pm, Guild g)
        {
            VvVPlayerEntry entry = GetPlayerEntry <VvVPlayerEntry>(pm);

            return(entry != null && entry.Guild == g && entry.Resigning);
        }
Example #20
0
        public void HandlePlayerDeath(PlayerMobile victim)
        {
            VvVPlayerEntry ventry = GetPlayerEntry <VvVPlayerEntry>(victim);

            if (ventry != null && ventry.Active)
            {
                List <DamageEntry> list    = victim.DamageEntries.OrderBy(d => - d.DamageGiven).ToList();
                List <Mobile>      handled = new List <Mobile>();
                bool statloss = false;

                for (int i = 0; i < list.Count; i++)
                {
                    Mobile dam = list[i].Damager;

                    if (dam == victim || dam == null)
                    {
                        continue;
                    }

                    if (dam is BaseCreature creature && creature.GetMaster() is PlayerMobile)
                    {
                        dam = creature.GetMaster();
                    }

                    bool isEnemy = IsEnemy(victim, dam);

                    if (isEnemy)
                    {
                        VvVPlayerEntry kentry = GetPlayerEntry <VvVPlayerEntry>(dam);

                        if (kentry != null && kentry.Active && !handled.Contains(dam))
                        {
                            if (Battle.IsInActiveBattle(dam, victim))
                            {
                                if (i == 0)
                                {
                                    Battle.Update(ventry, kentry, UpdateType.Kill);
                                }
                                else
                                {
                                    Battle.Update(ventry, kentry, UpdateType.Assist);
                                }
                            }

                            handled.Add(dam);
                            kentry.TotalKills++;

                            if (EnhancedRules)
                            {
                                kentry.AwardSilver(victim);
                            }
                        }

                        if (!handled.Contains(victim))
                        {
                            ventry.TotalDeaths++;
                            handled.Add(victim);
                        }
                    }

                    if (!statloss && isEnemy)
                    {
                        statloss = true;
                    }
                }

                if (statloss)
                {
                    ApplySkillLoss(victim);
                }

                ColUtility.Free(list);
                ColUtility.Free(handled);
            }
        }
Example #21
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();
        }
Example #22
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);
        }
Example #23
0
        public ViceVsVirtueLeaderboardGump(PlayerMobile pm, Filter filter = Filter.Score) : base(50, 50)
        {
            User   = pm;
            Filter = filter;

            AddPage(0);
            AddBackground(0, 0, 920, 320, 5054);
            AddImageTiled(10, 10, 900, 300, 2624);

            AddHtmlLocalized(0, 12, 920, 20, 1114921, 0xFFFF, false, false);                                                                                           // <DIV ALIGN=CENTER>Vice Vs Virtue - Player Rankings</DIV>

            AddHtmlLocalized(10, 55, 65, 20, 1114981, 0xFFFF, false, false);                                                                                           // <DIV ALIGN=CENTER>#:</DIV>
            AddHtmlLocalized(70, 55, 160, 20, 1114966, 0xFFFF, false, false);                                                                                          // <DIV ALIGN=LEFT>Name:</DIV>
            AddHtmlLocalized(230, 55, 70, 20, 1114978, 0xFFFF, false, false);                                                                                          // <DIV ALIGN=CENTER>Guild:</DIV>
            AddHtmlLocalized(300, 55, 100, 20, 1114977, Filter == Filter.Score ? Server.Engines.Quests.BaseQuestGump.C32216(0x00FA9A) : 0xFFFF, false, false);         // <DIV ALIGN=RIGHT>Score:</DIV>
            AddHtmlLocalized(420, 55, 55, 20, 1114975, Filter == Filter.Kills ? Server.Engines.Quests.BaseQuestGump.C32216(0x00FA9A) : 0xFFFF, false, false);          // <DIV ALIGN=RIGHT>Kills:</DIV>
            AddHtmlLocalized(480, 55, 55, 20, 1114893, 0xFFFF, false, false);                                                                                          // <DIV ALIGN=RIGHT>Deaths:</DIV>
            AddHtmlLocalized(540, 55, 55, 20, 1155572, 0xFFFF, false, false);                                                                                          // <DIV ALIGN=RIGHT>Assists:</DIV>
            AddHtmlLocalized(610, 55, 90, 20, 1155575, Filter == Filter.ReturnedSigils ? Server.Engines.Quests.BaseQuestGump.C32216(0x00FA9A) : 0xFFFF, false, false); // <DIV ALIGN=RIGHT>Returned Sigil:</DIV>
            AddHtmlLocalized(710, 55, 100, 20, 1155574, 0xFFFF, false, false);                                                                                         // <DIV ALIGN=RIGHT>Disarmed Traps:</DIV>
            AddHtmlLocalized(810, 55, 80, 20, 1155573, 0xFFFF, false, false);                                                                                          // <DIV ALIGN=RIGHT>Stolen Sigil:</DIV>

            if (Filter != Filter.Score)
            {
                AddButton(400, 55, 2437, 2438, 1, GumpButtonType.Reply, 0);
            }
            else
            {
                AddImage(400, 55, 10006);
            }

            if (Filter != Filter.Kills)
            {
                AddButton(475, 55, 2437, 2438, 2, GumpButtonType.Reply, 0);
            }
            else
            {
                AddImage(475, 55, 10006);
            }

            if (Filter != Filter.ReturnedSigils)
            {
                AddButton(700, 55, 2437, 2438, 3, GumpButtonType.Reply, 0);
            }
            else
            {
                AddImage(700, 55, 10006);
            }

            AddButton(280, 290, 4005, 4007, 4, GumpButtonType.Reply, 0);
            AddHtmlLocalized(315, 290, 150, 20, 1114923, 0xFFFF, false, false); // Guild Rankings

            List <VvVPlayerEntry> list = new List <VvVPlayerEntry>(ViceVsVirtueSystem.Instance.PlayerTable.OfType <VvVPlayerEntry>());

            switch (Filter)
            {
            default:
            case Filter.Score: list = list.OrderBy(e => - e.Score).ToList(); break;

            case Filter.Kills: list = list.OrderBy(e => - e.Kills).ToList(); break;

            case Filter.ReturnedSigils: list = list.OrderBy(e => - e.ReturnedSigils).ToList(); break;
            }

            int pages     = (int)Math.Ceiling((double)list.Count / PerPage);
            int y         = 75;
            int page      = 1;
            int pageindex = 0;

            if (pages < 1)
            {
                pages = 1;
            }

            AddPage(page);
            AddHtmlLocalized(60, 290, 150, 20, 1153561, String.Format("{0}\t{1}", page.ToString(), pages.ToString()), 0xFFFF, false, false); // Page ~1_CUR~ of ~2_MAX~

            for (int i = 0; i < list.Count; i++)
            {
                VvVPlayerEntry entry = list[i];

                if (entry.Player == null)
                {
                    continue;
                }

                Guild g = entry.Player.Guild as Guild;

                AddHtml(10, y, 65, 20, CenterGray((i + 1).ToString() + "."), false, false);
                AddHtml(70, y, 160, 20, LeftGray(entry.Player.Name), false, false);
                AddHtml(230, y, 70, 20, CenterGray(g == null ? "None" : g.Abbreviation), false, false);
                AddHtml(300, y, 100, 20, Filter == Filter.Score ? RightGreen(entry.Score.ToString()) : RightGray(entry.Score.ToString()), false, false);
                AddHtml(420, y, 55, 20, Filter == Filter.Kills ? RightGreen(entry.Kills.ToString()) : RightGray(entry.Kills.ToString()), false, false);
                AddHtml(480, y, 55, 20, RightGray(entry.Deaths.ToString()), false, false);
                AddHtml(540, y, 55, 20, RightGray(entry.Assists.ToString()), false, false);
                AddHtml(610, y, 90, 20, Filter == Filter.ReturnedSigils ? RightGreen(entry.ReturnedSigils.ToString()) : RightGray(entry.ReturnedSigils.ToString()), false, false);
                AddHtml(710, y, 100, 20, RightGray(entry.DisarmedTraps.ToString()), false, false);
                AddHtml(810, y, 80, 20, RightGray(entry.StolenSigils.ToString()), false, false);

                y += 20;
                pageindex++;

                if (pageindex == PerPage)
                {
                    AddHtmlLocalized(60, 290, 150, 20, 1153561, String.Format("{0}\t{1}", page.ToString(), pages.ToString()), 0xFFFF, false, false); // Page ~1_CUR~ of ~2_MAX~

                    if (i > 0 && i < list.Count - 1)
                    {
                        AddButton(200, 290, 4005, 4007, 0, GumpButtonType.Page, page + 1);

                        page++;
                        y         = 75;
                        pageindex = 0;
                        AddPage(page);

                        AddButton(170, 290, 4014, 4016, 0, GumpButtonType.Page, page - 1);
                    }
                }
            }

            list.Clear();
            list.TrimExcess();
        }
        public BattleStatsGump(PlayerMobile pm, VvVBattle battle)
            : base(50, 50)
        {
            Battle = battle;
            AddBackground(0, 0, 500, 500, 9380);

            Guild leader  = battle.GetLeader();
            Guild myGuild = pm.Guild as Guild;

            if (leader == null || myGuild == null)
            {
                return;
            }

            AddHtmlLocalized(0, 40, 500, 20, 1154645, "#1154945", Color16, false, false); // The Battle between Vice and Virtue has ended!
            AddHtml(40, 65, 420, 20, String.Format("<basefont color=#B22222>{0} [{1}] has won the battle!", leader.Name, leader.Abbreviation), false, false);

            int y = 90;

            if (leader.Alliance != null && Battle.HasAlliance(leader))
            {
                AddHtml(40, y, 420, 20, String.Format("<basefont color=#B22222>The {0} Alliance has won the battle!", leader.Alliance.Name), false, false);
                y += 25;
            }

            // TODO: Does score reflect everyone, alliance, or just that player! For now, it will be entire alliance

            int          silver = 0, score = 0, kills = 0, assists = 0, deaths = 0, stolen = 0, returned = 0, vicereturned = 0, virtuereturned = 0, disarmed = 0;
            List <Guild> alliance = Battle.GetAlliance(myGuild);

            foreach (Guild g in alliance)
            {
                VvVGuildBattleStats stats = Battle.GetGuildStats(g);

                kills          += stats.Kills;
                assists        += stats.Assists;
                deaths         += stats.Deaths;
                stolen         += stats.Stolen;
                returned       += stats.ReturnedSigils;
                vicereturned   += stats.ViceReturned;
                virtuereturned += stats.VirtueReturned;
                disarmed       += stats.Disarmed;
            }

            silver += (int)ViceVsVirtueSystem.Instance.GetPoints(pm);

            VvVPlayerEntry entry = ViceVsVirtueSystem.Instance.GetPlayerEntry <VvVPlayerEntry>(pm);

            if (entry != null)
            {
                score = entry.Score;
            }

            AddHtmlLocalized(40, y, 420, 20, 1154947, silver.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false); // Total Silver Points: ~1_val~
            y += 25;

            AddHtmlLocalized(40, y, 420, 20, 1154948, score.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false); // Total Score: ~1_val~
            y += 25;

            AddHtmlLocalized(40, y, 420, 20, 1154949, kills.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false);
            y += 25;

            AddHtmlLocalized(40, y, 420, 20, 1154950, assists.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false);
            y += 25;

            AddHtmlLocalized(40, y, 420, 20, 1154951, deaths.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false);
            y += 25;

            AddHtmlLocalized(40, y, 420, 20, 1154952, stolen.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false);
            y += 25;

            AddHtmlLocalized(40, y, 420, 20, 1154953, returned.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false);
            y += 25;

            AddHtmlLocalized(40, y, 420, 20, 1154954, vicereturned.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false);
            y += 25;

            AddHtmlLocalized(40, y, 420, 20, 1154955, virtuereturned.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false);
            y += 25;

            AddHtmlLocalized(40, y, 420, 20, 1154956, disarmed.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false);
            y += 25;
        }