private bool checkIfPlayerWon(int i_LastInsertedColumn) { int lastInstertedRow = m_CurrentEmptyRowInColumn[i_LastInsertedColumn] - 1; eBoardSquare currentPlayerSquare = m_GameBoard[lastInstertedRow, i_LastInsertedColumn]; bool playerWon = checkCurrentColumn(lastInstertedRow, i_LastInsertedColumn, currentPlayerSquare); if (!playerWon) { playerWon = checkCurrentRow(lastInstertedRow, i_LastInsertedColumn, currentPlayerSquare); if (!playerWon) { playerWon = checkCurrentDiagonals(lastInstertedRow, i_LastInsertedColumn, currentPlayerSquare); } } return(playerWon); }
public bool TryToSetColumnSquare(int i_ColumnIndex, eBoardSquare i_PlayerSquare) { bool isColumnFull = true; if (isValidColumn(i_ColumnIndex)) { if (m_CurrentEmptyRowInColumn[i_ColumnIndex] > 0) { m_GameBoard[m_CurrentEmptyRowInColumn[i_ColumnIndex] - 1, i_ColumnIndex] = i_PlayerSquare; --m_NumberOfEmptySquares; setNewBoardStatus(i_ColumnIndex); --m_CurrentEmptyRowInColumn[i_ColumnIndex]; isColumnFull = false; } } return(isColumnFull); }
private bool checkCurrentDiagonals(int i_LastInstertedRow, int i_LastInsertedColumn, eBoardSquare currentPlayerSquare) { bool playerWon = false; return(playerWon); }
private bool checkCurrentRow(int i_LastInstertedRow, int i_LastInsertedColumn, eBoardSquare currentPlayerSquare) { bool playerWon = false; int maxNumberofSquaresInARow = 0; for (int i = 0; i < Columns && !playerWon; ++i) { if (m_GameBoard[i_LastInstertedRow, i] == currentPlayerSquare) { ++maxNumberofSquaresInARow; } else { maxNumberofSquaresInARow = 0; } if (maxNumberofSquaresInARow == k_NumberOfSquaresInARowNeededForVictory) { playerWon = true; } } return(playerWon); }