예제 #1
0
        public void GiocatoriCasuali()
        {
            RandomFiller.RandomFiller rndfl = new RandomFiller.RandomFiller();
            Player uno = new Player(rndfl.getName(),rndfl.getSurname(),rndfl.getAge(),rndfl.getAvgSkill(),rndfl.getRole());
            Console.WriteLine(uno.ToString());

        }
예제 #2
0
        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());
            
        }
예제 #3
0
        private int evaluatePlayer(Player tosell)
        {
            double perc = 100;
           // Console.WriteLine("step1: " + perc);
            perc -= (100 - tosell.SkillAvg);
           // Console.WriteLine("onskill: " + perc);
            perc -= ((tosell.Age / 40.0 * 100));
           // Console.WriteLine("\tmodifier: " + (tosell.Age / 40.0 * 100));
            //Console.WriteLine("onage: " + perc);


            return Convert.ToInt32(perc);
        }
예제 #4
0
        static int constant = 43; //constant for selling stuff
        public TryToSellPlayerForm(Player p)
        {
            tosell = p;
            playerteam = MainForm.l.getTeambyTeamName(MainForm.playerteam);
            
            foreach (Team t in MainForm.l.leagueTeams)
            {
                if (t.isplayers != true)
                {
                    teamnames.Add(t.TeamName);
                }
            }

            InitializeComponent();
        }
