コード例 #1
0
ファイル: PlayerPivot.cs プロジェクト: thelpi/Gnoj-Ham
        /// <summary>
        /// Updates the human player's name.
        /// </summary>
        /// <param name="game">The current game.</param>
        /// <param name="humanPlayerName">The new <see cref="Name"/> value for human player.</param>
        internal static void UpdateHumanPlayerName(GamePivot game, string humanPlayerName)
        {
            if (game == null)
            {
                throw new ArgumentNullException(nameof(game));
            }

            humanPlayerName = CheckName(humanPlayerName);

            game.Players.ElementAt(GamePivot.HUMAN_INDEX).Name = humanPlayerName;
        }
コード例 #2
0
ファイル: ScoreTools.cs プロジェクト: thelpi/Gnoj-Ham
        /// <summary>
        /// Computes the rank and score of every players at the current state of the game.
        /// </summary>
        /// <param name="game">The current game.</param>
        /// <returns>A list of player with score, order by ascending rank.</returns>
        public static List <PlayerScorePivot> ComputeCurrentRanking(GamePivot game)
        {
            if (game == null)
            {
                throw new ArgumentNullException(nameof(game));
            }

            var playersOrdered = new List <PlayerScorePivot>();

            int i = 1;

            foreach (PlayerPivot player in game.Players.OrderByDescending(p => p.Points))
            {
                playersOrdered.Add(new PlayerScorePivot(player, i, ComputeUma(i), game.InitialPointsRule.GetInitialPointsFromRule()));
                i++;
            }

            return(playersOrdered);
        }