Exemplo n.º 1
0
        /// <summary>
        /// Išspausdina populiariausią klasę
        /// </summary>
        /// <param name="branchContainer"></param>
        private static void PrintMostPopularRole(BranchContainer branchContainer)
        {
            var mostPopularRole = FindMostPopular(branchContainer);
            var maxValue        = mostPopularRole.Values.Max();
            var role            = mostPopularRole.FirstOrDefault(f => f.Value == maxValue).Key;

            Console.WriteLine($"1.Daugiausiai šios klasės veikėjų: {role} | Pasikartoja: {maxValue} karto(ų)");
            Console.WriteLine();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Išspausdina žaidėjų lentelę
        /// </summary>
        /// <param name="branchContainer"></param>
        /// <param name="file"></param>
        private static void CreateReportTable(BranchContainer branchContainer, string file)
        {
            using (var writer = new StreamWriter(file, true, Encoding.UTF8))
            {
                writer.WriteLine("Žaidėjų sąrašai");
                writer.WriteLine(new string('-', 181));
                for (int i = 0; i < branchContainer.Count; i++)
                {
                    writer.WriteLine(new string('-', 181));
                    writer.WriteLine("Naujas žaidėjo sąrašas");
                    writer.WriteLine(new string('-', 181));
                    writer.WriteLine("| {0,-10} | {1,-15} | ", "Rasė", "Miestas");
                    writer.WriteLine($"| {branchContainer.GetBranch(i).Race,-10} | {branchContainer.GetBranch(i).Town,-15} |");

                    writer.WriteLine(new string('-', 181));
                    writer.WriteLine("Herojai");
                    writer.WriteLine(new string('-', 181));
                    writer.WriteLine("| {0, -15} | {1,-15} | {2,-15} | {3,-15} | {4,-15} | {5,-15} | {6,-15} | {7,-15} | {8,-15} | {9,-15} |",
                                     "Vardas", "Klasė", "Gyvybės taškai", "Mana", "Žalos taškai ", "Gynybos taškai", "Jėga", "Vikrumas", "Intelektas", "Ypatinga galia");
                    writer.WriteLine(new string('-', 181));
                    for (int j = 0; j < branchContainer.GetBranch(i).Heroes.Count; j++)
                    {
                        writer.WriteLine($"| {branchContainer.GetBranch(i).Heroes.GetHero(j).Name,-15} | {branchContainer.GetBranch(i).Heroes.GetHero(j).Role,-15} | " +
                                         $"{branchContainer.GetBranch(i).Heroes.GetHero(j).HitPoints,15} | {branchContainer.GetBranch(i).Heroes.GetHero(j).Mana,15} | " +
                                         $"{branchContainer.GetBranch(i).Heroes.GetHero(j).Damage,15} | {branchContainer.GetBranch(i).Heroes.GetHero(j).Defence,15} | " +
                                         $"{branchContainer.GetBranch(i).Heroes.GetHero(j).Strength,15} | {branchContainer.GetBranch(i).Heroes.GetHero(j).Agility,15} | " +
                                         $"{branchContainer.GetBranch(i).Heroes.GetHero(j).Intelligence,15} | {branchContainer.GetBranch(i).Heroes.GetHero(j).Power,-15} |");
                    }

                    writer.WriteLine(new string('-', 181));
                    writer.WriteLine("NPC");
                    writer.WriteLine(new string('-', 181));
                    writer.WriteLine("| {0, -15} | {1,-15} | {2,-15} | {3,-15} | {4,-15} | {5,-15} | {6,-15} |",
                                     "Vardas", "Klasė", "Gyvybės taškai", "Mana", "Žalos taškai ", "Gynybos taškai", "Gildija");
                    writer.WriteLine(new string('-', 181));
                    for (int j = 0; j < branchContainer.GetBranch(i).NPCs.Count; j++)
                    {
                        writer.WriteLine($"| {branchContainer.GetBranch(i).NPCs.GetNPC(j).Name,-15} | {branchContainer.GetBranch(i).NPCs.GetNPC(j).Role,-15} | " +
                                         $"{branchContainer.GetBranch(i).NPCs.GetNPC(j).HitPoints,15} | {branchContainer.GetBranch(i).NPCs.GetNPC(j).Mana,15} | " +
                                         $"{branchContainer.GetBranch(i).NPCs.GetNPC(j).Damage,15} | {branchContainer.GetBranch(i).NPCs.GetNPC(j).Defence,15} | " +
                                         $"{branchContainer.GetBranch(i).NPCs.GetNPC(j).Guild,-15} |");
                    }
                    writer.WriteLine(new string('-', 181));
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Įrašo pasikartojančias rasių vardus į failą
        /// </summary>
        /// <param name="branchContainer"></param>
        /// <param name="file"></param>
        public static void WriteFilteredPlayersData(BranchContainer branchContainer, string file)
        {
            var filteredPlayers      = FilterPlayers(branchContainer);
            var filteredPlayersCount = filteredPlayers.Values.Max();

            using (var writer = new StreamWriter(file, false, Encoding.UTF8))
            {
                writer.WriteLine("Vardas;");
                foreach (KeyValuePair <string, int> samePlayers in filteredPlayers)
                {
                    if (samePlayers.Value >= 2)
                    {
                        writer.WriteLine($"{samePlayers.Key}");
                    }
                }
            }
        }
Exemplo n.º 4
0
        public const int TankDefence = 30;  // Tanko gynyba pagal kurias suranda tanka

        static void Main(string[] args)
        {
            Console.ReadKey();
            var filePaths       = Directory.GetFiles(Directory.GetCurrentDirectory(), "L3Data*.csv");
            var branchContainer = new BranchContainer();

            foreach (var path in filePaths)
            {
                branchContainer.AddBranch(ReadData(path));
            }
            using (var writer = new StreamWriter("ReportTable.txt"));
            CreateReportTable(branchContainer, "ReportTable.txt");
            PrintMostPopularRole(branchContainer);
            Console.WriteLine("2.Išspausdina pasikartojančius veikėjų vardus į Klaidos.csv");
            WriteFilteredPlayersData(branchContainer, "Klaidos.csv");
            Console.ReadKey();
            Console.WriteLine();
            Console.WriteLine("3.Išspausdina tankus pagal gyvybės ir gynybos taškus į Tankai.csv");
            PrintTanks(branchContainer, "Tankai.csv");
            Console.ReadKey();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Įrašo surikiuotus tankus į failą.
        /// </summary>
        /// <param name="branchContainer"></param>
        /// <param name="file"></param>
        public static void PrintTanks(BranchContainer branchContainer, string file)
        {
            var filteredTanks = FindTanks(branchContainer);

            filteredTanks.Heroes.SortHeroes();
            filteredTanks.NPCs.SortNPCs();
            using (var writer = new StreamWriter(file, false, Encoding.UTF8))
            {
                writer.WriteLine("Herojai");
                writer.WriteLine("Vardas;Klasė;Gyvybės taškai;Mana;Žalos taškai;Gynybos taškai;Jėga;Vikrumas;Intelektas;Ypatinga galia");
                for (int i = 0; i < filteredTanks.Heroes.Count; i++)
                {
                    writer.WriteLine(filteredTanks.Heroes.GetHero(i).ToString());
                }
                writer.WriteLine();
                writer.WriteLine("NPC");
                writer.WriteLine("Vardas;Klasė;Gyvybės taškai;Mana;Žalos taškai;Gynybos taškai;Gildija");
                for (int i = 0; i < filteredTanks.NPCs.Count; i++)
                {
                    writer.WriteLine(filteredTanks.NPCs.GetNPC(i).ToString());
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Suranda herojus kurie atitinka tanko parametrus
        /// </summary>
        /// <param name="branches">masyvas su visu rasiu duomenis</param>
        /// <returns>Gražina tankus</returns>
        public static Branch FindTanks(BranchContainer branchContainer)
        {
            var tanks = new Branch();

            for (int i = 0; i < branchContainer.Count; i++)
            {
                for (int j = 0; j < branchContainer.GetBranch(i).Heroes.Count; j++)
                {
                    if (branchContainer.GetBranch(i).Heroes.GetHero(j).IsTank(TankHealth, TankDefence))
                    {
                        tanks.AddHero(branchContainer.GetBranch(i).Heroes.GetHero(j));
                    }
                }

                for (int j = 0; j < branchContainer.GetBranch(i).NPCs.Count; j++)
                {
                    if (branchContainer.GetBranch(i).NPCs.GetNPC(j).IsTank(TankHealth, TankDefence))
                    {
                        tanks.AddNPC(branchContainer.GetBranch(i).NPCs.GetNPC(j));
                    }
                }
            }
            return(tanks);
        }