Player12
An open source football management simulator
Loading...
Searching...
No Matches
GameStateRepository Class Reference

Repository class for managing the game state in the database. More...

#include <game_state_repository.h>

Public Member Functions

 GameStateRepository (std::shared_ptr< DatabaseConnection > db_conn)
 Construct a new Game State Repository object.
 
bool isFirstRun () const
 Check if this is the first time the game is run.
 
void updateGameState (uint8_t current_season, uint16_t managed_team_id, const std::string &game_date) const
 Update the current game state in the database.
 
bool loadGameState (uint8_t &current_season, uint16_t &managed_team_id, std::string &game_date) const
 Load the game state from the database.
 

Private Attributes

std::shared_ptr< DatabaseConnection > db_conn
 

Detailed Description

Repository class for managing the game state in the database.

Constructor & Destructor Documentation

◆ GameStateRepository()

GameStateRepository::GameStateRepository ( std::shared_ptr< DatabaseConnection >  db_conn)
explicit

Construct a new Game State Repository object.

Parameters
db_connShared pointer to the database connection.

Member Function Documentation

◆ isFirstRun()

bool GameStateRepository::isFirstRun ( ) const

Check if this is the first time the game is run.

Returns
True if it is the first run, false otherwise.

◆ loadGameState()

bool GameStateRepository::loadGameState ( uint8_t &  current_season,
uint16_t &  managed_team_id,
std::string &  game_date 
) const

Load the game state from the database.

Parameters
current_seasonReference to store the current season number.
managed_team_idReference to store the managed team ID.
game_dateReference to store the current game date.
Returns
True if the game state was successfully loaded, false otherwise.

◆ updateGameState()

void GameStateRepository::updateGameState ( uint8_t  current_season,
uint16_t  managed_team_id,
const std::string &  game_date 
) const

Update the current game state in the database.

Parameters
current_seasonThe current season number.
managed_team_idThe ID of the team managed by the player.
game_dateThe current date in the game as a string.

Member Data Documentation

◆ db_conn

std::shared_ptr<DatabaseConnection> GameStateRepository::db_conn
private

The documentation for this class was generated from the following files: