Exemplo n.º 1
0
 private static void FireCoachW(Team plt)
 {
     //throw new NotImplementedException();
     losecounter = 0;
     drawcounter = 0;
     Coach c = GameUtils.getRandomCoach();
     Console.WriteLine("You fired your Coach\nThe president choose to hire \n" + c.ToString() + "\n as new coach");
     plt.setCoach(c);
 }
Exemplo n.º 2
0
        private static void FireCoach()
        {
           // throw new NotImplementedException();
            Team playersteam = new Team("bla");
            foreach (Team t in l.leagueTeams)
            {
                if (t.isplayers) playersteam = t;
            }

            if (l.getTeamByTablePosition(l.NumbOfTeam).TeamName != playersteam.TeamName)
            {
                double off =GameUtils.getWage(1,3);
                Console.WriteLine("Your Coach, " + playersteam.coach.ToStringShort() + " want a raise of "+off);
                Console.Write("\t do you want to? [y/n]> ");

                string s = Console.ReadLine();
                if (s == "y")
                {
                    Console.WriteLine("\t you paid "+off+" M Euro, to keep your Coach");
                    money -= off;
                }
                else
                {
                    Coach c = GameUtils.getRandomCoach();
                    Console.WriteLine("The president choose to hire \n"+ c.ToString()+"\n as new coach");
                    playersteam.setCoach(c);
                }
            }
            else
            {
                Console.WriteLine("You finished last this year, want to fire your coach " + playersteam.coach.ToStringShort() + "? ");
                Console.Write("\t[y/n]> ");

                string s = Console.ReadLine();
                if (s == "y")
                {
                    Coach c = GameUtils.getRandomCoach();
                    Console.WriteLine("The president choose to hire \n" + c.ToString() + "\n as new coach");
                    playersteam.setCoach(c);
                }
                else
                {
                    Console.WriteLine("\t you must love your Coach...");

                }
            }

            playersteam.coach.FavouriteModule = GameUtils.getRandomCoach().FavouriteModule;
            Console.WriteLine("\t"+playersteam.coach.ToStringShort() + " module for the next year: " + playersteam.coach.FavouriteModule);

        }
Exemplo n.º 3
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();

        }
Exemplo n.º 4
0
        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());

        }
Exemplo n.º 5
0
        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());

        }
Exemplo n.º 6
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);
        }