public GameResult(bool isGameOver, Player winningPlayer, WinningType winningType, int winningPos) { Is_Game_Over = isGameOver; Winning_Player = winningPlayer; Winning_Type = winningType; Winning_Pos = winningPos; }
public GameResult Check_Game_Over() { bool is_game_over = false; Player winning_player = Player.empty; WinningType winning_type = WinningType.ROW; int winning_pos = -1; for (int row = 0; row < NumRow; row++) { if (this.Check_Row_GameOver(row)) { is_game_over = true; winning_player = GameBoard[0, row]; winning_type = WinningType.ROW; winning_pos = row; } } for (int col = 0; col < NumCol; col++) { if (this.Check_Col_GameOver(col)) { is_game_over = true; winning_player = GameBoard[col, 0]; winning_type = WinningType.COL; winning_pos = col; } } if (this.Check_Diag_GameOver(Direction.TLtoBR)) { is_game_over = true; winning_player = GameBoard[0, 0]; winning_type = WinningType.DIAG; winning_pos = 0; } if (this.Check_Diag_GameOver(Direction.TRtoBL)) { is_game_over = true; winning_player = GameBoard[0, NumCol - 1]; winning_type = WinningType.DIAG; winning_pos = NumCol; } if (is_game_over == false) { if (this.Check_Board_Filled()) { is_game_over = true; winning_player = Player.empty; winning_type = WinningType.DRAW; winning_pos = -1; } } return(new GameResult(is_game_over, winning_player, winning_type, winning_pos)); }