public void ForceSort(PlayerSortOrder order)
        {
            this.SortOrder = PlayerSortOrder.Unsorted;
            if (order == PlayerSortOrder.Unsorted)
            {
                order = PlayerSortOrder.Id;
            }
            switch (order - 1)
            {
            case PlayerSortOrder.Unsorted:
                this.SortByID();
                break;

            case PlayerSortOrder.Id:
                this.SortByIDByesLast();
                break;

            case PlayerSortOrder.IdByesLast:
                this.SortByName();
                break;

            case PlayerSortOrder.FirstName:
                this.SortByLastname();
                break;

            case PlayerSortOrder.LastName:
                this.SortByRank();
                break;

            default:
                throw new Exception(string.Format("Sort Order Re-sort not implemented: {0}", (object)order));
            }
        }
 public void SortByRank()
 {
     if (this._sortOrder == PlayerSortOrder.Rank)
     {
         return;
     }
     this.Sort((IComparer <ITournPlayer>)TournPlayerArray.sorter_ByRank);
     this._sortOrder = PlayerSortOrder.Rank;
 }
 public void SortByLastname()
 {
     if (this._sortOrder == PlayerSortOrder.LastName)
     {
         return;
     }
     this.Sort((IComparer <ITournPlayer>)TournPlayerArray.sorter_ByLastName);
     this._sortOrder = PlayerSortOrder.LastName;
 }
 public void SortByID()
 {
     if (this._sortOrder == PlayerSortOrder.Id)
     {
         return;
     }
     this.Sort((IComparer <ITournPlayer>)TournPlayerArray.sorter_ByID);
     this._sortOrder = PlayerSortOrder.Id;
 }
 public void SortByIDByesLast()
 {
     if (this._sortOrder == PlayerSortOrder.IdByesLast)
     {
         return;
     }
     this.Sort((IComparer <ITournPlayer>)TournPlayerArray.sorter_ByIdByesLast);
     this._sortOrder = PlayerSortOrder.IdByesLast;
 }
Beispiel #6
0
 public void SortByLastname()
 {
     if (this._sortOrder == PlayerSortOrder.LastName)
     {
         return;
     }
     this.Sort((IComparer <IPlayer>)PlayerArray._SortByLastNameComparer);
     this._sortOrder = PlayerSortOrder.LastName;
 }
Beispiel #7
0
 public void SortByIDByesLast()
 {
     if (this._sortOrder == PlayerSortOrder.IdByesLast)
     {
         return;
     }
     this.Sort((IComparer <IPlayer>) new PlayerSort_ByIdByesLast());
     this._sortOrder = PlayerSortOrder.IdByesLast;
 }
Beispiel #8
0
 public void SortByID()
 {
     if (this._sortOrder == PlayerSortOrder.Id)
     {
         return;
     }
     this.Sort((IComparer <IPlayer>)PlayerArray._SortByIdComparer);
     this._sortOrder = PlayerSortOrder.Id;
 }
Beispiel #9
0
        public List <Player> DeserializeList(uint top, PlayerSortOrder sorting, bool ascending)
        {
            string        selectStatement = string.Format("Select 1 as RowNumber, * From [Player] order by {0} {1} Limit @top", sorting, ascending ? "asc" : "desc");
            List <Player> result          = SqlHelper.ExecuteClassListQuery <Player>(selectStatement, IndexedPlayerFromDataRow, "top", (int)top);

            for (ushort i = 0; i < result.Count; i++)
            {
                ((IIndexedPlayerSerializable)result[i]).RowNumber += i;
            }

            return(result);
        }
Beispiel #10
0
        public bool ChangePlayerId(long oldPlayerId, long newPlayerId)
        {
            IPlayer byId = this.FindById(oldPlayerId);

            if (byId == null || this.FindById(newPlayerId) != null)
            {
                return(false);
            }
            byId.ID        = newPlayerId;
            this.SortOrder = PlayerSortOrder.Unsorted;
            return(true);
        }
