private void MarketSummer_Load(object sender, EventArgs e) { Program.formFixing(this); currentround = 1; string coachreport = GameUtils.CheckCoachWorkString(MainForm.l); txtEvents.Text += coachreport + "\r\n"; string agingreport = GameUtils.AgePlayersString(MainForm.l); txtEvents.Text += agingreport+"\r\n"; string randommarketreport = GameUtils.CalciomercatoRandomString(MainForm.l); txtEvents.Text += randommarketreport; playersteam = MainForm.l.getTeambyTeamName(MainForm.playerteam); FillTeamInfo(); FillLst(playersteam); btnMyTeam.Focus(); }
private void TryToSellPlayerForm_Load(object sender, EventArgs e) { Program.formFixing(this); Random rnd = new Random(); double probabilitytosell = constant + (100 - (tosell.Age / 40.0 * 100)); if (GameUtils.getProbability(Convert.ToInt32(probabilitytosell))) // probabilitá di vendere giocatore legata all'etá { int c = evaluatePlayer(tosell); off = Math.Round((tosell.Val + (tosell.Val * (c / 100.0))),2); other = MainForm.l.getTeambyTeamName(teamnames.ElementAt(rnd.Next(0, teamnames.Count))); txtOffer.Text = other.TeamName + " offer " + off + " M € for this Player"; } else { txtOffer.Text = "No offers for this Player"; btnAccept.Enabled = false; btnReject.Enabled = false; button1.Visible = true; } txtPlayerInfo.Text = tosell.ToString(); }
private void FillLst(Team playersteam) { List<string> pls = new List<string>(); foreach (Player pl in playersteam.players) { pls.Add(pl.ToStringShort()+" "+pl.Role); } lstPlayers.DataSource = pls; }
public static int[] playersForRolesinTeam(Team t) { int[] nplayr = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; List<string> roles = new List<string>() { "PT", "DC", "DD", "DS", "CC", "CD", "CS", "AD", "AS", "AC" }; foreach (Player pl in t.getPlayers()) { int i = roles.IndexOf(pl.Role); if (i >= 0) nplayr[i] += 1; } return nplayr; }
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()); }
private void MyTeamForm_Load(object sender, EventArgs e) { Program.formFixing(this); this.Text = MainForm.playerteam + " Info"; playersteam = MainForm.l.getTeambyTeamName(MainForm.playerteam); FillLst(playersteam); FillTeamInfo(); btnQuit.Focus(); }
private void SpeakWithCoachForm_Load(object sender, EventArgs e) { Program.formFixing(this); playersteam = MainForm.l.getTeambyTeamName(MainForm.playerteam); c = playersteam.coach; txtCoachInfo.Text = c.ToString(); AddTeamInfo(); txtCoachWords.Text = c.CoachName+" : Hello mr " + MainForm.playername + ", I heard you wanted to talk with me... what is the matter?"; btnGoodJob.Focus(); }
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(); }
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); } }
public bool check(Team t, Module m) { foreach (Player pl in t.getPlayers()) { int i = roles.IndexOf(pl.Role); if (i >= 0) nplayr[i] += 1; } int length = nplayr.Count(); int[] needed = playerForRolesForModule(m.SelectedModule); for (int i = 0; i < length; i++) { if (nplayr[i] < needed[i]) return false; } return true; }
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()); }
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(); }
//static Dictionary<Player, string> loaned = new Dictionary<Player, string>(); public MarketPlaceSimulator(League le, double m) { this.l = le; this.money = m; this.otherst = new List<Team>(); this.bought = new List<string>(); this.sold = new List<string>(); this.youthclub = new List<Player>(); foreach (Team t in this.l.leagueTeams) { if (t.isplayers) { this.plt = t; } else { otherst.Add(t); } } }
public bool check(Team t) { return check(t, this); }
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); } }
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; } }
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()); }
public void TestGiocatoriPerOgniRuoloperSquadra() { List<Player> players = GameUtils.getRandomPlayersList(20); Team t = new Team("Juventus"); foreach (Player item in players) { t.addPlayer(item); } Console.WriteLine(t.ToStringFull()); int[] plfr = Module.playersForRolesinTeam(t); List<string> rol = Module.getRoles(); int length = plfr.Count(); for (int i = 0; i < length; i++) { if (plfr[i] > 0) { Console.WriteLine(rol.ElementAt(i)+" : "+plfr[i].ToString()); } } }
private Player choosePlayer(Team cteam) { int n; try { n = int.Parse(Console.ReadLine()); if (n > otherst.Count) { throw new Exception(); } if (n < 1) { throw new Exception(); } } catch (Exception e) { n = 1; } return cteam.getPlayer(n - 1); }
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); }
// 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 YouthClubForm(List<Player> y) { youthcl = y; plteam = MainForm.l.getTeambyTeamName(MainForm.playerteam); InitializeComponent(); }
public SpeakWithPlayer(Player p) { playertobuy = p; playersteam = MainForm.l.getTeambyTeamName(MainForm.playerteam); InitializeComponent(); }
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); }
private Player printPlayers(Team cteam) { int c = 1; foreach (Player pl in cteam.players) { Console.WriteLine(c+". "+pl.ToString()); c++; } int n; printPlayerPerRoleAndMoneyInfo(); Console.Write("Choose the player > "); try { n = int.Parse(Console.ReadLine()); if (n > otherst.Count) { throw new Exception(); } if (n < 1) { throw new Exception(); } } catch (Exception e) { n = 1; } return cteam.players.ElementAt(n - 1); }
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); }
public void TestModuloEValidita() { Module m = new Module("4-4-2"); List<Player> players = GameUtils.getRandomPlayersList(20); Team t = new Team("Ababa"); foreach (Player item in players) { t.addPlayer(item); } Console.WriteLine(t.ToStringFull()); if (m.check(t, m)) Console.WriteLine("OK"); else Console.WriteLine("Nope"); }
public Match(Team a, Team b) { homeTeam = a; awayTeam = b; }
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(); }