Exemplo n.º 1
0
 public override int GetHashCode()
 {
     return(Date.GetHashCode() ^ 7
            * HomeId.GetHashCode() ^ 11
            * AwayId.GetHashCode() ^ 17
            * LeagueId.GetHashCode() ^ 23);
 }
Exemplo n.º 2
0
 public PoeItemsByOwner()
 {
     Owner       = "";
     ListVersion = 0;
     Items       = new List <PoeItem>();
     League      = LeagueId.Default;
 }
Exemplo n.º 3
0
 public PoeItemsByOwner(SerializationInfo info, StreamingContext ctxt)
 {
     Owner       = info.GetString("Owner");
     ListVersion = info.GetInt32("ListVersion");
     Items       = (List <PoeItem>)info.GetValue("Items", typeof(List <PoeItem>));
     League      = (LeagueId)info.GetValue("League", typeof(LeagueId));
 }
Exemplo n.º 4
0
        //  fill the available slot with a player from the roster or maybe a free agent
        private void PickPlayer(LineupSlot slot)
        {
            _playerList = new List <NFLPlayer>();
            var rosterCount = 0;

            if (LeagueId != Constants.K_LEAGUE_PerfectChallenge)
            {
                //  select eligible players from the fantasy roster
                var dr = Utility.TflWs.GetFTeamDr(Season, LeagueId, OwnerCode);
                //  add rostered players
                for (var i = 65; i < 91; i++)                   //  from A-Z
                {
                    var playerCode = string.Format("PLAYER{0}", ( char )i);
                    AddPlayer(dr[playerCode].ToString().Trim(), slot.SlotType, freeAgent: false);
                }
#if DEBUG
                Announce($"{_playerList.Count} players on the roster for {OwnerCode}");
#endif
                rosterCount = _playerList.Count;
            }

            if ((LeagueId.Equals(Constants.K_LEAGUE_Yahoo) ||
                 LeagueId.Equals(Constants.K_LEAGUE_PerfectChallenge)) &&
                IncludeFreeAgents)
            {
                //  append to the roster all free agents starters available
                var cats = string.Empty;
                foreach (var sType in slot.SlotType)
                {
                    var sCat = sType;
                    if (sCat == "W" || sCat == "T")
                    {
                        sCat = "3";
                    }
                    if (cats.IndexOf(sCat) < 0)
                    {
                        cats += sCat;
                    }
                }
                var ds = Utility.TflWs.GetOffensivePlayers(cats);
                foreach (var row in ds.Tables[0].Rows.Cast <DataRow>()
                         .Where(row => !HaveAlreadyGotOne(row["PLAYERID"].ToString().Trim())))
                {
                    AddPlayer(
                        row["PLAYERID"].ToString().Trim(),
                        slot.SlotType,
                        freeAgent: true);
                }
#if DEBUG
                Announce($"{_playerList.Count - rosterCount} players added as free agents");
#endif
            }

#if DEBUG
            Announce($"{_playerList.Count} players to choose from for {slot.SlotCode}");
#endif
            // pick the best player from the list
            slot.PlayerSelected = ChooseBestPlayer(slot);
        }
Exemplo n.º 5
0
 public PoeItemsManager(SerializationInfo info, StreamingContext ctxt)
 {
     InitializeList();
     AllItems = (List <PoeItem>)info.GetValue("AllItems", typeof(List <PoeItem>));
     OwnerItemsListUpdateTime = (SortedDictionary <string, int>)info.GetValue("OwnerItemsListUpdateTime", typeof(SortedDictionary <string, int>));
     LeagueIndex = (LeagueId)info.GetValue("LeagueIndex", typeof(LeagueId));
     //LeagueIndex = LeagueId.Default;
 }
