public void DraftPlayer(Player draftedPlayer, FantasyTeam draftingTeam) { //string playerInfo = draftedPlayer.Full + ", " + draftedPlayer.Position + " - $" + draftedPlayer.Dollar; //int moneyAfterDrafting = draftingTeam.MoneyLeft - (16 - (Brain.myTeam.Roster.Count + 1) + draftedPlayer.Dollar); //bool canAffordToDraft = moneyAfterDrafting >= 0; //if (!canAffordToDraft) //{ // MessageBox.Show("Not Enough $$$"); //} //else //{ // Brain.myTeam.addPlayer(draftedPlayer); // if (Brain.lastFivePlayersDrafted.Count == 5) // { // Brain.lastFivePlayersDrafted.Remove(Brain.lastFivePlayersDrafted.ElementAt(0)); // Brain.lastFivePlayersDrafted.Add(draftedPlayer); // } // else // { // Brain.lastFivePlayersDrafted.Add(draftedPlayer); // } //} }
private static void OptimizePosition(FantasyTeam mockTeam, string position, int spotsAlreadyFilled) { int numberOfTotalSpots = Brain.MyDraft.RosterSpotsByPosition[position]; int percentageBudgetForPosition = mockTeam.PercentageBudgetsByPosition[position]; int percentageBudgetForBench = mockTeam.PercentageBudgetsByPosition["BENCH"]; List<Player> players = new List<Player>(); players.AddRange(Brain.MyDraft.PlayersByPosition[position]); while (spotsAlreadyFilled < numberOfTotalSpots) { int dollarBudgetForPosition = mockTeam.GetBudgetDollarForPosition(position); int numberOfSpotsAvailable = numberOfTotalSpots - spotsAlreadyFilled; int dollarBudgetForThisPlayer = numberOfSpotsAvailable > 1 ? (int)Math.Ceiling(dollarBudgetForPosition / 2.0) : dollarBudgetForPosition; Player bestPlayer = players.Where(p => p.Dollar <= dollarBudgetForThisPlayer && !mockTeam.Roster.Contains(p)) .OrderByDescending(s => s.Points).First(); mockTeam.addMockPlayer(bestPlayer); players.Remove(bestPlayer); spotsAlreadyFilled++; } if (mockTeam.PercentageBudgetsByPosition[position] > 0) { var increase = mockTeam.PercentageBudgetsByPosition[position] * Brain.MyDraft.LeagueSalarayCap / 100; mockTeam.AdjustedCap += increase; } }
private static void CreateMyTeam(IEnumerable<string> lines) { FantasyTeam mine = new FantasyTeam("Me"); Dictionary<string, int> BudgetPercentages = new Dictionary<string, int>(); Dictionary<string, int> PositionCounts = new Dictionary<string, int>(); foreach(string str in lines.Where(line => line.Contains("_"))) { string[] splitter = str.Split('_'); string position = splitter[0]; int percentage = Convert.ToInt16(splitter[1]); int count = Convert.ToInt16(splitter[2]); BudgetPercentages.Add(position, percentage); PositionCounts.Add(position, count); } mine.PercentageBudgetsByPosition = BudgetPercentages; MyDraft.RosterSpotsByPosition = PositionCounts; MyDraft.League.Add(mine); MyDraft.TeamsInLeague++; MyDraft.MyTeam = mine; }
public static FantasyTeam RunOptimizer(Player playerUpForAuction) { FantasyTeam mock = new FantasyTeam("mock"); foreach(string key in Brain.MyDraft.MyTeam.PercentageBudgetsByPosition.Keys) { mock.PercentageBudgetsByPosition.Add(key, Brain.MyDraft.MyTeam.PercentageBudgetsByPosition[key]); } foreach (Player p in Brain.MyDraft.MyTeam.Roster) { mock.addMockPlayer(p); } if(playerUpForAuction != null) { mock.addMockPlayer(playerUpForAuction); } foreach (string position in new string[]{"K","DST","TE","QB","RB","WR"}) { int numberPositionRosterSpots = mock.Roster.Count(p => p.Position.Equals(position)); OptimizePosition(mock, position, numberPositionRosterSpots); } return mock; }
private static void InitializeFantasyLeague(IEnumerable<string> lines) { MyDraft = new Draft(); MyDraft.LeagueSalarayCap = Convert.ToInt32(lines.Last()); CreateMyTeam(lines); foreach (string opponentName in lines.Where(line => line.StartsWith("-"))) { FantasyTeam team = new FantasyTeam(opponentName.Substring(1)); MyDraft.League.Add(team); MyDraft.TeamsInLeague++; } MyDraft.LeaguePool = MyDraft.LeagueStartPool = MyDraft.LeagueSalarayCap * MyDraft.TeamsInLeague; }
public OptimalWindow(Player player = null) { InitializeComponent(); WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; this.Width = System.Windows.SystemParameters.PrimaryScreenWidth; this.Height = System.Windows.SystemParameters.PrimaryScreenHeight - 30; InitializeTeamBox(); mockTeam = RunOptimizer(player); foreach(Player play in mockTeam.Roster) { AddPlayerToTeamBox(play); } // DisplayStatistics(); }
public Draft() { TeamsInLeague = 0; LeagueSalarayCap = 0; LeaguePool = 0; LeagueStartPool = 0; CurrentPlayerUpForAuction = null; SelectedPlayer = null; League = new List<FantasyTeam>(); Players = new List<Player>(); PlayersByPosition = new Dictionary<string, List<Player>>(); RosterSpotsByPosition = new Dictionary<string, int>(); MyTeam = null; }
public void updateTeamBox(Player p, FantasyTeam team) { string playerPosition = p.Position; IEnumerable<Label> correspondingLabels = panelTeam.Children.OfType<Label>().Where(label => label.Content.ToString().StartsWith(playerPosition)); Label nextOpenSlot = correspondingLabels.FirstOrDefault(lab => lab.Content.ToString().Split('-')[1].Length == 0); if (nextOpenSlot != null) { nextOpenSlot.Content += p.toTeam(); Label projectedTotalLabel = panelTeam.Children.OfType<Label>().First(label => label.Name.Equals("projTotal")); projectedTotalLabel.Content = "Proj. Total - " + team.ProjectedTotal + " pts"; } else { IEnumerable<Label> benchSlots = panelTeam.Children.OfType<Label>().Where(label => label.Content.ToString().StartsWith("BENCH")); nextOpenSlot = benchSlots.FirstOrDefault(lab => lab.Content.ToString().Length == 8); if (nextOpenSlot != null) { nextOpenSlot.Content += p.toTeam(); } } }