public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            HasGenerated = reader.ReadBool();

            GuildStats = new Dictionary <Guild, VvVGuildStats>();
            Battle     = new VvVBattle(reader, this);

            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                Item item = reader.ReadItem();

                if (item != null)
                {
                    AddVvVItem(item);
                }
            }

            count = reader.ReadInt();
            for (int i = 0; i < count; i++)
            {
                Guild         g     = reader.ReadGuild() as Guild;
                VvVGuildStats stats = new VvVGuildStats(g, reader);

                if (g != null)
                {
                    GuildStats[g] = stats;
                }
            }
        }
Пример #2
0
        public void OnBattleEnd()
        {
            foreach (KeyValuePair <Guild, VvVGuildBattleStats> kvp in Battle.GuildStats)
            {
                Guild g = kvp.Key;

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

                int score = (int)kvp.Value.Points;

                GuildStats[g].Kills          += kvp.Value.Kills;
                GuildStats[g].ReturnedSigils += kvp.Value.ReturnedSigils;
                GuildStats[g].Score          += score;

                List <Mobile> list = g.Members.Where(mob => mob.NetState != null && mob.Region.IsPartOf(Battle.Region)).ToList();

                foreach (Mobile m in list)
                {
                    VvVPlayerEntry entry = GetPlayerEntry <VvVPlayerEntry>(m, true);

                    if (entry != null)
                    {
                        entry.Score += score;
                    }
                }
            }
        }
Пример #3
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            GuildStats   = new Dictionary <Guild, VvVGuildStats>();
            ExemptCities = new List <VvVCity>();

            switch (version)
            {
            case 2:
            case 1:
            {
                int count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    ExemptCities.Add((VvVCity)reader.ReadInt());
                }

                goto case 0;
            }

            case 0:
            {
                HasGenerated = reader.ReadBool();

                Battle = new VvVBattle(reader, this);

                int count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    Item item = reader.ReadItem();

                    if (item != null)
                    {
                        AddVvVItem(item);
                    }
                }

                count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    Guild         g     = reader.ReadGuild() as Guild;
                    VvVGuildStats stats = new VvVGuildStats(g, reader);

                    if (g != null)
                    {
                        GuildStats[g] = stats;
                    }
                }
            }
            break;
            }

            if (version == 1)
            {
                Timer.DelayCall(FixVvVItems);
            }
        }
Пример #4
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            GuildStats   = new Dictionary <Guild, VvVGuildStats>();
            ExemptCities = new List <VvVCity>();

            bool enabled  = false;
            bool enhanced = false;

            switch (version)
            {
            case 4:
                int c = reader.ReadInt();
                for (int i = 0; i < c; i++)
                {
                    var pm = reader.ReadMobile() as PlayerMobile;

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

                        ShowNewRules.Add(pm);
                    }
                }

                enhanced = reader.ReadBool();
                goto case 3;

            case 3:
                enabled = reader.ReadBool();
                goto case 2;

            case 2:
            case 1:
            {
                int count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    ExemptCities.Add((VvVCity)reader.ReadInt());
                }

                goto case 0;
            }

            case 0:
            {
                HasGenerated = reader.ReadBool();

                Battle = new VvVBattle(reader, this);

                int count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    Item item = reader.ReadItem();

                    if (item != null)
                    {
                        AddVvVItem(item);
                    }
                }

                count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    Guild         g     = reader.ReadGuild() as Guild;
                    VvVGuildStats stats = new VvVGuildStats(g, reader);

                    if (g != null)
                    {
                        GuildStats[g] = stats;
                    }
                }
            }
            break;
            }

            if (version == 1)
            {
                Timer.DelayCall(FixVvVItems);
            }

            if (Enabled && !enabled)
            {
                Timer.DelayCall(() =>
                {
                    CreateSilverTraders();
                });
            }
            else if (!Enabled && enabled)
            {
                DeleteSilverTraders();
            }

            if (EnhancedRules && !enhanced)
            {
                OnEnhancedRulesEnabled();
            }
        }
