![]() |
ConnectX 3.0
ConnectX Game Suite
|
#include <engine.hpp>
Public Types | |
| using | StateChangeCallback = std::function< void(const GameState &)> |
Public Member Functions | |
| GameEngine (uint8_t rows=6, uint8_t cols=7, uint8_t num_players=2, uint8_t connect_length=4) | |
| void | startGame () |
| bool | makeMove (uint8_t column) |
| bool | makeMove (uint8_t column, uint8_t player_id) |
| void | reset () |
| void | setStateChangeCallback (StateChangeCallback callback) |
| void | skipPlayerTurn () |
| const GameState & | getState () const |
| const GameRules & | getRules () const |
| bool | isGameOver () const |
| std::optional< uint8_t > | getWinner () const |
Core game engine - manages game flow and enforces rules
| using GameEngine::StateChangeCallback = std::function<void(const GameState &)> |
| GameEngine::GameEngine | ( | uint8_t | rows = 6, |
| uint8_t | cols = 7, |
||
| uint8_t | num_players = 2, |
||
| uint8_t | connect_length = 4 |
||
| ) |
|
inline |
|
inline |
|
inline |
| bool GameEngine::isGameOver | ( | ) | const |
| bool GameEngine::makeMove | ( | uint8_t | column | ) |
Make a move for the current player
| column | Column to drop piece in |
| bool GameEngine::makeMove | ( | uint8_t | column, |
| uint8_t | player_id | ||
| ) |
Make a move for a specific player (with validation)
| column | Column to drop piece in |
| player_id | Player making the move |
| void GameEngine::reset | ( | ) |
Reset the game to initial state
|
inline |
Register callback for state changes
|
inline |
Skip one player's turn
| void GameEngine::startGame | ( | ) |
Start a new game