Beispiel #1
0
        public static void OnLoad()
        {
            Stats = new List <VoidPoolStats>();

            Persistence.Deserialize(
                FilePath,
                reader =>
            {
                int version = reader.ReadInt();

                if (version == 0)
                {
                    Stats.Add(new VoidPoolStats(reader, true));
                }
                else
                {
                    int count = reader.ReadInt();
                    for (int i = 0; i < count; i++)
                    {
                        VoidPoolStats stats = new VoidPoolStats(reader, false);

                        if (stats.Controller != null)
                        {
                            Stats.Add(stats);
                        }
                    }
                }
            });
        }
Beispiel #2
0
        public override void OnResponse(Server.Network.NetState state, RelayInfo info)
        {
            var stats = VoidPoolStats.GetStats(Controller);

            switch (info.ButtonID)
            {
            default: break;

            case 1:
                User.SendGump(new ScoresGump(Controller, User, ScoreType.Current));
                break;

            case 2:
                User.SendGump(new ScoresGump(Controller, User, ScoreType.BestSingle));
                break;

            case 3:
                User.SendGump(new ScoresGump(Controller, User, ScoreType.OverallTotal));
                break;

            case 4:
                if (stats.BestWave != null)
                {
                    User.SendGump(new ScoresGump(Controller, User, ScoreType.BestWave));
                }
                break;
            }
        }
Beispiel #3
0
        public void EndInvasion()
        {
            Region.SendRegionMessage(1152530);             // Cora's forces have destroyed the Void Pool walls. The battle is lost!

            VoidPoolStats.OnInvasionEnd(this /*CurrentScore, Wave*/);

            NextStart = DateTime.UtcNow + TimeSpan.FromMinutes(RestartSpan);

            Region.SendRegionMessage(1152526, RestartSpan.ToString());             // The battle for the Void Pool will begin in ~1_VALUE~ minutes.

            List <Mobile> list = Region.GetPlayers();

            foreach (Mobile m in list.Where(m => GetCurrentPoints(m) > 0))
            {
                PointsSystem.VoidPool.AwardPoints(m, GetCurrentPoints(m));
            }

            foreach (Mobile m in list.Where(m => CurrentScore.ContainsKey(m)))
            {
                m.SendLocalizedMessage(1152650, String.Format("{0}\t{1}\t{2}\t{3}", GetTotalWaves(m), Wave.ToString(), Wave.ToString(), CurrentScore[m]));
                // During the battle, you helped fight back ~1_COUNT~ out of ~2_TOTAL~ waves of enemy forces. Your final wave was ~3_MAX~. Your total score for the battle was ~4_SCORE~ points.
            }

            list.Clear();
            list.TrimExcess();
            ClearSpawn(true);
        }
Beispiel #4
0
        public BestWave(Dictionary <Mobile, long> score, int waves)
        {
            Score = score;

            TotalScore = VoidPoolStats.GetCollectiveScore(score);
            Waves      = waves;
            Date       = DateTime.Now.ToShortDateString();
        }
Beispiel #5
0
        public static void CheckBestWave(VoidPoolController controller)
        {
            VoidPoolStats stats = GetStats(controller);
            int           wave  = controller.Wave;

            if (stats.BestWave == null || wave > stats.BestWave.Waves)
            {
                stats.BestWave = new BestWave(controller.CurrentScore, wave);
                Timer.DelayCall(TimeSpan.FromSeconds(1.5), () => World.Broadcast(2072, false, string.Format("A new Void Pool Invasion record has been made: {0}!", wave.ToString())));
            }
        }
Beispiel #6
0
        public static VoidPoolStats GetStats(VoidPoolController controller)
        {
            VoidPoolStats stats = Stats.FirstOrDefault(s => s.Controller == controller);

            if (stats == null)
            {
                stats = new VoidPoolStats(controller);
            }

            return(stats);
        }
