// $G$ DSN-002 (-20) No UI seperation! This class merge the Logic board with the Visual board (UserControl) of the game... private void checkTheNextStatusInTheGame() { const bool v_HasFreePlaceOnBoardGame = true; const bool v_NextPlayerCanContinueToPlay = true; const bool v_CurrentPlayerCanContinueToPlay = true; if (m_OthelloGameBoard.CheckTheOtheloBoardGameHasFreePlace() == v_HasFreePlaceOnBoardGame) { // There is still empty place in board if (m_OthelloGameRules.CheckIfPlayerHasOptionContinueToPlay(OthelloGamePlayer.GetTheOppositeColor(m_CurrentSignalTurn), m_OthelloGameBoard, m_SecondPlayer) == v_NextPlayerCanContinueToPlay) { // The next player can play - change turn and let him play nextPlayerCanPlayInTheNextTurn(); } else { // The next player can't play - so check if the current player can play now another turn if (m_OthelloGameRules.CheckIfPlayerHasOptionContinueToPlay(m_CurrentSignalTurn, m_OthelloGameBoard, m_SecondPlayer) == v_CurrentPlayerCanContinueToPlay) { // Let the current player to play another game currentPlayerCanPlayThisTurn(); } else { // No one from players can play - GAME OVER announceGameOver(); } } } else { // No empty place in board = GAME OVER announceGameOver(); } }
public OthelloGameBoardForm(OthelloGameBoard i_OthelloGameBoard, OthelloGamePlayer i_FirstPlayer, OthelloGamePlayer i_SecondPlayer) { InitializeComponent(); m_GameBoardSize = i_OthelloGameBoard.OtheloGameBoardMatrixDimension; m_OthelloGameRules = new OthelloGameRules(m_GameBoardSize, i_SecondPlayer); m_OthelloGameBoard = i_OthelloGameBoard; m_FirstPlayer = i_FirstPlayer; m_SecondPlayer = i_SecondPlayer; m_CurrentSignalTurn = OthelloGamePlayer.ePlayerColorTypes.Black; m_ButtonsMatrix = new ButtonWithPositionInMatrix[m_GameBoardSize, m_GameBoardSize]; }
private void createThePlayers(out OthelloGamePlayer o_FirstPlayer, out OthelloGamePlayer o_SecondPlayer, OthelloGameBoard.eGameTypes i_GameStatus) { // Create the first player o_FirstPlayer = new OthelloGamePlayer(OthelloGamePlayer.ePlayerColorTypes.Black, OthelloGameBoard.eGameTypes.Player); // Create the second player to play with if (i_GameStatus == OthelloGameBoard.eGameTypes.Computer) { o_SecondPlayer = new OthelloGamePlayer(OthelloGamePlayer.ePlayerColorTypes.White, OthelloGameBoard.eGameTypes.Computer); } else { o_SecondPlayer = new OthelloGamePlayer(OthelloGamePlayer.ePlayerColorTypes.White, OthelloGameBoard.eGameTypes.Player); } }
public void GetTheNumOfPointsPlayersInThisGame(OthelloGamePlayer.ePlayerColorTypes i_TheWinnerOfTheCurrentGame, out int o_PointsToWinnerInCurrentGame, out int o_PointsToLosserInCurrentGame, OthelloGamePlayer i_FirstPlayer, OthelloGamePlayer i_SecondPlayer) { if (i_TheWinnerOfTheCurrentGame == OthelloGamePlayer.ePlayerColorTypes.Black) { i_FirstPlayer.PlayerTotalPoints++; o_PointsToWinnerInCurrentGame = this.NumOfFirstPlayerSignalsOnBoard; o_PointsToLosserInCurrentGame = this.NumOfSecondPlayerSignalsOnBoard; } else if (i_TheWinnerOfTheCurrentGame == OthelloGamePlayer.ePlayerColorTypes.White) { i_SecondPlayer.PlayerTotalPoints++; o_PointsToWinnerInCurrentGame = this.NumOfSecondPlayerSignalsOnBoard; o_PointsToLosserInCurrentGame = this.NumOfFirstPlayerSignalsOnBoard; } else { o_PointsToWinnerInCurrentGame = (m_OtheloGameBoardMatrixDimension * m_OtheloGameBoardMatrixDimension) / 2; o_PointsToLosserInCurrentGame = o_PointsToWinnerInCurrentGame; } }