4 #include <forward_list>
6 #include <unordered_set>
74 : hue(hue), neighbors(neighbors) {}
79 bool operator==(
const BubbleCell& other)
const {
80 return hue == other.hue;
83 bool operator!=(
const BubbleCell& other)
const {
84 return hue != other.hue;
87 void operator=(
const size_t hue) {
126 : row(row), col(col), hue(hue) {}
139 std::vector<BubbleEvent> events;
148 : events(events), type(type) {}
151 : events(std::move(events)), type(type) {}
168 MATCHES_TO_POP(
GameUtils::getCfgSizeT(
"*.Board",
"MATCHES_TO_POP")),
225 size_t get(
const size_t row,
const size_t col)
const;
235 size_t getNbrs(
const size_t row,
const size_t col)
const;
253 void set(
const size_t row,
const size_t col,
const size_t hue);
264 size_t count()
const;
273 bool oob(
const size_t row,
const size_t col)
const;
288 bool canAttach(
const size_t row,
const size_t col)
const;
304 bool attach(
const size_t row,
const size_t col,
const size_t hue);
324 bool pop(
const size_t row,
const size_t col,
const size_t matches = 0);
361 bool update(
const size_t row,
const size_t col,
const size_t hue,
const size_t matches = 0);
367 void fill(
const size_t hue);
393 const size_t MATCHES_TO_POP;
395 std::vector<BubbleCell> board;
397 std::forward_list<BubbleEventVector> boardEvents;
399 size_t at(
const size_t row,
const size_t col)
const;
400 void applyNbrs(std::vector<BubbleCell>& b,
const size_t row,
const size_t col);
402 std::array<std::pair<int, int>, 6> getOffsets(
const size_t row)
const;
Represents the game board and provides public methods to interact with it.
Definition: board.hpp:47
size_t getGridSize(const size_t nRows) const
Returns the total number of cells of the game board.
Definition: board.cpp:17
size_t getColAlign(const size_t row) const
Returns the number of columns in the game board on the requested row.
Definition: board.cpp:13
bool pop(const size_t row, const size_t col, const size_t matches=0)
Pops same-colored bubbles starting from the specified cell on the board.
Definition: board.cpp:65
bool update(const size_t row, const size_t col, const size_t hue, const size_t matches=0)
Applies all transformations for a game loop iteration, while allowing for a new bubble to be attached...
Definition: board.cpp:149
void set(const size_t row, const size_t col, const size_t hue)
Sets the hue of a bubble at the specified location on the board.
Definition: board.cpp:29
size_t getCols() const
Getter for the maximum number of columns in the game board (column amount alternates on row index).
Definition: board.cpp:9
BubbleEventVector popEventVec()
Pops and returns the first event vector from the board event list.
Definition: board.cpp:173
size_t getNbrs(const size_t row, const size_t col) const
Getter for the number of neighbors of a bubble on the game board.
Definition: board.cpp:25
size_t count() const
Returns the number of non-empty board cells.
Definition: board.cpp:38
size_t getRows() const
Getter for the number of rows in the game board.
Definition: board.cpp:5
void dropFloating()
Drops floating bubbles on the board.
Definition: board.cpp:104
void fill(const size_t hue)
Fills the game board data structure.
Definition: board.cpp:159
bool canAttach(const size_t row, const size_t col) const
Checks if a bubble can be attached to a specific location on the board.
Definition: board.cpp:48
bool reachedBottom() const
Checks if the board has a bubble in its lowest row.
Definition: board.cpp:141
size_t get(const size_t row, const size_t col) const
Getter for the hue of a bubble on the game board.
Definition: board.cpp:21
GameBoard(const size_t rows, const size_t cols)
Constructor for the GameBoard class.
Definition: board.hpp:165
bool attach(const size_t row, const size_t col, const size_t hue)
Attaches a bubble to a specific location on the board.
Definition: board.cpp:52
bool hasEvents() const
Checks if the board has any event vectors that other modules might want to process.
Definition: board.cpp:169
bool oob(const size_t row, const size_t col) const
Checks if a specific row and column are out of bounds.
Definition: board.cpp:44
Provides utility functions for the game.
Definition: util.hpp:26
Represents a bubble cell on the game board.
Definition: board.hpp:61
BubbleCell(size_t hue=0, size_t neighbors=0)
Default constructor for the BubbleCell struct.
Definition: board.hpp:73
Wraps the row and column of a bubble on the board with its hue.
Definition: board.hpp:113
BubbleEvent(size_t row, size_t col, size_t hue)
Constructs a BubbleEvent instance with the given hue, row, and column.
Definition: board.hpp:125
Holds a vector of bubble events and the type of event that occurred.
Definition: board.hpp:106
EventType
Determines the type of event that occurred with the bubble.
Definition: board.hpp:133
BubbleEventVector(const std::vector< BubbleEvent > &events, const EventType type)
Constructs a BubbleEventVector instance with the given events and type.
Definition: board.hpp:147