コード例 #1
0
        protected void MovePiece(PieceOnBoard[,] board, int roll, int rowIndex, int colIndex)
        {
            if (colIndex != -1)
            {
                board[rowIndex, colIndex].ChangeCount(false);
            }
            else
            {
                Saved();
            }

            ChangeIndexes(roll, ref rowIndex, ref colIndex);

            if (colIndex < 0) // Player is clearing pieces
            {
                Cleared();
            }
            else if (board[rowIndex, colIndex].Count != 0 && board[rowIndex, colIndex].Player.Type != Type) // Player is eating other player's piece
            {
                board[rowIndex, colIndex].Player.Eaten();
                board[rowIndex, colIndex] = new PieceOnBoard(this, 1);
            }
            else if (board[rowIndex, colIndex].Count != 0) // There are pieces of the player
            {
                board[rowIndex, colIndex].ChangeCount(true);
            }
            else  // No pieces there
            {
                board[rowIndex, colIndex] = new PieceOnBoard(this, 1);
            }
        }
コード例 #2
0
        public PieceOnBoard(PieceOnBoard piece)
        {
            if (piece.Player is HumanPlayer)
            {
                Player = (HumanPlayer)piece.Player.Clone();
            }
            else
            {
                Player = piece.Player;
            }

            Count = piece.Count;
        }
コード例 #3
0
        private PieceOnBoard[,] CreateCopyOfBoard(PieceOnBoard[,] source)
        {
            PieceOnBoard[,] copy = new PieceOnBoard[2, 12];

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 12; j++)
                {
                    copy[i, j] = new PieceOnBoard(source[i, j]);
                }
            }

            return(copy);
        }
コード例 #4
0
        public GameBoard(BasePlayer playerOne, BasePlayer playerTwo)
        {
            this.playerOne = playerOne;
            this.playerTwo = playerTwo;

            /*Board[0, 0] = new PieceOnBoard(playerTwo, 14);
             * Board[1, 0] = new PieceOnBoard(playerOne, 14);
             * Board[1, 6] = new PieceOnBoard(playerOne, 1);
             * Board[0, 6] = new PieceOnBoard(playerTwo, 1);*/
            Board[0, 0]  = new PieceOnBoard(playerOne, 2);
            Board[0, 5]  = new PieceOnBoard(playerTwo, 5);
            Board[0, 7]  = new PieceOnBoard(playerTwo, 3);
            Board[0, 11] = new PieceOnBoard(playerOne, 5);
            Board[1, 11] = new PieceOnBoard(playerTwo, 5);
            Board[1, 7]  = new PieceOnBoard(playerOne, 3);
            Board[1, 5]  = new PieceOnBoard(playerOne, 5);
            Board[1, 0]  = new PieceOnBoard(playerTwo, 2);
        }