Exemplo n.º 1
0
        public void Goals(Team homeTeam, Team awayTeam)
        {
            RandomFiller.RandomFiller rnd = new RandomFiller.RandomFiller();
            for (int i = 0; i < goalHome; i++)
            {    
                scorerHome.Add(homeTeam.getScorer());
                GameUtils.wait(30);
            }

            for (int i = 0; i < goalAway; i++)
            {
                scorerAway.Add(awayTeam.getScorer());
                GameUtils.wait(30);
            }
        }
Exemplo n.º 2
0
 private int bonusHome()
 {
     RandomFiller.RandomFiller rnd = new RandomFiller.RandomFiller();
     GameUtils.wait();
     if (rnd.getInt(0, 100) > 66)
     {
        // Console.WriteLine("Ottenuto Goal Home bonus");
         return 1;
     }
     return 0;
 }
Exemplo n.º 3
0
 private int chance()
 {
     RandomFiller.RandomFiller rnd = new RandomFiller.RandomFiller();
     return rnd.getInt(0, 3);
 }
Exemplo n.º 4
0
        private void Simulate()
        {
            RandomFiller.RandomFiller rnd = new RandomFiller.RandomFiller();
            int homepoints = HomeTeam.getAvgTeam();
            int awaypoints = AwayTeam.getAvgTeam();
            int c = rnd.getInt(100);
            if (c > 20)
            {
                //Console.WriteLine("risultato normale");
                int diff = (homepoints - awaypoints);
                if (diff < 0)
                {
                    goalAway = (awaypoints - homepoints) % 6;
                    goalHome = 0;
                    goalHome += chance();
                    goalAway += chance();
                    goalHome += bonusHome();
                }
                else
                {
                    goalHome = (homepoints - awaypoints) % 6;
                    goalAway = 0;
                    goalAway += chance();
                    goalHome += bonusHome();
                }
            }
            else
            {
                //Console.WriteLine("risultato nel 30%");
                goalHome = 0;
                goalAway = 0;
                goalHome += chance();
                goalAway += chance();
                goalHome += bonusHome();
            }

            //Influenza etá
            if (homeTeam.getAvgAge() > 29) { goalHome += bonusHome(); }
            if (awayTeam.getAvgAge() > 29) { goalAway += bonusHome(); }

            if (homeTeam.getAvgAge() < 24) { goalHome += bonusHome(); }
            if (awayTeam.getAvgAge() < 24) { goalAway += bonusHome(); }

            //influenza portiere HOME
            Player tmp;
            try 
	        {	        
		        tmp = homeTeam.getPlayerForRole("PT");
	        }
	        catch (Exception)
	        {
		
		        tmp = new Player("noone","",1,10,"");
	        }

            if (rnd.getInt(0, 100) > (100 - tmp.SkillAvg))
            {
                //Console.WriteLine("paratona HOME! "+tmp.SkillAvg);
                goalAway -= 1;
                if (goalAway < 0) goalAway = 0;
            }

            //Influenza Portiere AWAY
            try
            {
                tmp = awayTeam.getPlayerForRole("PT");
            }
            catch (Exception)
            {

                tmp = new Player("", "", 1, 10, "");
            }

            if (rnd.getInt(0, 100) > (100 - tmp.SkillAvg))
            {
               // Console.WriteLine("paratona AWAY! " + tmp.SkillAvg);
                goalHome -= 1;
                if (goalHome < 0) goalHome = 0;
            }

            //Influenza Campione
            //EVENTUALMENTE se ci fosse un giocatore sulla 95ina potremmo dargli un goal bonus

            GameUtils.wait();
            rnd = new RandomFiller.RandomFiller();
            //influenza modulo: piú difensori meno goal subiti e meno fatti, piú attaccanti piú goal fatti e subiti
            if (AwayTeam.coach != null)
            {
                if (offensiveMod.IndexOf(awayTeam.coach.FavouriteModuleString) != -1) //modulo offensivo
                {
                    if (rnd.getInt(100) > 50) //teoricamente sarebbe meglio fare media attacco
                    {
                        goalAway += 1;
                    }

                    GameUtils.wait();
                    //goal malus per squadra offensiva
                    if (rnd.getInt(100) > 50) //teoricamente sarebbe meglio fare media difesa
                    {
                        goalHome += 1;
                    }

                }
                else if (defensiveMod.IndexOf(AwayTeam.coach.FavouriteModuleString) != -1)//modulo difensivo
                {
                    if (rnd.getInt(100) > 50) //teoricamente sarebbe meglio fare media difesa
                    {
                        goalHome -= 1;
                        if (goalHome < 0) goalHome = 0;
                    }

                }
            }

            if (HomeTeam.coach != null)
            {
                if (offensiveMod.IndexOf(homeTeam.coach.FavouriteModuleString) != -1) //modulo offensivo
                {
                    //goal bonus con squadra offensiva
                    if (rnd.getInt(100) > 50) //teoricamente sarebbe meglio fare media attacco
                    {
                        goalHome += 1;
                    }

                    GameUtils.wait();
                    //goal malus per squadra offensiva
                    if (rnd.getInt(100) > 50) //teoricamente sarebbe meglio fare media difesa
                    {
                        goalAway += 1;
                    }

                }
                else if (defensiveMod.IndexOf(homeTeam.coach.FavouriteModuleString) != -1)//modulo difensivo
                {
                    if (rnd.getInt(100) > 50) //teoricamente sarebbe meglio fare media difesa
                    {
                        goalAway -= 1;
                        if (goalAway < 0) goalAway = 0;
                    }


                }
            }
            



            GameUtils.wait();

        }
