Ejemplo n.º 1
0
        internal int CalcOptions(BoardSigns.eBoardSigns i_PlayerSign)
        {
            int numOfOption = 0;

            for (int row = 0; row < r_GameBoard.GetLength(0); row++)
            {
                for (int col = 0; col < r_GameBoard.GetLength(0); col++)
                {
                    if (!IsFullCell(row, col))
                    {
                        if (findOpositeSignInSquareAroundMe(row, col, BoardSigns.GetOpositeSign(i_PlayerSign)))
                        {
                            r_GameBoard[row, col].CellSign = BoardSigns.eBoardSigns.Option;
                            numOfOption++;
                        }
                        else
                        {
                            r_GameBoard[row, col].CellSign = BoardSigns.eBoardSigns.Empty;
                        }
                    }
                }
            }

            return(numOfOption);
        }
Ejemplo n.º 2
0
        private bool findOpositeSignInSquareAroundMe(int i_RowNumber, int i_ColNumber, BoardSigns.eBoardSigns i_OpositeSignToFind)
        {
            bool anyOptionFound = false;

            for (int rowDir = -1; rowDir < 2; rowDir++)
            {
                for (int colDir = -1; colDir < 2; colDir++)
                {
                    if (IsInBounds(i_RowNumber + rowDir, i_ColNumber + colDir) && r_GameBoard[i_RowNumber + rowDir, i_ColNumber + colDir].CellSign == i_OpositeSignToFind)
                    {
                        anyOptionFound |= findSignInDir(i_RowNumber, i_ColNumber, BoardSigns.GetOpositeSign(i_OpositeSignToFind), rowDir, colDir);
                    }
                }
            }

            return(anyOptionFound);
        }
Ejemplo n.º 3
0
        private void prepareNextUserTurn()
        {
            if (noMovesForPlayer(BoardSigns.GetOpositeSign(m_CurrentTurnSign)))
            {
                if (noMovesForPlayer(m_CurrentTurnSign))
                {
                    askForNewGame();
                }
            }
            else
            {
                m_CurrentTurnSign = BoardSigns.GetOpositeSign(m_CurrentTurnSign);
                Text = string.Format("{0}{1} Turn", k_FormName, getCurrentPlayerName());

                if (r_OtheloLogicGame.PcTurn(m_CurrentTurnSign))
                {
                    r_OtheloLogicGame.GetPcCellChoice(out int row, out int col);
                    BoardButton_Click(r_BoardButtons[row, col], EventArgs.Empty);
                }
            }
        }
Ejemplo n.º 4
0
 internal void FillCell(int i_RowNumber, int i_ColNumber, BoardSigns.eBoardSigns i_Sign)
 {
     r_GameBoard[i_RowNumber, i_ColNumber].CellSign = i_Sign;
     findOpositeSignInSquareAroundMe(i_RowNumber, i_ColNumber, BoardSigns.GetOpositeSign(i_Sign));
 }