Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

#ifndef BRICK_H

#define BRICK_H
#include "Enums.h"
#include "Position.h"
#include <vector>
#include <iomanip>
#include "Board.h"

using namespace std;


namespace Tetris
{
/**
* @brief Default relative positions for Tetris shapes.
* Each inner vector represents the relative positions of cells forming a
shape.
*/
struct RelativesPos{
static const std::vector<std::vector<Position>> defaultRelativespos;
};

/**
* @brief Represents a brick in the Tetris game.
*/
class Brick
{
public:
/**
* @brief
*/
Brick() = delete;
/**
* @brief Constructs a brick with the specified brickShape.
* @param shape The shape of the brick.
* @param board The game board on which the brick is placed.
*/
Brick(const BrickShape& shape , Board& board);
/**
* @brief Retrieves the shape of the brick.
* @return The shape of the brick.
*/
inline const BrickShape& getBrickShape() const {return shape;}
/**
* @brief Retrieves the absolute position of the brick.
* @return The absolute position of the brick.
*/
inline const Position& getAbsolutePosition() const {return
absolutePosition;}
/**
* @brief Retrieves the positions of the cells occupied by the brick.
* @return A vector containing the positions of the cells occupied by the
brick.
*/
inline const std::vector<Position>& getCellsPositions() const {return
cellsPositions;}
/**
* @brief Calculates the actual positions of the cells occupied by the
brick.
* @return A vector of positions occupied by the brick.
*/
std::vector<Position> calculateCellsPositions();
/**
* @brief Deleted to prevent assignment from nullptr.
*/
Brick& operator=(const std::nullptr_t) = delete;
/**
* @brief Destructor for the Brick class.
*/
~Brick();

private:
/**
* @brief Moves the brick in the specified direction on the board.
* @param dir The direction in which to move the brick.
* @return true if the brick moved
*/
bool moveBrick(const Direction& dir);
/**
* @brief Rotates the brick in the specified direction on the board.
* @param dir The direction in which to rotate the brick.
* @return true if the brick moved
*/
bool rotateBrick(const Direction& dir); // seulment droite ou gauche

friend class Game;


friend class BrickTest;

BrickShape shape; ///< The shape of the brick.


Position absolutePosition; ///< The position of the brick.
std::vector<Position> cellsPositions; ///< The positions of every cell
occupied by the brick.
Board& board; ///< The game board on which the brick is placed.
};

} // Tetris

#endif // BRICK_H

You might also like