|
Trabalho Prático - PDS2
|


Membros Públicos | |
| Lig4 (int rows, int cols) | |
| Constructs a new Lig4 object with the specified number of rows and columns. | |
| void | validateMove (int col) |
| Validates a move in the Lig4 game. | |
| void | makeMove () override |
| Executes a move in the Lig4 game. | |
| char | isGameFinished () override |
| Checks if the game is finished. | |
| void | printBoard () override |
| Prints the current state of the game board to the standard output. | |
Membros Públicos herdados de Game | |
| Game (int rows, int cols) | |
| Constructs a new Game object with the specified number of rows and columns. | |
| void | changePlayer () |
Membros privados | |
| bool | checkDirection (int row, int col, int rowDir, int colDir) |
| Checks if there are four consecutive elements in a specified direction. | |
| void | readMove () override |
| Reads a move from the user and validates it. | |
Outros membros herdados | |
Atributos Protegidos herdados de Game | |
| Board | board |
| std::pair< int, int > | move |
| char | current_player |
| Lig4 | ( | int | rows, |
| int | cols ) |
|
private |
Checks if there are four consecutive elements in a specified direction.
This function checks if there are four consecutive elements starting from the given position (row, col) in the direction specified by (rowDir, colDir).
| row | The starting row position. |
| col | The starting column position. |
| rowDir | The row direction to check (e.g., 1 for down, -1 for up, 0 for no vertical movement). |
| colDir | The column direction to check (e.g., 1 for right, -1 for left, 0 for no horizontal movement). |


|
overridevirtual |
Checks if the game is finished.
This function iterates through the entire game board and checks for a winning condition in four possible directions: horizontal, vertical and diagonals. If a winning condition is found, it returns the element (player) that has won. If the board is full and no winning condition is found, it returns 'D' indicating a draw. If the game is still ongoing, it returns 'E'.
int The element (player) that has won, 'D' for draw, or 'E' for ongoing game. Implementa Game.

|
overridevirtual |
Executes a move in the Lig4 game.
This function reads the player's move and updates the game board. It places the current player's piece in the lowest available position in the specified column.
Implementa Game.

|
overridevirtual |
Prints the current state of the game board to the standard output.
Reimplementa Game.

|
overrideprivatevirtual |
Reads a move from the user and validates it.
| InvalidInputException | if the input column is invalid. |
Implementa Game.


| void validateMove | ( | int | col | ) |
Validates a move in the Lig4 game.
This function checks if the specified column is within the valid range and if the top position of the column is not already occupied.
| col | The column number to validate. |
| InvalidInputException | if the column is out of bounds or the position is occupied. |