Beispiel #7
0
        public static bool CheckBestSingle(VoidPoolController controller)
        {
            VoidPoolStats stats = GetStats(controller);

            foreach (KeyValuePair <Mobile, long> kvp in controller.CurrentScore)
            {
                if (!stats.BestSingle.ContainsKey(kvp.Key) || kvp.Value > stats.BestSingle[kvp.Key])
                {
                    stats.BestSingle[kvp.Key] = kvp.Value;
                    return(true);
                }
            }

            return(false);
        }
        public void AddToOverallTotal(Mobile m, int points)
        {
            var stats = VoidPoolStats.GetStats(Controller);

            if (stats != null)
            {
                if (!stats.OverallTotal.ContainsKey(m))
                {
                    stats.OverallTotal[m] = points;
                }
                else
                {
                    stats.OverallTotal[m] += points;
                }
            }
        }
Beispiel #9
0
        public static void AddToOverallTotal(VoidPoolController controller)
        {
            VoidPoolStats stats = GetStats(controller);

            foreach (KeyValuePair <Mobile, long> kvp in controller.CurrentScore)
            {
                if (!stats.OverallTotal.ContainsKey(kvp.Key))
                {
                    stats.OverallTotal[kvp.Key] = kvp.Value;
                }
                else
                {
                    stats.OverallTotal[kvp.Key] += kvp.Value;
                }
            }
        }
Beispiel #10
0
        public static void OnSave(WorldSaveEventArgs e)
        {
            Persistence.Serialize(
                FilePath,
                writer =>
            {
                writer.Write(1);

                writer.Write(Stats.Count);
                for (var index = 0; index < Stats.Count; index++)
                {
                    VoidPoolStats stats = Stats[index];
                    stats.Serialize(writer);
                }
            });
        }
Beispiel #11
0
        public void AddGumpLayout()
        {
            AddBackground(0, 0, 400, 565, 9350);

            AddHtmlLocalized(10, 10, 200, 16, 1152531, Red, false, false);                                           // The Void Pool
            AddHtmlLocalized(10, 30, 200, 16, Controller.Map == Map.Felucca ? 1012001 : 1012000, Red, false, false); // FEl/Tram

            if (Controller.OnGoing)
            {
                AddHtmlLocalized(10, 50, 200, 16, 1152914, Orange, false, false);                              // Current Battle:
                AddHtmlLocalized(180, 50, 200, 16, 1152915, Controller.Wave.ToString(), Orange, false, false); // Wave ~1_WAVE~
            }
            else
            {
                AddHtmlLocalized(10, 50, 200, 16, 1152916, Orange, false, false);                 // Next Battle:

                if (Controller.NextStart > DateTime.UtcNow)
                {
                    AddHtmlLocalized(180, 50, 200, 16, 1152917, ((int)(Controller.NextStart - DateTime.UtcNow).TotalMinutes).ToString(), Orange, false, false);                     // Starts in ~1_MIN~ min.
                }
            }

            AddButton(140, 70, 4005, 4006, 1, GumpButtonType.Reply, 0);
            AddHtmlLocalized(180, 70, 200, 16, 1152535, Orange, false, false);                          //Current Battle Scoreboard

            AddButton(140, 90, 4005, 4006, 2, GumpButtonType.Reply, 0);
            AddHtmlLocalized(180, 90, 200, 16, 1152536, Orange, false, false);                          //Best Single Battle Scoreboard

            AddButton(140, 110, 4005, 4006, 3, GumpButtonType.Reply, 0);
            AddHtmlLocalized(180, 110, 200, 16, 1152537, Orange, false, false);                         //Overall Total Scores

            var stats = VoidPoolStats.GetStats(Controller);

            if (stats.BestWave != null)
            {
                AddButton(140, 130, 4005, 4006, 4, GumpButtonType.Reply, 0);
                AddHtml(180, 130, 200, 16, String.Format("<basefont color=#A52A2A>Best Wave: {0}", stats.BestWave.Waves.ToString()), false, false);
            }

            AddHtmlLocalized(10, 150, 400, 16, 1152552, Orange, false, false);                                  // See Loyalty Menu for Reward Points
            AddHtmlLocalized(10, 170, 400, 16, 1152553, Orange, false, false);                                  // See Vela in Cove for rewards

            AddHtmlLocalized(10, 190, 380, 175, 1152533, Orange, true, true);
            AddHtmlLocalized(10, 375, 380, 175, 1152534, Orange, true, true);
        }
