Example #1
0
    public void testReplayProperlyParsed()
    {
        csgoParser parser = new csgoParser(pathMirageDemo);

        parser.ParseAllRounds();



        Assert.AreEqual(Team.CounterTerrorist, parser.GetWinningTeam());
        Assert.AreEqual(25, parser.RoundsPlayed);
        Assert.AreEqual(25, parser.GetPlayerPathInAllRounds(parser.Players[0]).Keys.Count);

        for (int i = 0; i < parser.RoundsPlayed; i++)
        {
            var allPlayerPathsInRound = parser.GetAllPlayerPathInRound(i);

            //for every tick in a round a position is saved
            var ticksPerRound = parser.GetTicksPerRound(i);

            List <AdvancedPosition> path = allPlayerPathsInRound.getFirstKey();

            Assert.AreEqual(ticksPerRound, path.Count);


            //10 player path are saved each round
            Assert.AreEqual(allPlayerPathsInRound.Keys.Count, 10);
        }
    }
Example #2
0
    public void testCSVWriter()
    {
        csgoParser parser = new csgoParser(pathMirageDemo);

        parser.ParseAllRounds();
        Player p = parser.Players[0];
        string header;
        string secondLine;
        string header2;
        string secondLine2;
        int    round       = 1;
        Player illegalName = parser.Players[5];

        parser.SaveToCSV(p, round, outputPath);
        parser.SaveToCSV(illegalName, round, outputPath);
        parser.saveOnlyKillFeed(outputPath);

        string[] files            = Directory.GetFiles(outputPath, "*.csv", SearchOption.AllDirectories);
        string[] filePlayerPath   = files.Where(f => f.ContainsAll(p.Name, round.ToString())).ToArray();
        string[] fileKillfeedPath = files.Where(f => f.ContainsAll("killFeed", round.ToString())).ToArray();

        //directory is created and file is saved there
        Assert.IsTrue(Directory.Exists(outputPath));
        Assert.IsNotEmpty(files);
        Assert.IsNotEmpty(filePlayerPath);
        Assert.IsNotEmpty(fileKillfeedPath);

        using (StreamReader reader = new StreamReader(filePlayerPath[0]))
        {
            header = reader.ReadLine();
            //file doesnt end after header
            Assert.IsFalse(reader.EndOfStream);
            secondLine = reader.ReadLine();
        }

        using (StreamReader reader = new StreamReader(fileKillfeedPath[0]))
        {
            header2 = reader.ReadLine();
            //file doesnt end after header
            Assert.IsFalse(reader.EndOfStream);
            secondLine2 = reader.ReadLine();
        }

        int amountOfCommataInValues = secondLine.Count(f => f == ',');
        int amountOfCommataInHeader = header.Count(f => f == ',');

        //header is written correctly
        Assert.IsTrue(header.ContainsAll("ticks", "posX", "posY", "posZ"));

        Assert.AreEqual(amountOfCommataInHeader, amountOfCommataInValues);
        Assert.AreEqual(header2.Count(f => f == ','), secondLine2.Count(f => f == ','));
    }
Example #3
0
    public void testKillfeed()
    {
        csgoParser parser = new csgoParser(pathMirageDemo);

        parser.ParseAllRounds();

        Dictionary <int, Dictionary <int, List <PlayerKilledEventArgs> > > killfeed = parser.GetKillFeed();

        Assert.AreEqual(killfeed.Keys.Count, parser.RoundsPlayed);
        foreach (var item in killfeed.Keys)
        {
            Dictionary <int, List <PlayerKilledEventArgs> > kills = killfeed[item];
            //Latest kill is still in the round
            Assert.LessOrEqual(kills.Keys.Last(), parser.GetTicksPerRound(item));
            //No more than 10 deaths are possible in a round
            Assert.LessOrEqual(kills.Count, 10);
        }
    }
    /// <summary>
    /// Saves the players' paths to a CSV
    /// </summary>
    /// <param name="args">replay file, and optional output folder</param>
    public static void Main(string[] args)
    {
        if (!AreProperArguments(args, out string saveFolder))
        {
            return;
        }

        string fileReplay = args[0];

        csgoParser parser = new csgoParser(fileReplay);

        Console.Write(parser.ToString());

        parser.ParseAllRounds();

        parser.SaveToCSV(saveFolder);

        Console.WriteLine("parsing finished");
        Console.Write(parser.GetEndGameStatsString());
    }
Example #5
0
 public void parseAllRounds()
 {
     ReplayParsed = parser.ParseAllRounds();
 }