public void SetBattingOrder(Objects.Team team, MLB mlb, PlayersRoster players, TeamManager teamManager) { //team.battingOrder = Players.Where(T => T.Team.Equals(team.Abbrev)).DefaultIfEmpty().ToList(); if (mlb.Teams.Any(T => T.Abbrev.Equals(team.Abbrev))) { teamManager.BattingOrder = Players.Where(T => T.Team.Equals(team.Abbrev)).DefaultIfEmpty().ToList(); } else { PickLineUp lineUp = new PickLineUp(); teamManager.BattingOrder = lineUp.GetPlayers(players, mlb); } }
public void SettingNewTeam(Objects.Team team, MLB mlb, string choice, bool atAway) { if (!mlb.Teams.Any(T => T.Abbrev.ToLower().Equals(choice.ToLower()))) { team.Abbrev = choice; team.Name = choice; Output.WriteStringOutput("What DefEff you want this team to have? MLB average is 0.687, right now ranging from 0.669-0.719"); team.DefEff = Convert.ToDouble(Console.ReadLine()); Output.WriteStringOutput("Just need 2 more things. Fielding Recentage? MLB average is 0.983, right now ranging from 0.976-0.989"); team.FP = Convert.ToDouble(Console.ReadLine()); if (atAway) { Output.WriteStringOutput("What about On-Base Average (Pitching) when playing at Away? MLB is right now ranging between 0.229-0.278"); team.OBAAway = Convert.ToDouble(Console.ReadLine()); } else { Output.WriteStringOutput("What about On-Base Average (Pitching) when playing at Home? MLB is right now ranging between 0.214-0.298"); team.OBAHome = Convert.ToDouble(Console.ReadLine()); } } }
static void Main(string[] args) { #region ctor Console.SetWindowSize(120, 28); Output.ScreenOutput = new List <Tuple <string, int, int> >(); Output.StartTimer(); BallPark3.ApplicationData.DefaultApplicationFolder = "BallPark"; BallPark3.ApplicationData.DefaultCompanyFolder = "Oddsphere"; BallPark3.ApplicationData.DefaultAdditionalPath = ""; var DataFolder = new BallPark3.ApplicationData().ApplicationFolderPath; var teams = new MLB(); var players = new PlayersRoster(); var teamManagerOne = new TeamManager(); var teamManagerTwo = new TeamManager(); var teamOneTotal = 0; var teamTwoTotal = 0; //var Squad = (Objects.Team)TeamManager; #endregion players.Players = BallPark3.Serialization.ReadObject <List <Objects.Player> >(System.IO.File.ReadAllBytes(DataFolder + "\\players.dat")); teams.Teams = BallPark3.Serialization.ReadObject <List <Objects.Team> >(System.IO.File.ReadAllBytes(DataFolder + "\\teams.dat")); Output.WriteStringOutput("Ready? (y/n)", 2, 2); var input = Console.ReadLine(); Output.ClearScreen(); while (input != "") { if (!input.Equals("n")) { Random random = new Random(); MLB.CurrentTeams(teams.Teams); Output.WriteStringOutput("Choose a team to play: ", 2, 2); var teamOne = new Team(); var inputOne = Console.ReadLine(); teamOne = TeamManager.TeamSelection(teams.Teams, inputOne.ToLower()); players.SetBattingOrder(teamOne, teams, players, teamManagerOne); if (teamOne.Abbrev == null) { teamOne.Abbrev = inputOne; teamOne.Name = inputOne; } ; teams.SettingNewTeam(teamOne, teams, inputOne, true); Output.WriteStringOutput("Who is the second team?", 2, 2); var teamTwo = new Team(); var inputTwo = Console.ReadLine(); teamTwo = TeamManager.TeamSelection(teams.Teams, inputTwo.ToLower()); players.SetBattingOrder(teamTwo, teams, players, teamManagerTwo); if (teamTwo.Abbrev == null) { teamTwo.Abbrev = inputTwo; teamTwo.Name = inputTwo; } ; teams.SettingNewTeam(teamTwo, teams, inputTwo, false); Output.WriteStringOutput($"\n {teamOne.Name} vs. {teamTwo.Name}"); for (var i = 0; i < 9; i++) { var top = new Inning(); Output.WriteStringOutput($"\nInning {i + 1}"); top.GameOn(players, teamOne, teamTwo, teamOne.OBAAway, teamManagerOne); Output.WriteStringOutput($"\n{teamOne.Abbrev} {top.HomeRuns}\n"); var bottom = new Inning(); bottom.GameOn(players, teamTwo, teamOne, teamTwo.OBAHome, teamManagerTwo); Output.WriteStringOutput($"\n{teamTwo.Abbrev} {bottom.HomeRuns}\n"); teamOneTotal += top.HomeRuns; teamTwoTotal += bottom.HomeRuns; Output.WriteStringOutput($"\nAfter Inning {i + 1} - \n{teamOne.Abbrev} {teamOneTotal}\n{teamTwo.Abbrev} {teamTwoTotal}\n"); int milliseconds = 2000; Thread.Sleep(milliseconds); } if (teamOneTotal == teamTwoTotal) { Output.WriteStringOutput($"\nIt was a tie\n{teamOne.City} {teamOne.Name} {teamOneTotal}\n{teamTwo.City} {teamTwo.Name} {teamTwoTotal}"); } else if (teamTwoTotal > teamOneTotal) { Output.WriteStringOutput($"\n{teamTwo.City} {teamTwo.Name} won {teamTwoTotal}:{teamOneTotal}"); } else { Output.WriteStringOutput($"\n{teamOne.City} {teamOne.Name} won {teamOneTotal}:{teamTwoTotal}"); } input = Console.ReadLine(); teamOneTotal = 0; teamTwoTotal = 0; } else { break; } } Output.WriteStringOutput("Goodbye"); }
public List <Objects.Player> GetPlayers(PlayersRoster players, MLB mlb) { int inputNumber = 0; Output.WriteStringOutput("\n\nHow do you want choose your players? \nChoose number: " + "\n1-Random (5 players)" + "\n2-based on Batting Average (any qualifying player)" + "\n3-specific Team line up" + "\n4-pick players by name (5 players):\n"); inputNumber = Convert.ToInt32(Console.ReadLine()); while (inputNumber == 0 || inputNumber > 4) { Output.WriteStringOutput("Invalid choice. Try again"); Output.WriteStringOutput("\n\nHow do you want choose your players? \nChoose number: " + "\n1-Random (5 players)" + "\n2-based on Batting Average (any qualifying player)" + "\n3-specific Team line up" + "\n4-pick players by name (5 players):\n"); inputNumber = Convert.ToInt32(Console.ReadLine()); } ; switch (inputNumber) { case 1: //Choose 5 random players Random random = new Random(); battingOrder.Add(players.Players[random.Next(0, 190)]); battingOrder.Add(players.Players[random.Next(0, 190)]); battingOrder.Add(players.Players[random.Next(0, 190)]); battingOrder.Add(players.Players[random.Next(0, 190)]); battingOrder.Add(players.Players[random.Next(0, 190)]); break; case 2: Output.WriteStringOutput("What's the minimum Batting Averge one has to have to qualify for your team? - "); double Ba = Convert.ToDouble(Console.ReadLine()); battingOrder = players.Players.Where(T => T.AVG > Ba).ToList(); break; case 3: Output.WriteStringOutput("Which team's line up you want to take over? (Scroll up for the list) - "); string whichTeam = Console.ReadLine().ToLower(); battingOrder = players.Players.Where(T => T.Team.ToLower().Equals(whichTeam)).ToList(); break; case 4: Output.WriteStringOutput("So who are you drafting? - "); string whichPlayer = Console.ReadLine().ToLower(); var i = 5; do { if (!players.Players.Any(T => T.Name.ToLower().Equals(whichPlayer))) { Output.WriteStringOutput("Dont have this player. Please check for correct spelling.\n"); whichPlayer = Console.ReadLine().ToLower(); } else { battingOrder.Add(players.Players.Where(T => T.Name.ToLower().Equals(whichPlayer)).SingleOrDefault()); i--; Output.WriteStringOutput($"\nGood choice! {i} more player(s) - "); whichPlayer = Console.ReadLine().ToLower(); } } while (i > 0); break; } battingOrder.OrderBy(T => T.AVG); return(battingOrder); }