BalloonsPop.Highscore.HighscoreTable.CanAddPlayer C# (CSharp) 메소드

CanAddPlayer() 공개 메소드

Checks if a player can be added to a HighscoreTable.
public CanAddPlayer ( int movesCount ) : bool
movesCount int The amount of moves a player has.
리턴 bool
        public bool CanAddPlayer(int movesCount)
        {
            bool listAcceptsEntries = this.table.Count < HighscoreTable.MaxPlayers;
            bool hasLowerMoves = this.table.Any(x => movesCount < x.Moves);

            return listAcceptsEntries || hasLowerMoves;
        }

Usage Example

예제 #1
0
        public void HighscoreTableShouldAddPlayerWhenNotReachedMaxPlayers()
        {
            List<PlayerScore> playerScores = new List<PlayerScore>();
            for (int i = 0; i < HighscoreTable.MaxPlayers - 1; i++)
            {
                playerScores.Add(new PlayerScore(i.ToString(), i, DateTime.Now));
            }

            HighscoreTable table = new HighscoreTable(playerScores);

            bool canAddPlayer = table.CanAddPlayer(10);

            Assert.IsTrue(canAddPlayer);
        }
All Usage Examples Of BalloonsPop.Highscore.HighscoreTable::CanAddPlayer