Exemple #1
0
       // static Team playerteam;
        static void Main(string[] args)
        {
            inizializePlayer();
            int A = 1;
            Console.WriteLine("Generate a random League(1) or Use a File(2)?");
            A = MyConsole.AskForInt(2);
            if (A == 1)
            {
                Console.WriteLine("How many Teams do you want in your League? [4/18]");
                int a;
                try
                {
                    a = int.Parse(Console.ReadLine());
                    if (a < 4)
                    {
                        throw new Exception("Too enough Teams");
                    }

                    if (a > 18)
                    {
                        throw new Exception("Too Many Teams");
                    }

                    if (a % 2 != 0)
                    {
                        //throw new Exception("Must be a pair number of Teams");
                        a += 1;
                    }

                    if (a <= 0)
                    {
                        throw new Exception("Not enough teams");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error: " + e.Message + "\n team number choose by default 8");
                        a=8;
                }

                Console.WriteLine("Hit enter to generate a random League");
                Console.ReadKey();
                Console.Write("generating...");
                l = new League(GameUtils.getRandomTeamsList(a));
                Console.WriteLine("done!");
            }
            else
            {
                Console.Write("Reading configuration file...");
                List<string> teamNameList = ReadTeamNameFromFile();
                List<Team> teamList = new List<Team>();
                Console.WriteLine("done!\n\nReading Teams...");
                foreach (string team in teamNameList)
                {
                    Console.WriteLine("Reading "+team+" ...");

                    Team temp = new Team(UppercaseFirst(team));
                    Console.Write("Reading " + team + " players from file...");
                    temp.addPlayers(GameUtils.generatePlayersFromFile(team+".txt"));
                    Console.WriteLine("done!\nSetting a Random Coach...");
                    temp.setCoach(GameUtils.getRandomCoachList().ElementAt(0));
                    Console.WriteLine("team "+ team+" completed...");
                    teamList.Add(temp);
                    GameUtils.wait();
                }
                l = new League(teamList);
                l.generateFixture();
                Console.WriteLine("done!");
            }

            Console.WriteLine("Enter to start...");
            Console.ReadLine();
            Console.Clear();

            chooseTeam();

            foreach (Team item in l.leagueTeams)
            {
                if (item.isplayers) playerteam = item.TeamName;
            }

            string cmd = "";
            while (cmd != "q")
            {
                command(ref cmd);
            }
            quit();

        }
        public void TestPartitaConSquadreConModuloAdatto()
        {
            RandomFiller.RandomFiller rnd = new RandomFiller.RandomFiller();
            Team a = new Team(rnd.getTeamName());
            GameUtils.wait();
            Team b = new Team(rnd.getTeamName());
            List<Coach> coachl = GameUtils.getRandomCoachList(2);

            a.setCoach(coachl.ElementAt(0));
            b.setCoach(coachl.ElementAt(1));

            a.addPlayers(GameUtils.getRandomPlayersForModule(coachl.ElementAt(0).FavouriteModule));
            b.addPlayers(GameUtils.getRandomPlayersForModule(coachl.ElementAt(1).FavouriteModule));

            Match m = new Match(a, b);
            Console.WriteLine(a.ToStringFull());
            Console.WriteLine(b.ToStringFull());
            Console.WriteLine("\n*********\n" + a.Avg + " : " + b.Avg);
            Console.WriteLine(a.TeamName + " - " + b.TeamName + " " + m.Score().ToString());

        }
        public void TestPartitaConGiocatoriVeri()
        {
            Team juve = new Team("Juventus FC");
            Coach all = new Coach("Massimiliano", "Allegri", 80, "4-3-3");
            juve.setCoach(all);

            List<Player> juvteam = new List<Player>(){
                                                        new Player("Gigi","Buffon",36,87,"PT"),
                                                        new Player("Patrice","Evrá",33,82,"DS"),
                                                        new Player("Giorgio","Chiellini",30,86,"DC"),
                                                        new Player("Andrea","Barzagli",33,84,"DC"),
                                                        new Player("Paul", "Pogba", 21, 80, "CC", "Francese"),
                                                        new Player("Andrea", "Pirlo", 35, 87, "CC"),
                                                        new Player("Arturo", "Vidal", 28, 85, "CC", "Cileno"),
                                                        new Player("Kwadwo", "Asamoah", 26, 80, "AS", "Ghanese"),
                                                        new Player("Stephen", "Lichsteiner", 30, 80, "DD", "Svizzero"),
                                                        new Player("Carlitos", "Tevez", 30, 88, "AD", "Argentino"),
                                                        new Player("Fernando", "Llorente", 29, 82, "AC", "Spagnolo")
                                                        };
            juve.addPlayers(juvteam);

          /*  Module mod = all.FavouriteModule;

            Console.WriteLine("Modulo: " + mod.check(juve).ToString());*/

            Team milan = new Team("AC Milan");
            Coach all1 = new Coach("Filippo", "Inzaghi", 70, "4-4-2");
            milan.setCoach(all1);
            List<Player> milteam = new List<Player>(){
                                                        new Player("Christian","Abbiati",37,80,"PT"),
                                                        new Player("Kevin","Constant",27,78,"DD"),
                                                        new Player("Mattia","De Sciglio",22,78,"DS"),
                                                        new Player("Daniele","Bonera",33,77,"DC"),
                                                        new Player("Amil", "Rami", 29, 82, "DC", "Francese"),
                                                        new Player("Riccardo", "Montolivo", 29, 84, "CC"),
                                                        new Player("Keisuke", "Honda", 28, 81, "CC", "Giapponese"),
                                                        new Player("Neigel", "De Jong", 30, 79, "CC", "Olandese"),
                                                        new Player("Michael", "Essien", 32, 81, "CC", "Ghanese"),
                                                        new Player("Stephan", "El Shaarawy", 22, 81, "AC"),
                                                        new Player("Mario", "Balotelli", 24, 84, "AC")
                                                        };
            milan.addPlayers(milteam);


            //Partita
            Match m = new Match(juve, milan);
            Console.WriteLine(juve.ToStringFull());
            Console.WriteLine(milan.ToStringFull());
            Console.WriteLine("\n*********\n" + juve.Avg + " : " + milan.Avg);
            Console.WriteLine(juve.TeamName + " - " + milan.TeamName + " " + m.Score().ToString());

        }
Exemple #4
0
        private void btnGenerateTeamsFromFiles_Click(object sender, EventArgs e)
        {
            DisableGenerators();
           lblStatus.Text = "Reading configuration file...";
            List<string> teamNameList = ReadTeamNameFromFile();
            List<Team> teamList = new List<Team>();
            StreamMessageInStatus("done!\n\nReading Teams...");
            foreach (string team in teamNameList)
            {
                Console.WriteLine("Reading " + team + " ...");

                Team temp = new Team(UppercaseFirst(team));
                Console.Write("Reading " + team + " players from file...");
                temp.addPlayers(GameUtils.generatePlayersFromFile(team + ".txt"));
                Console.WriteLine("done!\nSetting a Random Coach...");
                temp.setCoach(GameUtils.getRandomCoachList().ElementAt(0));
                Console.WriteLine("team " + team + " completed...");
                teamList.Add(temp);
                GameUtils.wait();
            }
            l = new League(teamList);
            l.generateFixture();
            Console.WriteLine("done!");
            StreamMessageInStatus("Completed");
            TeamListToListBox(l.leagueTeams, lstTeams);
        }