Example #1
0
 private new void Awake()
 {
     timeCounter = GetComponent <TimerScript>();
     instance    = this;
     base.Awake();
     // PlayerScoreList = new Hashtable();
     foreach (var player in PhotonNetwork.PlayerList)
     {
         //PlayerScoreList.Add(player.NickName, 0);
         if (player.IsMasterClient)
         {
             //Hashtable hash = new Hashtable();
             //hash.Add("score", 0);
             //player.CustomProperties = hash;
             ScoreList.Add(player, 0);
         }
         else
         {
             //Hashtable hash = new Hashtable();
             //hash.Add("score", 100);
             //player.CustomProperties = hash;
             ScoreList.Add(player, 100);
         }
         Instantiate(roomListItemPrefab, ScoreBoardContent).GetComponent <ScoreBoardItem>().SetUp(player);
     }
 }
Example #2
0
        /// <summary>
        /// Displays the 5 best scores and saves the scores to a file
        /// </summary>
        public void WriteScore()
        {
            List <UInt64> ScoreList;

            if (File.Exists("score.xml")) //check if file exists before trying to read
            {
                ScoreList = ListIO.ReadList <UInt64>("score.xml");
                ScoreList.Add(Data.Score);
                ScoreList.Sort();
                ScoreList.Reverse();
                if (ScoreList.Count > 5) //remove the excess scores
                {
                    ScoreList.RemoveAt(5);
                }
            }
            else //generate new file if it deos not exists
            {
                ScoreList = new List <UInt64>
                {
                    Data.Score
                };
            }
            byte Line = 3;

            foreach (UInt64 CurrScore in ScoreList) //write scores
            {
                Console.SetCursorPosition(56, Line);
                Console.Write(CurrScore.ToString());
                Line += 1;
            }
            ListIO.WriteList <UInt64>("score.xml", ScoreList);
            ScoreList = null;
        }
Example #3
0
        public void TopTen()
        {
            Assert.IsFalse(DataStorage.Exists("topten.xml"));
            ScoreList score = new ScoreList();

            score.Add("sata", 100);
            score.Add("yksi", 1);
            score.Add("kaksi", 2);
            DataStorage.Save(score, "topten.xml");
            Assert.IsTrue(DataStorage.Exists("topten.xml"));

            ScoreList score2 = new ScoreList();

            score2 = DataStorage.Load(score2, "topten.xml");
            Assert.AreEqual(score2, score);
        }
        public void TestGenerateScoresWithoutFirstAndLast()
        {
            Dive      dive      = new Dive(new DiveCode(3.1));
            ScoreList scoreList = new ScoreList
            {
                new Score(7),
                new Score(8),
                new Score(5),
                new Score(10)
            };


            dive.Scores = scoreList;

            ScoreList list = dive.generateScoresWithoutFirstAndLastScore();

            //ScoreList winList = new ScoreList
            //{
            //    new Score(7),
            //    new Score(8)
            //};
            ScoreList winList = new ScoreList();
            Score     score   = new Score(7);
            Score     score2  = new Score(8);

            winList.Add(score);
            winList.Add(score2);


            double sum1 = 0, sum2 = 0;

            foreach (var s in winList)
            {
                sum1 += s.Value;
            }

            foreach (var s in list)
            {
                sum2 += s.Value;
            }

            //Assert.IsTrue(sum1 == 15);
            Assert.AreEqual(15, sum1);
            Assert.AreEqual(15, sum2);
        }
 private new void Awake()
 {
     instance    = this;
     timeCounter = GetComponent <TimerScript1>();
     base.Awake();
     foreach (var player in PhotonNetwork.PlayerList)
     {
         //PlayerScoreList.Add(player.NickName, 0);
         ScoreList.Add(player, 0);
         Instantiate(roomListItemPrefab, ScoreBoardContent).GetComponent <ScoreBoardItem>().SetUp(player);
     }
 }