예제 #5
0
        public void CreaSquadra()
        {
            RandomFiller.RandomFiller rndfl = new RandomFiller.RandomFiller();
            Team sq = new Team("Banana UTD");
            for (int i = 0; i < 11; i++)
            {

                Player uno = new Player(rndfl.getName(), rndfl.getSurname(), rndfl.getAge(), rndfl.getAvgSkill(), rndfl.getRole());

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


            Console.WriteLine(sq.ToStringFull());

        }
예제 #6
0
파일: Offer.cs 프로젝트: vikkio88/dsmanager
        public Offer()
        {
            Random rnd = new Random();
            playerteam = MainForm.l.getTeambyTeamName(MainForm.playerteam);

            foreach (Team t in MainForm.l.leagueTeams)
            {
                if (t.isplayers != true)
                {
                    teamnames.Add(t.TeamName);
                }
            }

            other = MainForm.l.getTeambyTeamName(teamnames.ElementAt(rnd.Next(teamnames.Count)));
            tosell = playerteam.getPlayer(rnd.Next(playerteam.NumbOfPlayers));

            InitializeComponent();
        }
예제 #7
0
 public void TestValoreGiocatoriReali()
 {
     Player giocatore = new Player("Paul", "Pogba", 21, 79, "CC", "Francese");
     Console.WriteLine(giocatore.ToString());
     giocatore = new Player("Arturo", "Vidal", 28, 85, "CC", "Cileno");
     Console.WriteLine(giocatore.ToString());
     giocatore = new Player("Lionel", "Messi", 27, 95, "AS", "Argentino");
     Console.WriteLine(giocatore.ToString());
     giocatore = new Player("Robin", "VanPersie", 31, 89, "AC", "Olandese");
     Console.WriteLine(giocatore.ToString());
     giocatore = new Player("Alvaro", "Morata", 22, 76, "AC", "Spagnolo");
     Console.WriteLine(giocatore.ToString());
 }
예제 #8
0
 public void TestCTORPlayerConNazionalitaDiverse()
 {
     RandomFiller.RandomFiller rnd = new RandomFiller.RandomFiller();
     Player pl = new Player(rnd.getName("Spain"), rnd.getSurname("Spain"),rnd.getAge(),rnd.getAvgSkill(),"Spain");
     Console.WriteLine(pl.ToString());
 }
예제 #9
0
 public SpeakWithPlayer(Player p) 
 {
     playertobuy = p;
     playersteam = MainForm.l.getTeambyTeamName(MainForm.playerteam);
     InitializeComponent();
 }
예제 #10
0
파일: Team.cs 프로젝트: vikkio88/dsmanager
 public void rmPlayer(Player pl)
 {
     players.Remove(pl);
 }
예제 #11
0
 private void trytobuy(Player cpl, Team cteam)
 {
     Console.Clear();
     Console.WriteLine("Trying to buy "+cpl.ToString()+" from "+ cteam.TeamName);
     double req = Math.Round((cpl.Val + (GameUtils.getWage(0, 5))), 2);
     Console.WriteLine("\t they asked: "+req+" M Euro\n your offer [money owned: "+money+" M euro] > ");
     double off = MyConsole.AskForDouble(money);
     if (off <= money && off>0)
     {
         Console.WriteLine(off+"M euro ...offert sent..");
         GameUtils.wait(1000);
         Console.WriteLine("Offert received...");
         Console.Write("...We are thinking about it...");
         GameUtils.wait(1000);
         Random rnd = new Random();
         if (off - req > 10)
         {
             Console.WriteLine("we accept your generous offer...");
             Player tmp = cteam.popPlayer(cpl);
             plt.addPlayer(tmp);
             Console.WriteLine("\t you hired " + tmp.ToString() + " ");
             report("+ " + cpl.ToStringShort() + " - val: " + cpl.Val + " - off: " + off + " M euro, from "+cteam.TeamName,bought);
             checkrecordbought(cpl.ToStringShort() + " - val: " + cpl.Val + " - off: " + off + " M euro, from " + cteam.TeamName, off);
             money -= off;
         }
         else if (off >= req)
         {
             if (rnd.Next(100) > 20)
             {
                 Console.WriteLine("we accept your offer...");
                 Player tmp = cteam.popPlayer(cpl);
                 plt.addPlayer(tmp);
                 Console.WriteLine("\t you hired "+tmp.ToString()+" ");
                 report("+ " + cpl.ToStringShort() + " - val: " + cpl.Val + " - off: " + off + " M euro, from " + cteam.TeamName,bought);
                 checkrecordbought(cpl.ToStringShort() + " - val: " + cpl.Val + " - off: " + off + " M euro, from " + cteam.TeamName, off);
                 money -= off;
             }
             else
             {
                 Console.WriteLine("We refuse your offer...");
             }
         }
         else
         {
             if (rnd.Next(100) > 50)
             {
                 Console.WriteLine("we accept your offer...");
                 Player tmp = cteam.popPlayer(cpl);
                 plt.addPlayer(tmp);
                 Console.WriteLine("\t you hired " + tmp.ToString() + " ");
                 report("+ " + cpl.ToStringShort() + " - val: " + cpl.Val + " - off: " + off + " M euro, from " + cteam.TeamName,bought);
                 checkrecordbought(cpl.ToStringShort() + " - val: " + cpl.Val + " - off: " + off + " M euro, from " + cteam.TeamName, off);
                 money -= off;
             }
             else
             {
                 Console.WriteLine("We refuse your offer...");
             }
         }
     }else if(off<=0){
         Console.WriteLine("We kindly refuse your shitty offer");
     }
     else
     {
         Console.WriteLine("You dont have enough money...");
     }
     EnterToContinue();
 }
예제 #12
0
        private bool ElavuateOffer(Player p,double off)
        {

            return false;
        }
예제 #13
0
        private void trytobuy(Player cpl,bool fromyouth = false)
        {
            Console.Clear();
            Console.WriteLine("Trying to buy " + cpl.ToString() + " from  FreePlayers List");
            double req = Math.Round((cpl.Val * 0.3 + (GameUtils.getWage(0, 5))), 2);
            Console.WriteLine("\t He asked: " + req + " M Euro\n your offer [money owned: " + money + " M euro] ");
            double off = MyConsole.AskForDouble(money);
            if (off <= money)
            {
                Console.WriteLine(off + "M euro ...offert sent..");
                GameUtils.wait(1000);
                Console.WriteLine("Offert received...");
                Console.Write("...I am thinking about it...");
                GameUtils.wait(1000);
                Random rnd = new Random();
                if (off >= req)
                {
                    if (rnd.Next(100) > 5)
                    {
                        Console.WriteLine("I accept your offer...");
                        //Player tmp = cteam.popPlayer(cpl);
                        plt.addPlayer(cpl);
                        Console.WriteLine("\t you hired " + cpl.ToString() + " ");
                        if (!fromyouth)
                        {
                            
                            report("+ " + cpl.ToStringShort() + " - val: " + cpl.Val + " - off: " + off + " M euro, Parametro 0", bought);
                            checkrecordbought(cpl.ToStringShort() + " - val: " + cpl.Val + " - off: " + off + " M euro, Parametro 0", off);
                        }
                        else
                        {
                            report("+ " + cpl.ToStringShort() + " - val: " + cpl.Val + " - off: " + off + " M euro, from YouthClub", bought);
                            checkrecordbought(cpl.ToStringShort() + " - val: " + cpl.Val + " - off: " + off + " M euro, from YouthClub", off);
                        }

                        money -= off;
                    }
                    else
                    {
                        Console.WriteLine("I refuse your offer...");
                    }
                }
                else
                {
                    if (rnd.Next(100) > 50)
                    {
                        Console.WriteLine("I accept your offer...");
                       // Player tmp = cteam.popPlayer(cpl);
                        plt.addPlayer(cpl);
                        Console.WriteLine("\t you hired " + cpl.ToString() + " ");
                        if (!fromyouth)
                        {
                            checkrecordbought(cpl.ToStringShort() + " - val: " + cpl.Val + " - off: " + off + " M euro, Parametro 0", off);
                            report("+ " + cpl.ToStringShort() + " - val: " + cpl.Val + " - off: " + off + " M euro, Parametro 0", bought);
                        }
                        else
                        {
                            report("+ " + cpl.ToStringShort() + " - val: " + cpl.Val + " - off: " + off + " M euro, from YouthClub", bought);
                            checkrecordbought(cpl.ToStringShort() + " - val: " + cpl.Val + " - off: " + off + " M euro, from YouthClub", off);
                        }
                        money -= off;
                    }
                    else
                    {
                        Console.WriteLine("I refuse your offer...");
                    }
                }
            }
            else if (off <= 0)
            {
                Console.WriteLine("I kindly refuse your shitty offer");
            }
            else
            {
                Console.WriteLine("You dont have enough money...");
            }

            EnterToContinue();
        }
예제 #14
0
        private void addToScorer(Player pl, Team team)
        {
            //Attenzione possono esistere giocatori con lo stesso nome in
            //squadre diverse

            if (!scorers.ContainsKey(pl))
            {
                TeamGoals tg;
                tg.TeamName = team.TeamName;
                tg.goals = 1;

                scorers.Add(pl, tg);
                //scorers.Add(pl, team.TeamName, 1);
            }
            else
            {
                TeamGoals temp = scorers[pl];
                temp.goals += 1;
                scorers[pl] = temp;
            }
        }
예제 #15
0
파일: Team.cs 프로젝트: vikkio88/dsmanager
 public void addPlayer(Player p)
 {
     players.Add(p);
 }
예제 #16
0
        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);

            }

        }
예제 #17
0
파일: Match.cs 프로젝트: vikkio88/dsmanager
        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();

        }
예제 #18
0
파일: Team.cs 프로젝트: vikkio88/dsmanager
 public Player popPlayer(Player pl)
 {
     return popPlayerAt(players.IndexOf(pl));
 }