Game H
Game H
#define GAME_H
#include "Brick.h"
#include "Board.h"
#include "Observable.h"
#include "Shapes_Container.h"
#include <memory>
namespace Tetris
{
/**
* @brief Represents the game logic for Tetris.
*/
class Game : public Observable{
public:
/**
* @brief Deleted default constructor.
*/
Game() = delete;
/**
* @brief Constructs a game instance with the specified parameters.
* @param height The height of the game board.
* @param width The width of the game board.
* @param lvl The initial level of the game.
* @param partially_filled Boolean indicating whether the board should be
partially filled.
*/
Game(unsigned height,unsigned width,unsigned lvl, bool partially_filled) :
level(lvl), board(height,width,partially_filled),score(0),rowcpt(0),
gameOver(false),currentBrick(nullptr), shapesContainer(), pause(true){}
/**
* @brief Retrieves the current piece in the game.
* @return A reference to the current piece.
*/
inline const Brick& getCurrentBrick() const {return *currentBrick;}
/**
* @brief Retrieves the current board of the game.
* @return A reference to the current board.
*/
inline const Board& getBoard() const {return board;}
/**
* @brief Retrieves the current score of the game.
* @return The current score.
*/
inline const unsigned getScore() const {return score;}
/**
* @brief Retrieves the number of rows completed in the game.
* @return The current number of completed rows.
*/
inline const unsigned getRowCpt() const {return rowcpt;}
/**
* @brief Retrieves the current level of the game.
* @return The current level.
*/
inline const unsigned getLevel() const {return level;}
/**
* @brief Checks if the game is over.
* @return True if the game is over, false otherwise.
*/
inline const bool isGameOver() const {return gameOver;}
private:
/**
* @brief Starts the game.
*/
void startGame();
/**
*@brief Sets the pause status of the game.
*@param status The boolean indicating whether to pause the game or not.
*/
void setPause(const bool& status);
/**
* @brief Ends the game.
*/
void endGame();
/**
* @brief Sets the game level.
* @param lvl The level to set the game to.
*/
void setLevel(const unsigned lvl);
/**
* @brief Moves the current brick in the specified direction.
* @param dir The direction in which to move the current brick.
* @return bool true if the brick moved
*/
bool move(const Direction& dir);
/**
* @brief Rotates the current brick in the specified direction.
* @param dir The direction in which to rotate the current brick.
*/
void rotate(const Direction& dir);
/**
* @brief Moves the brick down until it encounters an obstacle.
*/
void dropCurrentBrick();
/**
* @brief Advances to the next current brick and handles scoring and level
updating.
*/
void nextCurrentBrick();
} // Tetris
#endif // GAME_H