Exemplo n.º 6
0
        private DataTable BuildTable()
        {
            var dt   = new DataTable();
            var cols = dt.Columns;

            cols.Add("WEEK", typeof(String));
            if (LeagueId.Equals(RosterLib.Constants.K_LEAGUE_Gridstats_NFL1))
            {
                cols.Add("Q1", typeof(String));
                cols.Add("R1", typeof(String));
                cols.Add("R2", typeof(String));
                cols.Add("T1", typeof(String));
                cols.Add("W1", typeof(String));
                cols.Add("W2", typeof(String));
                cols.Add("K1", typeof(String));

                cols.Add("Q2", typeof(String));
                cols.Add("R4", typeof(String));
                cols.Add("R3", typeof(String));
                cols.Add("T2", typeof(String));
                cols.Add("W4", typeof(String));
                cols.Add("W3", typeof(String));
                cols.Add("K2", typeof(String));
            }
            else
            {
                cols.Add("QB", typeof(String));
                cols.Add("RB1", typeof(String));
                cols.Add("RB2", typeof(String));
                cols.Add("WR1", typeof(String));
                cols.Add("WR2", typeof(String));
                cols.Add("WR3", typeof(String));
                cols.Add("TE", typeof(String));
                cols.Add("PK", typeof(String));
            }

            //  for each week of the season
            for (int w = Week; w <= RosterLib.Constants.K_WEEKS_IN_REGULAR_SEASON; w++)
            {
                var dr = dt.NewRow();
                dr["WEEK"] = w;

                // starters
                foreach (LineupSlot s in League.LineupSlots)
                {
                    PickPlayer(s, w);

                    dr[s.SlotCode] = string.Format("{0} ({1})",
                                                   s.PlayerSelected.PlayerNameShort, s.PlayerSelected.Points);
                }
                dt.Rows.Add(dr);
                //break;  // debug only
            }

            return(dt);
        }
Exemplo n.º 7
0
        public Task <bool> DeleteAsync(LeagueId key)
        {
            //check if exists
            //remove

            //var index = Leagues.FindIndex(x => x.Id == key);
            //if (index == -1)
            //    throw new KeyNotFoundException("League item not found");
            //Leagues.RemoveAt(index);
            //return Task.FromResult(true);
            throw new NotImplementedException();
        }
Exemplo n.º 8
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 23;
         hash = hash * 37 + TeamId.GetHashCode();
         hash = hash * 37 + (Name != null ? Name.GetHashCode() : 0);
         hash = hash * 37 + (LeagueId != null ? LeagueId.GetHashCode() : 0);
         hash = hash * 37 + SeasonId.GetHashCode();
         hash = hash * 37 + (Score != null ? Score.GetHashCode() : 0);
         return(hash);
     }
 }
Exemplo n.º 9
0
        public void Test_Basic_Id_Int_Type()
        {
            LeagueId id1 = 1;
            LeagueId id2 = 2;

            //LeagueId id3 = id1 + id2;

            Assert.NotEqual(id1, id2);
            //Assert.Equal((LeagueId)3, id3);

            //Assert.True(id1 < id2);
            //Assert.True(id1 <= id2);
            //Assert.False(id1 > id2);
            //Assert.False(id1 >= id2);
        }
