예제 #1
0
 /// <summary>
 /// Places the pieces in their starting positions.
 /// </summary>
 /// <param name="sheepPlayer">The Sheep Player.</param>
 public void SetupGamePieces(SheepPlayer sheepPlayer)
 {
     for (int i = 0, j = 0; i < Rows.Length; i += 2, j++)
     {
         this.Rows[Size - 1].Squares[i].PutPiece(sheepPlayer.Pieces[j]);
     }
 }
예제 #2
0
        /// <summary>
        /// Creates a new instance of <see cref="Game"/>.
        /// </summary>
        /// <param name="options">Game options.</param>
        public Game(Options options)
        {
            gameOptions = options;

            PlayerWolf = new WolfPlayer(gameOptions.WolfPlayerName);

            // No rounding or parsing necessary.
            // Validation done by Options garantees the BoardSize is an even number,
            // making gameOptions.BoardSize / 2 always result in a uint.
            PlayerSheep = new SheepPlayer(gameOptions.BoardSize / 2, gameOptions.SheepPlayerName);

            Board = new Board(gameOptions.BoardSize);
            Board.SetupGamePieces(PlayerSheep);
        }
예제 #3
0
        /// <summary>
        /// Checks if a given player has any possible moves.
        /// </summary>
        /// <param name="player">The player to check for possible moves.</param>
        /// <returns>A boolean value representing availability of moves.</returns>
        public bool GetPlayerHasPossibleMoves(Player player)
        {
            bool result = false;

            if (player is WolfPlayer wolfPlayer)
            {
                result = GetPieceHasPossibleMoves(wolfPlayer, wolfPlayer.Piece);
            }
            else
            {
                SheepPlayer sheepPlayer = (SheepPlayer)player;

                for (int i = 0; i < sheepPlayer.Pieces.Length; i++)
                {
                    result = GetPieceHasPossibleMoves(sheepPlayer, sheepPlayer.Pieces[i]);
                }
            }

            return(result);
        }