Example #6
0
        private void getListScoreUser2(object sender, EventArgs e)
        {
            ObservableCollection <Score> ScoreListTmp = new ObservableCollection <Score>();
            JsonTools   tmp     = new JsonTools();
            HTTPRequest connect = (HTTPRequest)sender;

            System.Diagnostics.Debug.WriteLine("##################  Get all scores of user #######################");
            System.Diagnostics.Debug.WriteLine(connect.Response);
            JsonArray jsonArray;

            if (JsonArray.TryParse(connect.Response, out jsonArray))
            {
                foreach (var item in jsonArray)
                {
                    ScoreList.Add(tmp.getScoreFromJson(item.Stringify()));
                }
                ScoreList = ScoreListTmp;
            }
        }
        public void TestFullContest()
        {
            DateTime endDate = new DateTime(2018, 2, 22);

            ContestInfo contestInfo = new ContestInfo("Svedala simhopps tävling", "Örebro", DateTime.Now, endDate, "Gustavsvik");

            Judge judge1 = new Judge("Karl", "Mal");
            Judge judge2 = new Judge("LAban", "Asda");
            Judge judge3 = new Judge("Leg", "Shin");
            Judge judge4 = new Judge("Handy", "Bandy");
            Judge judge5 = new Judge("Sammy", "Rol");

            JudgeList judgeList = new JudgeList();

            judgeList.Add(judge1);
            judgeList.Add(judge2);
            judgeList.Add(judge3);
            judgeList.Add(judge4);
            judgeList.Add(judge5);

            Contestant kalle = new Contestant("kalle", "Cool");
            Contestant pelle = new Contestant("pelle", "Holm");
            Contestant lars  = new Contestant("Lars", "Lerin");
            Contestant anna  = new Contestant("Anna", "Annasson");

            ContestantList contestantList = new ContestantList();

            contestantList.Add(kalle);
            contestantList.Add(pelle);
            contestantList.Add(lars);
            contestantList.Add(anna);

            // create the new Contest object
            Contest contest = new Contest(contestInfo, judgeList, contestantList);


            // create ContestantLists for a subcontest
            ContestantList branch1_Contestants = new ContestantList();

            branch1_Contestants.Add(kalle);
            branch1_Contestants.Add(pelle);
            branch1_Contestants.Add(lars);

            SubContestBranch branch1 = new SubContestBranch("Deltävling 1", contest, branch1_Contestants);


            // create second subcontest
            ContestantList branch2_Contestants = new ContestantList();

            branch2_Contestants.Add(kalle);
            branch2_Contestants.Add(pelle);
            branch2_Contestants.Add(anna);

            SubContestBranch branch2 = new SubContestBranch("Deltävling 2", contest, branch2_Contestants);

            // add the newly created subcontests to the contest
            contest.SubContestBranches.Add(branch1);
            contest.SubContestBranches.Add(branch2);


            // first dive of the subcontest
            Dive dive1Kalle = new Dive(new DiveCode(3.1));

            // Scores come in from all the judges and is built into a full ScoreList
            ScoreList scoreListDive1Kalle = new ScoreList();

            scoreListDive1Kalle.Add(new Score(8, judge1));
            scoreListDive1Kalle.Add(new Score(5, judge2));
            scoreListDive1Kalle.Add(new Score(8.5, judge3));
            scoreListDive1Kalle.Add(new Score(7, judge4));
            scoreListDive1Kalle.Add(new Score(9, judge5));

            dive1Kalle.Scores = scoreListDive1Kalle;

            branch1.AddNewDive(kalle, dive1Kalle);


            // second dive
            Dive dive1Pelle = new Dive(new DiveCode(3.1));

            // Scores come in from all the judges and is built into a full ScoreList
            ScoreList scoreListDive1Pelle = new ScoreList();

            scoreListDive1Pelle.Add(new Score(8, judge1));
            scoreListDive1Pelle.Add(new Score(5, judge2));
            scoreListDive1Pelle.Add(new Score(8.5, judge3));
            scoreListDive1Pelle.Add(new Score(7, judge4));
            scoreListDive1Pelle.Add(new Score(6.5, judge5));

            dive1Pelle.Scores = scoreListDive1Pelle;

            branch1.AddNewDive(pelle, dive1Pelle);


            // third dive
            Dive dive1Lars = new Dive(new DiveCode(3.1));

            // Scores come in from all the judges and is built into a full ScoreList
            ScoreList scoreListDive1Lars = new ScoreList();

            scoreListDive1Lars.Add(new Score(7.5, judge1));
            scoreListDive1Lars.Add(new Score(9, judge2));
            scoreListDive1Lars.Add(new Score(8.5, judge3));
            scoreListDive1Lars.Add(new Score(7, judge4));
            scoreListDive1Lars.Add(new Score(6.5, judge5));

            dive1Lars.Scores = scoreListDive1Lars;

            branch1.AddNewDive(lars, dive1Lars);


            // first dive of second subcontest
            Dive dive2Kalle = new Dive(new DiveCode(2.8));

            // Scores come in from all the judges and is built into a full ScoreList
            ScoreList scoreListDive2Kalle = new ScoreList();

            scoreListDive2Kalle.Add(new Score(8, judge1));
            scoreListDive2Kalle.Add(new Score(5, judge2));
            scoreListDive2Kalle.Add(new Score(8.5, judge3));
            scoreListDive2Kalle.Add(new Score(7, judge4));
            scoreListDive2Kalle.Add(new Score(9, judge5));

            dive2Kalle.Scores = scoreListDive1Kalle;

            branch2.AddNewDive(kalle, dive2Kalle);


            // second dive
            Dive dive2Pelle = new Dive(new DiveCode(2.9));

            // Scores come in from all the judges and is built into a full ScoreList
            ScoreList scoreListDive2Pelle = new ScoreList();

            scoreListDive2Pelle.Add(new Score(8, judge1));
            scoreListDive2Pelle.Add(new Score(5, judge2));
            scoreListDive2Pelle.Add(new Score(8, judge3));
            scoreListDive2Pelle.Add(new Score(7, judge4));
            scoreListDive2Pelle.Add(new Score(6.5, judge5));

            dive2Pelle.Scores = scoreListDive1Pelle;

            branch2.AddNewDive(pelle, dive2Pelle);


            // third dive
            Dive dive1Anna = new Dive(new DiveCode(3.0));

            // Scores come in from all the judges and is built into a full ScoreList
            ScoreList scoreListDive1Anna = new ScoreList();

            scoreListDive1Anna.Add(new Score(7.5, judge1));
            scoreListDive1Anna.Add(new Score(9, judge2));
            scoreListDive1Anna.Add(new Score(8.5, judge3));
            scoreListDive1Anna.Add(new Score(7, judge4));
            scoreListDive1Anna.Add(new Score(6.5, judge5));

            dive1Anna.Scores = scoreListDive1Anna;

            branch2.AddNewDive(anna, dive1Anna);

            Console.WriteLine("HEJ");

            foreach (var subContest in contest.SubContestBranches)
            {
                int i = 1;
                foreach (var result in subContest.GenerateSubContestResult())
                {
                    Console.WriteLine(i + ". " + result.Key.FirstName + " Score: " + result.Value);
                    i++;
                }
            }
        }
Example #8
0
        public Contest createTestContest()
        {
            DateTime endDate = new DateTime(2018, 2, 22);

            ContestInfo contestInfo = new ContestInfo("Svedala simhoppstävling", "Örebro", DateTime.Now, endDate, "Gustavsvik");

            Judge judge1 = new Judge(1, "Karl", "Mal", 22, "*****@*****.**", "male", "891017-6653", "Pappersvägen 3");
            Judge judge2 = new Judge(2, "Laban", "Asda", 45, "*****@*****.**", "male", "651011-6423", "Venavägen 8");
            Judge judge3 = new Judge(3, "Leg", "Shin", 33, "*****@*****.**", "male", "821201-5434", "Storgatan 1");
            Judge judge4 = new Judge(4, "Anna", "Pann", 29, "*****@*****.**", "female", "910413-4594", "Järnvägsgatan 33");
            Judge judge5 = new Judge(5, "Sammy", "Rol", 38, "*****@*****.**", "female", "880623-5921", "Skolgatan 28");

            JudgeList judgeList = new JudgeList();

            judgeList.Add(judge1);
            judgeList.Add(judge2);
            judgeList.Add(judge3);
            judgeList.Add(judge4);
            judgeList.Add(judge5);

            Contestant kalle = new Contestant(6, "Kalle", "Cool", 35, "*****@*****.**", "male", "78345345-435", "Storgatan 3");
            Contestant pelle = new Contestant(7, "Pelle", "Holm", 14, "*****@*****.**", "male", "04546387-1104", "Småttmisnöjdmedtillvaro gatan 25");
            Contestant lars  = new Contestant(8, "Lars", "Lerin", 50, "*****@*****.**", "male", "68345435-4352", "Brittmarie-gatan 89");
            Contestant anna  = new Contestant(9, "Anna", "Annasson", 28, "*****@*****.**", "female", "88376534534-3455", "Lokalgatan 8");

            ContestantList contestantList = new ContestantList();

            contestantList.Add(kalle);
            contestantList.Add(pelle);
            contestantList.Add(lars);
            contestantList.Add(anna);

            // create the new Contest object
            Contest contest = new Contest(contestInfo, judgeList, contestantList);


            // create ContestantLists for a subcontest
            ContestantList branch1_Contestants = new ContestantList();

            branch1_Contestants.Add(kalle);
            branch1_Contestants.Add(pelle);
            branch1_Contestants.Add(lars);

            SubContestBranch branch1 = new SubContestBranch("Deltävling 1", contest, branch1_Contestants);


            // create second subcontest
            ContestantList branch2_Contestants = new ContestantList();

            branch2_Contestants.Add(kalle);
            branch2_Contestants.Add(pelle);
            branch2_Contestants.Add(anna);

            SubContestBranch branch2 = new SubContestBranch("Deltävling 2", contest, branch2_Contestants);

            // add the newly created subcontests to the contest
            contest.SubContestBranches.Add(branch1);
            contest.SubContestBranches.Add(branch2);


            // first dive of the subcontest
            Dive dive1Kalle = new Dive(new DiveCode(3.1));

            // Scores come in from all the judges and is built into a full ScoreList
            ScoreList scoreListDive1Kalle = new ScoreList();

            scoreListDive1Kalle.Add(new Score(8, judge1));
            scoreListDive1Kalle.Add(new Score(5, judge2));
            scoreListDive1Kalle.Add(new Score(8.5, judge3));
            scoreListDive1Kalle.Add(new Score(7, judge4));
            scoreListDive1Kalle.Add(new Score(9, judge5));

            dive1Kalle.Scores = scoreListDive1Kalle;

            branch1.AddNewDive(kalle, dive1Kalle);


            // second dive
            Dive dive1Pelle = new Dive(new DiveCode(3.1));

            // Scores come in from all the judges and is built into a full ScoreList
            ScoreList scoreListDive1Pelle = new ScoreList();

            scoreListDive1Pelle.Add(new Score(8, judge1));
            scoreListDive1Pelle.Add(new Score(5, judge2));
            scoreListDive1Pelle.Add(new Score(8.5, judge3));
            scoreListDive1Pelle.Add(new Score(7, judge4));
            scoreListDive1Pelle.Add(new Score(6.5, judge5));

            dive1Pelle.Scores = scoreListDive1Pelle;

            branch1.AddNewDive(pelle, dive1Pelle);


            // third dive
            Dive dive1Lars = new Dive(new DiveCode(3.1));

            // Scores come in from all the judges and is built into a full ScoreList
            ScoreList scoreListDive1Lars = new ScoreList();

            scoreListDive1Lars.Add(new Score(7.5, judge1));
            scoreListDive1Lars.Add(new Score(9, judge2));
            scoreListDive1Lars.Add(new Score(8.5, judge3));
            scoreListDive1Lars.Add(new Score(7, judge4));
            scoreListDive1Lars.Add(new Score(6.5, judge5));

            dive1Lars.Scores = scoreListDive1Lars;

            branch1.AddNewDive(lars, dive1Lars);


            // first dive of second subcontest
            Dive dive2Kalle = new Dive(new DiveCode(2.8));

            // Scores come in from all the judges and is built into a full ScoreList
            ScoreList scoreListDive2Kalle = new ScoreList();

            scoreListDive2Kalle.Add(new Score(8, judge1));
            scoreListDive2Kalle.Add(new Score(5, judge2));
            scoreListDive2Kalle.Add(new Score(8.5, judge3));
            scoreListDive2Kalle.Add(new Score(7, judge4));
            scoreListDive2Kalle.Add(new Score(9, judge5));

            dive2Kalle.Scores = scoreListDive1Kalle;

            branch2.AddNewDive(kalle, dive2Kalle);


            // second dive
            Dive dive2Pelle = new Dive(new DiveCode(2.9));

            // Scores come in from all the judges and is built into a full ScoreList
            ScoreList scoreListDive2Pelle = new ScoreList();

            scoreListDive2Pelle.Add(new Score(8, judge1));
            scoreListDive2Pelle.Add(new Score(5, judge2));
            scoreListDive2Pelle.Add(new Score(8, judge3));
            scoreListDive2Pelle.Add(new Score(7, judge4));
            scoreListDive2Pelle.Add(new Score(6.5, judge5));

            dive2Pelle.Scores = scoreListDive1Pelle;

            branch2.AddNewDive(pelle, dive2Pelle);


            // third dive
            Dive dive1Anna = new Dive(new DiveCode(3.0));

            // Scores come in from all the judges and is built into a full ScoreList
            ScoreList scoreListDive1Anna = new ScoreList();

            scoreListDive1Anna.Add(new Score(7.5, judge1));
            scoreListDive1Anna.Add(new Score(9, judge2));
            scoreListDive1Anna.Add(new Score(8.5, judge3));
            scoreListDive1Anna.Add(new Score(7, judge4));
            scoreListDive1Anna.Add(new Score(6.5, judge5));

            dive1Anna.Scores = scoreListDive1Anna;

            branch2.AddNewDive(anna, dive1Anna);

            return(contest);
        }
Example #9
0
    public override void Begin()
    {
        Level.BackgroundColor = Color.Gray;

        //MessageDisplay.Position = new Vector(100, 100);
        MessageDisplay.MaxMessageCount = (int)(Screen.Height / Font.Default.CharacterHeight - 1);
        MessageDisplay.BackgroundColor = Color.Transparent;
        MessageDisplay.MessageTime     = TimeSpan.MaxValue;
        MessageDisplay.RealTime        = true;
        MessageDisplay.TextColor       = Color.LightGray;

        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, null);
        PhoneBackButton.Listen(Exit, null);

        StorageFile tiedosto = null;

        try
        {
            DataStorage.Delete("testi.txt");

            tiedosto = DataStorage.Create("testi.txt");
            Assert(tiedosto.Name.EndsWith("testi.txt"), "tiedosto.Name.EndsWith(\"testi.txt\")");
            AssertNotNull(tiedosto.Stream, "tiedosto.Stream");
            tiedosto.Close();

            Assert(DataStorage.Exists("testi.txt"), "DataStorage.Exists(\"testi.txt\")");

            tiedosto = DataStorage.Open("testi.txt", false);
            Assert(tiedosto.Name.EndsWith("testi.txt"), "tiedosto.Name.EndsWith(\"testi.txt\")");
            AssertNotNull(tiedosto.Stream, "tiedosto.Stream");
            Assert(!tiedosto.Stream.CanWrite, "!tiedosto.Stream.CanWrite");
            tiedosto.Close();

            DataStorage.Delete("testi.txt");
            Assert(!DataStorage.Exists("testi.txt"), "!DataStorage.Exists(\"testi.txt\")");

            MessageDisplay.Add("---");

            DataStorage.MkDir("kansio");
            Assert(DataStorage.Exists("kansio"), "DataStorage.Exists(\"kansio\")");
            Assert(DataStorage.ChDir("kansio") == true, "DataStorage.ChDir( \"kansio\" ) == true");
            AssertValue(DataStorage.GetFileList().Count, 0, "DataStorage.GetFileList().Count");
            Assert(DataStorage.Exists("kansio") == false, "DataStorage.Exists(\"kansio\") == false");
            Assert(DataStorage.ChDir("..") == true, "DataStorage.ChDir( \"..\" ) == true");
            Assert(DataStorage.Exists("kansio") == true, "DataStorage.Exists(\"kansio\") == true");
            DataStorage.RmDir("kansio");

            Assert(DataStorage.Exists("kansio") == false, "DataStorage.Exists(\"kansio\") == false");
            Assert(DataStorage.ChDir("kansio") == false, "DataStorage.ChDir( \"kansio\" ) == false");

            DataStorage.Delete("topten.xml");
            Assert(!DataStorage.Exists("topten.xml"), "!DataStorage.Exists(\"topten.xml\")");
            ScoreList score = new ScoreList();
            score.Add("sata", 100);
            score.Add("yksi", 1);
            score.Add("kaksi", 2);
            DataStorage.Save(score, "topten.xml");
            Assert(DataStorage.Exists("topten.xml"), "DataStorage.Exists(\"topten.xml\")");

            ScoreList score2 = new ScoreList();
            score2 = DataStorage.Load(score2, "topten.xml");
            Assert(score2.Equals(score), "score2.Equals( score )");

            MessageDisplay.Add("---");
            MessageDisplay.Add("PASSED!", Color.LimeGreen);
        }
        catch (TestException)
        {
            MessageDisplay.Add("---");
            MessageDisplay.Add("FAILED!", Color.Red);
        }
        finally
        {
            if (tiedosto != null && tiedosto.Stream.CanRead)
            {
                tiedosto.Close();
            }

            DataStorage.Delete("testi.txt");
            DataStorage.Delete("topten.xml");
        }
    }
        public void TestGenerateSubContestResult()
        {
            Contest    contest = new Contest();
            Contestant kalle   = new Contestant("kalle", "Cool");
            Contestant pelle   = new Contestant("pelle", "Holm");
            Contestant lars    = new Contestant("Lars", "Lerin");

            ContestantList contestantList = new ContestantList();

            contestantList.Add(kalle);
            contestantList.Add(pelle);
            contestantList.Add(lars);

            SubContestBranch subContest = new SubContestBranch("Test", contest, contestantList);

            Dive dive  = new Dive(new DiveCode(3.1));
            Dive dive2 = new Dive(new DiveCode(2.1));
            Dive dive3 = new Dive(new DiveCode(3.5));
            Dive dive4 = new Dive(new DiveCode(2.5));
            Dive dive5 = new Dive(new DiveCode(15.0));

            ScoreList scoreListDive = new ScoreList();

            scoreListDive.Add(new Score(8));
            scoreListDive.Add(new Score(8.5));
            scoreListDive.Add(new Score(6.5));
            scoreListDive.Add(new Score(7));
            scoreListDive.Add(new Score(9));
            dive.Scores = scoreListDive;
            // 72.85

            subContest.AddNewDive(kalle, dive);

            ScoreList scoreListDive2 = new ScoreList();

            scoreListDive2.Add(new Score(6));
            scoreListDive2.Add(new Score(7.5));
            scoreListDive2.Add(new Score(6.5));
            scoreListDive2.Add(new Score(7));
            scoreListDive2.Add(new Score(9));
            dive2.Scores = scoreListDive2;
            // 44.1

            subContest.AddNewDive(pelle, dive2);

            ScoreList scoreListDive3 = new ScoreList();

            scoreListDive3.Add(new Score(6));
            scoreListDive3.Add(new Score(4.5));
            scoreListDive3.Add(new Score(6.5));
            scoreListDive3.Add(new Score(5));
            scoreListDive3.Add(new Score(8));
            dive3.Scores = scoreListDive3;
            subContest.AddNewDive(kalle, dive3);
            // 61.25

            ScoreList scoreListDive4 = new ScoreList();

            scoreListDive4.Add(new Score(6));
            scoreListDive4.Add(new Score(7));
            scoreListDive4.Add(new Score(8.5));
            scoreListDive4.Add(new Score(5));
            scoreListDive4.Add(new Score(8));
            dive4.Scores = scoreListDive4;
            subContest.AddNewDive(pelle, dive4);
            //


            ScoreList scoreListDive5 = new ScoreList();

            scoreListDive5.Add(new Score(6));
            scoreListDive5.Add(new Score(7));
            scoreListDive5.Add(new Score(8.5));
            scoreListDive5.Add(new Score(5));
            scoreListDive5.Add(new Score(8));
            dive5.Scores = scoreListDive5;
            subContest.AddNewDive(lars, dive5);
            //

            // get the ResultDictionary containing pairs of contestant and a total score sum.
            ResultDictionary result = subContest.GenerateSubContestResult();



            Assert.AreEqual(3, result.Count);

            foreach (var score in result)
            {
                Console.WriteLine(score.Key.FirstName + ": " + score.Value);
            }

            Assert.AreEqual(315, result.First().Value);

            Console.WriteLine();

            // getting same data from our Contest object
            ResultDictionary r = contest.GetSubContestResultDictionary(subContest);

            Assert.AreEqual(3, r.Count);

            foreach (var score in r)
            {
                Console.WriteLine(score.Key.FirstName + ": " + score.Value);
            }

            Assert.AreEqual(315, r.First().Value);
        }
