public void ImportPlayers()
        {
            ImportQbHtml();
            ImportRbHtml();
            ImportWrHtml();
            ImportTeHtml();

            LeaguePlayerPool leaguePlayerPool = new LeaguePlayerPool(_league.LeagueId);
            leaguePlayerPool.SetTeamsPlayers();
            leaguePlayerPool.CalculateTradeValues();
        }
Esempio n. 2
0
        public IEnumerable<Player> OptimalLineUp(LeaguePlayerPool leaguePlayerPool, IEnumerable<Player> gainedPlayers, IEnumerable<Player> lostPlayers)
        {
            List<Player> team = new List<Player>(Players);
            if (lostPlayers != null) { foreach (Player lostPlayer in lostPlayers) { team.Remove(lostPlayer); } }
            if (gainedPlayers != null) { foreach (Player gainedPlayer in gainedPlayers) { team.Add(gainedPlayer); } }

            //create list of starters to return
            List<Player> starters = new List<Player>();

            //get position players
            List<Player> quarterbacks = team.Where(p => p.Position == "QB").OrderByDescending(p => p.Points).ToList();
            List<Player> runningBacks = team.Where(p => p.Position == "RB").OrderByDescending(p => p.Points).ToList();
            List<Player> wideReceivers = team.Where(p => p.Position == "WR").OrderByDescending(p => p.Points).ToList();
            List<Player> tightEnds = team.Where(p => p.Position == "TE").OrderByDescending(p => p.Points).ToList();

            //get starting players
            List<Player> startingQbs = quarterbacks.Take(1).ToList();
            List<Player> startingRbs = runningBacks.Take(2).ToList();
            List<Player> startingWrs = wideReceivers.Take(2).ToList();
            List<Player> startingTes = tightEnds.Take(1).ToList();

            //add best waiver to team if missing starter
            if (startingQbs.Count() < 1) { startingQbs.Add(leaguePlayerPool.GetBestWaiverQb()); }
            if (startingRbs.Count() < 2) { startingRbs.Add(leaguePlayerPool.GetBestWaiverRb()); }
            if (startingWrs.Count() < 2) { startingWrs.Add(leaguePlayerPool.GetBestWaiverWr()); }
            if (startingTes.Count() < 1) { startingTes.Add(leaguePlayerPool.GetBestWaiverTe()); }

            //get possible waiver players
            Player flexRb = runningBacks.Skip(2).Take(1).FirstOrDefault();
            Player flexWr = wideReceivers.Skip(2).Take(1).FirstOrDefault();
            Player flexTe = tightEnds.Skip(1).Take(1).FirstOrDefault();

            //get waiver points for easy comparing
            decimal flexRbPoints = (flexRb != null) ? flexRb.Points : 0;
            decimal flexWrPoints = (flexWr != null) ? flexWr.Points : 0;
            decimal flexTePoints = (flexTe != null) ? flexTe.Points : 0;

            //add best waiver player to starters and remove him from the bench
            Player flexPlayer;
            if (flexRbPoints > flexWrPoints && flexRbPoints > flexTePoints) { flexPlayer = flexRb; }
            else if (flexWrPoints > flexRbPoints && flexWrPoints > flexTePoints) { flexPlayer = flexWr; }
            else { flexPlayer = flexTe; }

            foreach (Player player in startingQbs) { starters.Add(player); }
            foreach (Player player in startingRbs) { starters.Add(player); }
            foreach (Player player in startingWrs) { starters.Add(player); }
            foreach (Player player in startingTes) { starters.Add(player); }
            starters.Add(flexPlayer);

            //return optimal starting lineup
            return starters;
        }
Esempio n. 3
0
        public JsonResult FindThreeForOneTrades(int leagueId, int myTeamId, int otherTeamId)
        {
            //create player pools to find trades
            LeaguePlayerPool leaguePlayerPool = new LeaguePlayerPool(leagueId);
            TeamPlayerPool myTeamPlayerPool = new TeamPlayerPool(myTeamId);
            TeamPlayerPool theirTeamPlayerPool = new TeamPlayerPool(otherTeamId);

            //find trades
            List<TradeView> trades = leaguePlayerPool.FindTrades(myTeamPlayerPool, theirTeamPlayerPool, myTeamPlayerPool.ThreePlayerTradePool, theirTeamPlayerPool.OnePlayerTradePool);

            //return Json object with found trades
            return Json(new { Trades = trades });
        }
Esempio n. 4
0
 public void SetTeamsPlayers(int id)
 {
     LeaguePlayerPool leaguePlayerPool = new LeaguePlayerPool(id);
     leaguePlayerPool.SetTeamsPlayers();
 }
Esempio n. 5
0
 public void CalculateTradeValues(int id)
 {
     LeaguePlayerPool leaguePlayerPool = new LeaguePlayerPool(id);
     leaguePlayerPool.CalculateTradeValues();
 }
Esempio n. 6
0
 public IEnumerable<Player> OptimalLineUp(LeaguePlayerPool leaguePlayerPool)
 {
     return OptimalLineUp(leaguePlayerPool, null, null);
 }