Пример #5
0
        public GuildLeaderboardGump(PlayerMobile pm, Filter filter = Filter.Score) : base(50, 50)
        {
            User   = pm;
            Filter = filter;

            AddPage(0);
            AddBackground(0, 0, 560, 320, 5054);
            AddImageTiled(10, 10, 540, 300, 2624);

            AddHtmlLocalized(0, 12, 560, 20, 1114922, 0xFFFF, false, false);                                                                            // <DIV ALIGN=CENTER>Vice Vs Virtue - Guild Rankings</DIV>

            AddHtmlLocalized(10, 55, 60, 20, 1114981, 0xFFFF, false, false);                                                                            // <DIV ALIGN=CENTER>#:</DIV>
            AddHtmlLocalized(50, 55, 180, 20, 1114978, 0xFFFF, false, false);                                                                           // <DIV ALIGN=CENTER>Guild:</DIV>
            AddHtmlLocalized(230, 55, 100, 20, 1114977, Filter == Filter.Score ? Quests.BaseQuestGump.C32216(0x00FA9A) : 0xFFFF, false, false);         // <DIV ALIGN=RIGHT>Score:</DIV>
            AddHtmlLocalized(330, 55, 85, 20, 1114975, Filter == Filter.Kills ? Quests.BaseQuestGump.C32216(0x00FA9A) : 0xFFFF, false, false);          // <DIV ALIGN=RIGHT>Kills:</DIV>
            AddHtmlLocalized(425, 55, 95, 20, 1155575, Filter == Filter.ReturnedSigils ? Quests.BaseQuestGump.C32216(0x00FA9A) : 0xFFFF, false, false); // <DIV ALIGN=RIGHT>Returned Sigil:</DIV>

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

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

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

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

            List <VvVGuildStats> list;

            switch (Filter)
            {
            default:
            case Filter.Score:
                list = new List <VvVGuildStats>();
                foreach (var stats in list.OrderBy(e => - e.Score))
                {
                    list.Add(stats);
                }
                break;

            case Filter.Kills:
                list = new List <VvVGuildStats>();
                foreach (var stats in list.OrderBy(e => - e.Kills))
                {
                    list.Add(stats);
                }
                break;

            case Filter.ReturnedSigils:
                list = new List <VvVGuildStats>();
                foreach (var stats in list.OrderBy(e => - e.ReturnedSigils))
                {
                    list.Add(stats);
                }
                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++)
            {
                VvVGuildStats entry = list[i];

                AddHtml(10, y, 65, 20, CenterGray((i + 1) + "."), false, false);
                AddHtml(50, y, 180, 20, CenterGray(entry.Guild == null ? "" : entry.Guild.Name), false, false);
                AddHtml(230, y, 100, 20, Filter == Filter.Score ? RightGreen(entry.Score.ToString()) : RightGray(entry.Score.ToString()), false, false);
                AddHtml(330, y, 85, 20, Filter == Filter.Kills ? RightGreen(entry.Kills.ToString()) : RightGray(entry.Kills.ToString()), false, false);
                AddHtml(425, y, 95, 20, Filter == Filter.ReturnedSigils ? RightGreen(entry.ReturnedSigils.ToString()) : RightGray(entry.ReturnedSigils.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();
        }
Пример #6
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);
        }
Пример #7
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            GuildStats   = new Dictionary <Guild, VvVGuildStats>();
            ExemptCities = new List <VvVCity>();
            bool enabled = false;

            switch (version)
            {
            case 3:
                enabled = reader.ReadBool();
                goto case 2;

            case 2:
            case 1:
            {
                int count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    ExemptCities.Add((VvVCity)reader.ReadInt());
                }

                goto case 0;
            }

            case 0:
            {
                HasGenerated = reader.ReadBool();

                Battle = new VvVBattle(reader, this);

                int count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    Item item = reader.ReadItem();

                    if (item != null)
                    {
                        AddVvVItem(item);
                    }
                }

                count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    Guild         g     = reader.ReadGuild() as Guild;
                    VvVGuildStats stats = new VvVGuildStats(g, reader);

                    if (g != null)
                    {
                        GuildStats[g] = stats;
                    }
                }
            }
            break;
            }

            if (version == 1)
            {
                Timer.DelayCall(FixVvVItems);
            }

            if (Enabled && !enabled)
            {
                CreateSilverTraders();
                Server.Factions.Generator.RemoveFactions();
            }
            else if (!Enabled && enabled)
            {
                DeleteSilverTraders();
            }
        }