Example #11
0
        public bool TryAdd(ReadOnlySpan <char> logLine)
        {
            if (LevelLoad.TryParse(logLine, LogDate, out var ll))
            {
                Current = ll;
                LoadLevelList.Add(ll);
            }
            else if (TestDriveStart.TryParse(logLine, LogDate, out var std))
            {
                Current = std;
                StartTestDriveList.Add(std);
            }
            else if (TestDriveFinish.TryParse(logLine, LogDate, out var ftd))
            {
                Current = ftd;
                FinishTestDriveList.Add(ftd);
            }
            else if (GameStart.TryParse(logLine, LogDate, out var sg))
            {
                Current = sg;
                StartGameList.Add(sg);
            }
            else if (GameFinish.TryParse(logLine, LogDate, out var fg))
            {
                Current = fg;
                FinishGameList.Add(fg);
            }
            else if (GameRound.TryParse(logLine, LogDate, out var rg))
            {
                Current = rg;
                RoundGameList.Add(rg);
            }
            else if (ActiveBattleStart.TryParse(logLine, LogDate, out var sab))
            {
                Current = sab;
                StartActiveBattleList.Add(sab);
            }
            else if (PlayerLoad.TryParse(logLine, LogDate, out var pl))
            {
                Current = pl;
                PlayerLoadList.Add(pl);
            }
            else if (Damage.TryParse(logLine, LogDate, out var dmg))
            {
                Current = dmg;
                DamageList.Add(dmg);
            }
            else if (Killing.TryParse(logLine, LogDate, out var kill))
            {
                Current = kill;
                KillList.Add(kill);
            }
            else if (KillAssist.TryParse(logLine, LogDate, out var ka))
            {
                Current = ka;
                KillAssistList.Add(ka);
            }
            else if (Score.TryParse(logLine, LogDate, out var sc))
            {
                Current = sc;
                ScoreList.Add(sc);
            }
            else if (Decal.TryParse(logLine, LogDate, out var dec))
            {
                Current = dec;
                DecalList.Add(dec);
            }
            else
            {
                Current = null;
                return(false);
            }
            //update datetimes
            var currentDateTime = new DateTime(Current.TimeStamp);

            if (currentDateTime > Last)
            {
                Last = currentDateTime;
            }
            if (currentDateTime < First)
            {
                First = currentDateTime;
            }
            return(true);
        }