Exemplo n.º 10
0
        public void Render()
        {
            var str = new SimpleTableReport(string.Format("Projected Lineup {0}:{1:#0} {2}", Season, Week, LeagueId));

            str.AddStyle(
                "#container { text-align: left; background-color: #ccc; margin: 0 auto; border: 1px solid #545454; padding:10px; font: 13px/19px Trebuchet MS, Georgia, Times New Roman, serif; }");
            str.AddStyle("#main { margin-left:1em; }");
            str.AddStyle("#dtStamp { font-size:0.8em; }");
            str.AddStyle(".end { clear: both; }");
            str.AddStyle(".gponame { color:white; background:black }");
            str.ColumnHeadings  = true;
            str.DoRowNumbers    = false;
            str.ShowElapsedTime = false;
            str.IsFooter        = false;
            str.AddColumn(new ReportColumn("Week", "WEEK", "{0}"));
            if (LeagueId.Equals(Constants.K_LEAGUE_Gridstats_NFL1))
            {
                str.AddColumn(new ReportColumn("Q1", "Q1", "{0}"));
                str.AddColumn(new ReportColumn("R1", "R1", "{0}"));
                str.AddColumn(new ReportColumn("R2", "R2", "{0}"));
                str.AddColumn(new ReportColumn("T1", "T1", "{0}"));
                str.AddColumn(new ReportColumn("W1", "W1", "{0}"));
                str.AddColumn(new ReportColumn("W2", "W2", "{0}"));
                str.AddColumn(new ReportColumn("K1", "K1", "{0}"));
                str.AddColumn(new ReportColumn("Q2", "Q2", "{0}"));
                str.AddColumn(new ReportColumn("R4", "R4", "{0}"));
                str.AddColumn(new ReportColumn("R3", "R3", "{0}"));
                str.AddColumn(new ReportColumn("T2", "T2", "{0}"));
                str.AddColumn(new ReportColumn("W4", "W4", "{0}"));
                str.AddColumn(new ReportColumn("W3", "W3", "{0}"));
                str.AddColumn(new ReportColumn("K2", "K2", "{0}"));
            }
            else
            {
                str.AddColumn(new ReportColumn("QB", "QB", "{0}"));
                str.AddColumn(new ReportColumn("RB1", "RB1", "{0}"));
                str.AddColumn(new ReportColumn("RB2", "RB2", "{0}"));
                str.AddColumn(new ReportColumn("WR1", "WR1", "{0}"));
                str.AddColumn(new ReportColumn("WR2", "WR2", "{0}"));
                str.AddColumn(new ReportColumn("WR3", "WR3", "{0}"));
                str.AddColumn(new ReportColumn("TE", "TE", "{0}"));
                str.AddColumn(new ReportColumn("PK", "PK", "{0}"));
            }

            str.LoadBody(BuildTable());
            str.RenderAsHtml(FileName(), true);
        }
Exemplo n.º 11
0
 public PoeItemsManager(LeagueId lIndex = LeagueId.Default)
 {
     LeagueIndex = lIndex;
     InitializeList();
 }
Exemplo n.º 12
0
 public override bool Equals(object other)
 {
     return(other is League otherLeague && LeagueId.Equals(otherLeague.LeagueId));
 }
Exemplo n.º 13
0
 public PoeItemsManager(LeagueId lIndex = LeagueId.Default)
 {
     LeagueIndex = lIndex;
     InitializeList();
 }
Exemplo n.º 14
0
 public override int GetHashCode()
 {
     return(LeagueId.GetHashCode());
 }
Exemplo n.º 15
0
        private NFLPlayer ChoosePlayerForSlot(int rank)
        {
#if DEBUG
            Announce("    Choosing from:");
#endif
            //  start with dummy player
            var selectedPlayer   = new NFLPlayer("-", "**", "?", "*", "-", "*", null);
            var availablePlayers = new List <NFLPlayer>();
            foreach (var plyr in _playerList)
            {
                var game     = plyr.CurrTeam.GameFor(Season, Week);
                var opponent = plyr.CurrTeam.OpponentFor(Season, Week);
                if (opponent != null)
                {
                    Announce($@"{
						plyr.PlayerNameShort
						} >> {
						game.ResultOut( plyr.CurrTeam.TeamCode, true )
						}"                        );

                    //  work out projected points
                    plyr.Points = RankPoints(plyr, game, opponent);

                    if (LeagueId.Equals(Constants.K_LEAGUE_Gridstats_NFL1))
                    {
                        if (IsAvailable(plyr))
                        {
                            availablePlayers.Add(plyr);
                        }
                    }
                    else
                    {
                        if (NotUsed(plyr) && IsAvailable(plyr))
                        {
                            availablePlayers.Add(plyr);
                        }
                    }
                }
                else
                {
                    plyr.Points = 0;
                }
            }
            //  pick out the player depending on rank
            availablePlayers.Sort((p1, p2) => p1.Points.CompareTo(p2.Points) * -1);

            var selectionIndex = 0;             //  always take best available
            if (LeagueId.Equals(Constants.K_LEAGUE_Gridstats_NFL1))
            {
                selectionIndex = rank - 1;
            }

            if (availablePlayers.Count > selectionIndex)
            {
                selectedPlayer = availablePlayers[selectionIndex];
            }

            foreach (var p in availablePlayers)
            {
                Announce(string.Format("      {0,-16} who has {1,4:#0.#} points",
                                       p.PlayerNameShort, p.Points));
            }
            Announce(string.Format("   {0} has been selected with {1:#0.#} points",
                                   selectedPlayer.PlayerNameShort, selectedPlayer.Points));
            Announce("   ------------------------------------------------");

            return(selectedPlayer);
        }
