public void SimulazionePartita()
        {
            RandomFiller.RandomFiller rndfl = new RandomFiller.RandomFiller();
            Team sq, sq1;
            if (rndfl.getInt(100) > 50)
            {
                sq = new Team("Milan");
                sq1 = new Team("Juventus");
            }
            else
            {
                sq1 = new Team("Milan");
                sq = new Team("Juventus");
            }
           // Team sq = new Team("Milan");
            for (int i = 0; i < 11; i++)
            {

                Player uno = new Player();
                uno.PlayerName = rndfl.getName();
                uno.PlayerSurname = rndfl.getSurname();
                uno.SkillAvg = rndfl.getInt(10, 100);
                uno.Age = rndfl.getInt(15, 39);

                sq.addPlayer(uno);
                //Console.WriteLine(uno.ToString());
            }


            Console.WriteLine(sq.ToString());

         //   RandomFiller.RandomFiller rndfl = new RandomFiller.RandomFiller();
         //   Team sq1 = new Team("Juventus");
            for (int i = 0; i < 11; i++)
            {

                Player uno = new Player();
                uno.PlayerName = rndfl.getName();
                uno.PlayerSurname = rndfl.getSurname();
                uno.SkillAvg = rndfl.getInt(40, 100);
                uno.Age = rndfl.getInt(15, 39);

                sq1.addPlayer(uno);
                //Console.WriteLine(uno.ToString());
            }


            Console.WriteLine(sq1.ToString());

            Match partita = new Match(sq, sq1);
            Console.WriteLine(sq.TeamName+" - "+ sq1.TeamName+" "+ partita.Score().ToString());
            
        }
        public void TestSuTantePartite()
        {
            RandomFiller.RandomFiller rndfl = new RandomFiller.RandomFiller();
            Team sq, sq1;
            for (int j = 0; j < 20; j++)
            {
                if (rndfl.getInt(100) > 50)
                {
                    sq = new Team("Milan");
                    sq1 = new Team("Juventus");
                }
                else
                {
                    sq1 = new Team("Milan");
                    sq = new Team("Juventus");
                }
                // Team sq = new Team("Milan");
                for (int i = 0; i < 11; i++)
                {

                    Player uno = new Player();
                    uno.PlayerName = rndfl.getName();
                    uno.PlayerSurname = rndfl.getSurname();
                    uno.SkillAvg = rndfl.getInt(40, 100);
                    uno.Age = rndfl.getInt(15, 39);

                    sq.addPlayer(uno);

                }

                for (int i = 0; i < 11; i++)
                {

                    Player uno = new Player();
                    uno.PlayerName = rndfl.getName();
                    uno.PlayerSurname = rndfl.getSurname();
                    uno.SkillAvg = rndfl.getInt(40, 100);
                    uno.Age = rndfl.getInt(15, 39);

                    sq1.addPlayer(uno);

                }




                Match partita = new Match(sq, sq1);
       
                Console.WriteLine("\n*********\n" + sq.getAvgTeam().ToString() + " : " + sq1.getAvgTeam().ToString());
                Console.WriteLine(sq.TeamName + " - " + sq1.TeamName + " " + partita.Score().ToString());
                System.Threading.Thread.Sleep(50);

            }

        }
        public void TestPartitaConRigori()
        {
            Team a = GameUtils.getRandomTeamsList().First();
            Team b = GameUtils.getRandomTeamsList().First();

            Match m = new Match(a, b);
            Console.WriteLine(a.TeamName+" - "+b.TeamName+" "+m.Score().ToString());

            if (m.Draw())
            {
                Console.WriteLine("Pareggio, ai rigori");
                m.Penalties();
                Console.WriteLine("dopo i rigori vince:");
                Console.WriteLine(m.Winner().TeamName);
            }
         
            
        }
        public void TestSimulazioniTantePartiteCasuali()
        {
            for (int i = 0; i < 10; i++)
            {


                List<Team> list = GameUtils.getRandomTeamsList(2);
                Team a = list.ElementAt(0);
                Team b = list.ElementAt(1);

                /*
                Team b = new Team("Juventus FC");
                b.addPlayers(GameUtils.getRandomPlayersList(20));
                */

                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().ToStringTiny());
            }
        }
        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());

        }
        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());

        }