Exemplo n.º 5
0
 public void Penalties()
 {
     if (Draw())
     {
         
         RandomFiller.RandomFiller rnd = new RandomFiller.RandomFiller();
         if (rnd.getInt(100) > 50)
         {
             goalHome += 1;
         }
         else
         {
             goalAway += 1;
         }
     }
 }
Exemplo n.º 6
0
        private double CalculateVal()
        {
            double temp = 0;
            RandomFiller.RandomFiller rnd = new RandomFiller.RandomFiller();
            temp = priceOnSkill();
            temp = temp * (1 + onAgeModifier());
            temp += rnd.getInt(1, 3);
            temp -= rnd.getInt(1, 3);

            //Modificatori prezzo sul Ruolo
            if (Role != null)
            {
                if (this.Role == "AC")
                {
                    temp += rnd.getInt(0, 4);

                }
                else if (this.Role == "AS")
                {
                    temp += rnd.getInt(0, 2);
                }
                else if (this.Role == "AD")
                {
                    temp += rnd.getInt(0, 2);
                }
                else if (this.Role == "CC")
                {
                    temp += rnd.getInt(0, 3);
                }
                else if (this.Role == "DC")
                {
                    temp += rnd.getInt(0, 2);
                }
            }
            //

            //Modificatori spiccioli
            if (rnd.getInt(100) > 50)
            {
                temp += (rnd.getInt(1, 5) / 10.0);
            }
            else
            {
                temp -= (rnd.getInt(1, 5) / 10.0);
            }
            //

            if (temp <= 0) temp = 0.1;
            if (temp > 130) temp = 130;

            temp = Math.Round(temp,2);
            this.val = temp;

            return temp;
        }
Exemplo n.º 7
0
        private static double[] CalcolaQuote(List<Team> TeamList)
        {
            RandomFiller.RandomFiller rnd = new RandomFiller.RandomFiller();

            int max;
            int min;
            List<double> quote = new List<double>();
            TeamList.Sort();
            max=TeamList.ElementAt((TeamList.Count-1)).Avg;
            min = TeamList.ElementAt(0).Avg;

            if (max - min > 10)
            {
                double quota = rnd.getInt(4, 6) + (rnd.getInt(1, 8) / 10.0);
                quote.Add(quota);
                quota = rnd.getInt(2, 4) + (rnd.getInt(1, 8) / 10.0);
                quote.Add(quota);
                quota = rnd.getInt(1, 2) + (rnd.getInt(1, 8) / 10.0);
                quote.Add(quota);
                quota = 1 + (rnd.getInt(1, 8) / 10.0);
                quote.Add(quota);

            }
            else
            {
                double quota = rnd.getInt(2, 3) + (rnd.getInt(1, 8) / 10.0);
                quote.Add(quota);
                quota = rnd.getInt(1, 3) + (rnd.getInt(1, 8) / 10.0);
                quote.Add(quota);
                quota = rnd.getInt(1, 2) + (rnd.getInt(1, 8) / 10.0);
                quote.Add(quota);
                quota = 1 + (rnd.getInt(1, 8) / 10.0);
                quote.Add(quota);

            }

            return quote.ToArray();
        }
Exemplo n.º 8
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);


        }