Beispiel #11
0
        public static IQueryable <T> OrderBy <T>(this IQueryable <T> playerStats, PlayerSortOrder sortOrder)
            where T : PlayerStatsBasicModel
        {
            switch (sortOrder)
            {
            case PlayerSortOrder.None:
                return(playerStats);

            case PlayerSortOrder.Name:
                return(playerStats
                       .OrderBy(p => p.PlayerName));

            case PlayerSortOrder.NameDesc:
                return(playerStats
                       .OrderByDescending(p => p.PlayerName));

            case PlayerSortOrder.Count:
                return(playerStats
                       .OrderBy(p => p.Count)
                       .ThenBy(p => p.HeadshotCount));

            case PlayerSortOrder.CountDesc:
                return(playerStats
                       .OrderByDescending(p => p.Count)
                       .ThenByDescending(p => p.HeadshotCount));

            case PlayerSortOrder.Headshot:
                return(playerStats
                       .OrderBy(p => p.HeadshotCount)
                       .ThenBy(p => p.Count));

            case PlayerSortOrder.HeadshotDesc:
                return(playerStats
                       .OrderByDescending(p => p.HeadshotCount)
                       .ThenByDescending(p => p.Count));

            case PlayerSortOrder.HeadshotRatio:
                return(playerStats
                       .OrderBy(p => p.HeadshotCount == 0 ? 0 : p.HeadshotCount / (float)p.Count)
                       .ThenBy(p => p.HeadshotCount));

            case PlayerSortOrder.HeadshotRatioDesc:
                return(playerStats
                       .OrderByDescending(p => p.HeadshotCount == 0 ? 0 : p.HeadshotCount / (float)p.Count)
                       .ThenByDescending(p => p.HeadshotCount));

            default:
                throw new ArgumentOutOfRangeException(nameof(sortOrder), sortOrder, null);
            }
        }
Beispiel #12
0
        public void ToFullXml(XmlWriter writer)
        {
            PlayerSortOrder sortOrder = this.SortOrder;

            this.SortByLastname();
            writer.WriteStartElement(this.XmlKeyElementName);
            foreach (IBaseObject baseObject in (List <IPlayer>) this)
            {
                baseObject.ToFullXml(writer);
            }
            writer.WriteEndElement();
            this.SortOrder = sortOrder;
            this.ReSort();
        }
        public int Append(ITournPlayerArray NewTournPlayers)
        {
            if (this.Count == 0)
            {
                this.SortOrder = PlayerSortOrder.Unsorted;
                this.AddRange((IEnumerable <ITournPlayer>)NewTournPlayers);
                return(NewTournPlayers.Count);
            }
            TournPlayerArray tournPlayerArray = new TournPlayerArray();
            int count = this.Count;

            foreach (ITournPlayer newTournPlayer in (IEnumerable <ITournPlayer>)NewTournPlayers)
            {
                if (!this.HasPlayer(newTournPlayer.ID))
                {
                    this.AddPlayer(newTournPlayer);
                }
            }
            return(this.Count - count);
        }
Beispiel #14
0
        public async Task <MultiplePlayerStatsWeaponResult> GetPlayerStatsWeapon(int startingIndex, int pageSize, PlayerSortOrder sortOrder, Expression <Func <PlayerStatsFullModel, bool> > additionalValidation)
        {
            var playerStatsList = await this.dbContext.PlayerStatsFull
                                  .OrderBy(sortOrder)
                                  .Skip(startingIndex)
                                  .Take(pageSize)
                                  .GroupToWeaponModel(additionalValidation)
                                  .ToListAsync();

            if (playerStatsList.Count == 0)
            {
                return(null);
            }

            return(new MultiplePlayerStatsWeaponResult
            {
                TotalPlayersCount = await this.dbContext.PlayerStatsFull.GroupToWeaponModel(additionalValidation).CountAsync(),
                Players = playerStatsList.Select(o => mapper.Map <PlayerStatsWeaponResult>(o)).ToList()
            });
        }
Beispiel #15
0
        public async Task <IActionResult> GetGameServerPlayersStatsBasic([FromRoute] Guid gameServerPublicKey, [FromRoute] int startingIndex, [FromRoute] int pageSize, [FromRoute] PlayerSortOrder sortOrder)
        {
            try
            {
                if (startingIndex < 0)
                {
                    throw new ArgumentException($"Invalid starting index value ({startingIndex})", nameof(startingIndex));
                }

                if (pageSize > this.maxPageSize)
                {
                    throw new ArgumentException($"Maximum page size exceeded ({maxPageSize})", nameof(pageSize));
                }

                var playerStats = await service.GetPlayerStatsBasic(startingIndex, pageSize, sortOrder, m => m.GameServerPublicKey == gameServerPublicKey);

                if (playerStats == null)
                {
                    return(Error(new ErrorResult
                    {
                        Classification = ErrorClassification.EntityNotFound,
                        Message = "Players not found"
                    }, HttpStatusCode.NotFound));
                }

                return(Ok(playerStats));
            }
            catch (Exception)
            {
                return(Error(new ErrorResult
                {
                    Classification = ErrorClassification.InternalError,
                    Message = "Failed getting player statistics"
                }));
            }
        }
Beispiel #16
0
 public List <Player> DeserializeList(uint top, PlayerSortOrder sorting, bool ascending)
 {
     return(SqlHelper.ExecuteClassListQuery <Player>("Player_DeserializeList", PlayerFromDataRow, "top", (int)top, "sorting", (int)sorting, "asc", ascending));
 }