Beispiel #7
0
        static void Main(string[] args)
        {
            double euro = 10;
            int num = 0;

            StampaBanner();
            Console.ReadKey();
            char q='0';
            while(q!='q'){
                num++;
                double scommessa = 0.0;
                euro = Math.Round(euro,2);
                Console.Clear();
                List<Team> TeamList = GameUtils.getRandomTeamsList(4);
                double[] quote = CalcolaQuote(TeamList);
                Team fav;
                Console.WriteLine("Partita numero: "+num);
                Console.WriteLine("Abbiamo le seguenti squadre:");
                int c = 1;
                foreach (Team team in TeamList)
                {
                    Console.WriteLine(c+".  "+team.TeamName+" media: "+ team.Avg +"%" + "\tquota: "+quote[c-1]);
                    c++;
                }

                Console.Write("Hai "+euro.ToString()+" Euro\n su quale scommetti?  > ");
                try
                {
                    c= int.Parse(Console.ReadLine());
                    fav = TeamList.ElementAt(c - 1);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Niente hai sbagliato, scelto io per te... la prima");
                    c=1;
                    fav = TeamList.ElementAt(0);
                }
                Console.WriteLine("\t\t---> " + fav.TeamName);
                
                while (!((scommessa <= euro)&&(scommessa!=0.0)&&(scommessa>0)))
                {
                    Console.WriteLine("Quanti euro scommetti?");
                    scommessa = double.Parse(Console.ReadLine());
                    if (scommessa > euro)
                    {
                        Console.WriteLine("Accettiamo solo contanti...");
                    }

                    if (scommessa == 0.0 || scommessa < 0.0)
                    {
                        Console.WriteLine("E che minchia sei venuto a scommettere?");
                    }
                }

                Console.WriteLine("\t\tscommessa piazzata---> " + fav.TeamName + " - Winner:" + quote[c - 1] + " x " + scommessa + " EUR");

                RandomFiller.RandomFiller rnd = new RandomFiller.RandomFiller();

                Team f1;
                Team f2;
                Console.WriteLine("Semifinali");

                GameUtils.wait(1000);

                Match sf1 = new Match(TeamList.ElementAt(0), TeamList.ElementAt(1));
               // Console.WriteLine("\n*********\n" + TeamList.ElementAt(0).Avg + " : " + TeamList.ElementAt(1).Avg);
                Console.Write(TeamList.ElementAt(0).TeamName + " - " + TeamList.ElementAt(1).TeamName + " ");
           
                GameUtils.wait(2000);
                Console.WriteLine(sf1.Score().ToStringTiny());
            
                if (!sf1.Draw())
                {
                    f1 = sf1.Winner();
                    Console.WriteLine("\tvince: " + f1.TeamName);
                }
                else
                {
                    Console.Write("Dopo i rigori...");
                    f1 = TeamList.ElementAt(rnd.getInt(1));
                    Console.WriteLine("\tvince: "+ f1.TeamName);
                }
                Console.WriteLine("Enter per continuare");
                Console.ReadLine();

                Match sf2 = new Match(TeamList.ElementAt(2), TeamList.ElementAt(3));
               // Console.WriteLine("\n*********\n" + TeamList.ElementAt(2).Avg + " : " + TeamList.ElementAt(3).Avg);
                Console.Write(TeamList.ElementAt(2).TeamName + " - " + TeamList.ElementAt(3).TeamName + " ");
                GameUtils.wait(2000);
                Console.WriteLine(sf2.Score().ToStringTiny());
                if (!sf2.Draw())
                {
                    f2 = sf2.Winner();
                    Console.WriteLine("\tvince: " + f2.TeamName);
                }
                else
                {
                    Console.Write("Dopo i rigori...");
                    f2 = TeamList.ElementAt(rnd.getInt(2,3));
                    Console.WriteLine("\tvince: " + f2.TeamName);
                }

                Console.WriteLine("Enter per continuare");
                Console.ReadLine();

                Team W;
                Console.WriteLine("Finale");
                Match f = new Match(f1,f2);
              //  Console.WriteLine("\n*********\n" + f1.Avg + " : " + f2.Avg);
                Console.Write(f1.TeamName + " - " + f2.TeamName + " ");
                GameUtils.wait(2000);
                Console.WriteLine(f.Score().ToStringTiny());
                if (!f.Draw())
                {
                    W = f.Winner();
                }
                else
                {
                    Console.Write("Dopo i rigori...");
                    if (rnd.getInt(100) > 50)
                    {
                        W = f1;
                    }
                    else
                    {
                        W = f2;
                    }
                    Console.WriteLine("vince: " + W.TeamName);
                }

                Console.WriteLine("\t\tVince il torneo: "+W.TeamName);
                GameUtils.wait(1000);
                Console.WriteLine("**************************");
                Console.WriteLine("Tu avevi scommesso su: "+fav.TeamName);
                GameUtils.wait(1000);
                
                if (fav.TeamName == W.TeamName)
                {
                    Console.WriteLine("Hai vinto " + scommessa * quote[c - 1] + " Euro");
                    euro += scommessa * quote[c - 1];
                }
                else
                {
                    Console.WriteLine("Hai perso");
                    euro -= scommessa;
                }

                if (euro < 1.0)
                {
                    gameover(euro, num);
                }

                Console.WriteLine("\n\nTi rimangono "+euro+" Euro\nEnter per giocare di nuovo, inserisci 'q' per uscire");
               
                try
                {
                    q = char.Parse(Console.ReadLine());
                }
                catch (Exception e)
                {
                    q= '0';
                }


            }
            gameover(euro, num);


        }