Beispiel #12
0
        public static bool CheckAddTop20(VoidPoolController controller)
        {
            long          total = GetCollectiveScore(controller.CurrentScore);
            VoidPoolStats stats = GetStats(controller);

            List <Dictionary <Mobile, long> > copy = new List <Dictionary <Mobile, long> >(stats.Top20);

            foreach (Dictionary <Mobile, long> s in copy.OrderBy(dic => - GetCollectiveScore(dic)))
            {
                if (total > GetCollectiveScore(s))
                {
                    stats.Top20.Remove(copy[copy.Count - 1]);
                    stats.Top20.Add(s);
                    return(true);
                }
            }

            return(false);
        }
Beispiel #13
0
        public static VoidPoolStats GetStats(VoidPoolController controller)
        {
            VoidPoolStats stats = null;

            for (var index = 0; index < Stats.Count; index++)
            {
                var s = Stats[index];

                if (s.Controller == controller)
                {
                    stats = s;
                    break;
                }
            }

            if (stats == null)
            {
                stats = new VoidPoolStats(controller);
            }

            return(stats);
        }
Beispiel #14
0
        public void AddGumpLayout()
        {
            int    page = 0;
            object loc;

            AddBackground(0, 0, 500, 620, 9350);
            AddPage(page);

            var stats = VoidPoolStats.GetStats(Controller);

            if (this.ScoreType == ScoreType.BestWave && stats.BestWave == null)
            {
                return;
            }

            switch (this.ScoreType)
            {
            default:
            case ScoreType.Current: Score = Controller.CurrentScore; loc = 1152535; break;

            case ScoreType.BestSingle: Score = stats.BestSingle; loc = 1152536; break;

            case ScoreType.OverallTotal: Score = stats.OverallTotal; loc = 1152537; break;

            case ScoreType.BestWave: Score = stats.BestWave.Score; loc = "Best Wave Scoreboard"; break;
            }

            AddHtmlLocalized(10, 10, 200, 16, 1152531, Red, false, false);                                           // The Void Pool
            AddHtmlLocalized(10, 30, 200, 16, Controller.Map == Map.Felucca ? 1012001 : 1012000, Red, false, false); // FEl/Tram

            if (loc is int)
            {
                AddHtmlLocalized(10, 50, 200, 16, (int)loc, Red, false, false);
            }
            else if (loc is string)
            {
                AddHtml(10, 50, 200, 16, String.Format("<basefont color=#8B0000>{0}", (string)loc), false, false);
            }

            if (this.ScoreType == ScoreType.BestWave)
            {
                AddHtml(200, 30, 200, 16, String.Format("<basefont color=#8B0000>Total Waves: {0}", stats.BestWave.Waves.ToString()), false, false);
                AddHtml(200, 50, 200, 16, String.Format("<basefont color=#8B0000>Total Score: {0}", stats.BestWave.TotalScore.ToString()), false, false);
            }

            AddHtmlLocalized(10, 90, 100, 16, 1152541, Orange, false, false);  // RANK
            AddHtmlLocalized(100, 90, 300, 16, 1152542, Orange, false, false); // PLAYER
            AddHtmlLocalized(400, 90, 100, 16, 1152543, Orange, false, false); // SCORE

            page++;
            AddPage(page);

            if (Score != null)
            {
                int index   = 0;
                int yOffset = 0;

                foreach (KeyValuePair <Mobile, long> table in Score.OrderBy(kvp => - kvp.Value))
                {
                    AddHtml(10, 130 + (20 * yOffset), 50, 16, (index + 1).ToString(), false, false);
                    AddHtml(100, 130 + (20 * yOffset), 300, 16, table.Key.Name, false, false);
                    AddHtml(400, 130 + (20 * yOffset), 100, 16, table.Value.ToString(), false, false);

                    index++;
                    yOffset++;

                    if (index > 0 && index % 19 == 0 && index < Score.Count - 1)
                    {
                        page++;
                        yOffset = 0;

                        AddHtmlLocalized(320, 570, 100, 16, 1044045, Orange, false, false); // NEXT PAGE
                        AddButton(404, 570, 4005, 4006, 0, GumpButtonType.Page, page);

                        AddPage(page);

                        AddHtmlLocalized(120, 570, 100, 16, 1044044, Orange, false, false); // PREV PAGE
                        AddButton(80, 570, 4014, 4015, 0, GumpButtonType.Page, page - 1);
                    }
                }
            }
        }