Exemplo n.º 16
0
        public void BothNull_Valid() //??desirable
        {
            LeagueId id = null;

            Assert.IsTrue(null == id);
        }
Exemplo n.º 17
0
 public async Task <League> GetAsync(LeagueId key)
 {
     return(_mapper.Map <League>(await _db.Leagues.AsNoTracking().SingleOrDefaultAsync(x => x.LeagueId == (uint)key)));
 }
Exemplo n.º 18
0
 private void SetActiveLeague(LeagueId id)
 {
     ActiveLeagueId = id;
     this.Title = StaticVariables.AppTitle + " - " + StaticVariables.LeagueNames[(int)id] + " League";
     ucItemTree.SetDataSource(ItemsManagers[(int)ActiveLeagueId].ItemsByCatForListView);
 }
Exemplo n.º 19
0
        private DataTable BuildTable()
        {
            var dt   = new DataTable();
            var cols = dt.Columns;

            cols.Add("SLOT", typeof(String));
            cols.Add("PLAYER", typeof(String));
            cols.Add("TEAM", typeof(String));
            cols.Add("POS", typeof(String));
            cols.Add("PTS", typeof(Int16));
            cols.Add("ROLE", typeof(String));
            cols.Add("GAME", typeof(String));
            cols.Add("OPPRATE", typeof(String));
            cols.Add("SPREAD", typeof(Decimal));
            cols.Add("TOTAL", typeof(Decimal));
            cols.Add("ACTUAL", typeof(Int16));

            // starters
            foreach (var s in League.LineupSlots)
            {
                Announce(
                    $"  Picking a player for slot {s.SlotNumber} - {s.SlotCode}, rank {s.Rank}");
                PickPlayer(s);
                AddPlayerLineWithPlayer(dt, false, s.PlayerSelected, s.SlotNumber);
#if DEBUG
                break;
#endif
            }
            //  blank line
            var blank = dt.NewRow();
            blank["SLOT"] = 99;
            dt.Rows.Add(blank);

            if (LeagueId != Constants.K_LEAGUE_PerfectChallenge)
            {
                var teamRow = Utility.TflWs.GetFTeamDr(Season, LeagueId, OwnerCode);
                _playerList = new List <NFLPlayer>();
                for (var i = 65; i < 91; i++)                   //  from A-Z
                {
                    var playerCode = string.Format("PLAYER{0}", ( char )i);
                    var playerId   = teamRow[playerCode].ToString().Trim();
                    if (playerId.Length > 0)
                    {
                        AddPlayerLine(dt, playerId, freeAgent: false);
                    }
                }
            }

            if ((LeagueId.Equals(Constants.K_LEAGUE_Yahoo) || LeagueId.Equals(Constants.K_LEAGUE_PerfectChallenge)) &&
                IncludeFreeAgents)
            {
                var blank2 = dt.NewRow();
                dt.Rows.Add(blank2);
                AddFreeAgents(dt, "1");

#if !DEBUG
                var blank3 = dt.NewRow();
                dt.Rows.Add(blank3);
                AddFreeAgents(dt, "2");
                var blank4 = dt.NewRow();
                dt.Rows.Add(blank4);
                AddFreeAgents(dt, "3");

                var blank5 = dt.NewRow();
                dt.Rows.Add(blank5);
                AddFreeAgents(dt, "4");
#endif
            }
            return(dt);
        }
Exemplo n.º 20
0
 private void SetActiveLeague(LeagueId id)
 {
     ActiveLeagueId = id;
     this.Title     = StaticVariables.AppTitle + " - " + StaticVariables.LeagueNames[(int)id] + " League";
     ucItemTree.SetDataSource(ItemsManagers[(int)ActiveLeagueId].ItemsByCatForListView);
 }