revert enum class
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
Board::Board(int width, int height) : width(width), height(height) {
|
||||
std::vector<ColorEnum> emptyRow;
|
||||
for (int i = 0; i < width; i ++) {
|
||||
emptyRow.push_back(ColorEnum::NOTHING);
|
||||
emptyRow.push_back(NOTHING);
|
||||
}
|
||||
|
||||
// initialize grid
|
||||
@@ -28,7 +28,7 @@ void Board::addBlock(const Cell& position, ColorEnum block) {
|
||||
if (position.y >= this->grid.size()) {
|
||||
std::vector<ColorEnum> emptyRow;
|
||||
for (int i = 0; i < width; i ++) {
|
||||
emptyRow.push_back(ColorEnum::NOTHING);
|
||||
emptyRow.push_back(NOTHING);
|
||||
}
|
||||
for (int j = this->grid.size(); j <= position.y; j++) {
|
||||
this->grid.push_back(emptyRow);
|
||||
@@ -42,7 +42,7 @@ void Board::addBlock(const Cell& position, ColorEnum block) {
|
||||
int Board::clearRows() {
|
||||
std::vector<ColorEnum> emptyRow;
|
||||
for (int i = 0; i < width; i ++) {
|
||||
emptyRow.push_back(ColorEnum::NOTHING);
|
||||
emptyRow.push_back(NOTHING);
|
||||
}
|
||||
|
||||
// check from top to bottom
|
||||
@@ -51,7 +51,7 @@ int Board::clearRows() {
|
||||
// check if a line has a block on every column
|
||||
bool isFull = true;
|
||||
for (int i = 0; i < this->width; i++) {
|
||||
if (this->grid.at(j).at(i) == ColorEnum::NOTHING) {
|
||||
if (this->grid.at(j).at(i) == NOTHING) {
|
||||
isFull = false;
|
||||
}
|
||||
}
|
||||
@@ -70,11 +70,11 @@ int Board::clearRows() {
|
||||
ColorEnum Board::getBlock(const Cell& position) const {
|
||||
// if the block is out of bounds
|
||||
if (position.x < 0 || position.x >= this->width || position.y < 0)
|
||||
return ColorEnum::OUT_OF_BOUNDS;
|
||||
return OUT_OF_BOUNDS;
|
||||
|
||||
// if the block is higher than the current grid, since it can grow indefinitely we do as if it was there but empty
|
||||
if (position.y >= this->grid.size())
|
||||
return ColorEnum::NOTHING;
|
||||
return NOTHING;
|
||||
|
||||
// else get the color in the grid
|
||||
return this->grid.at(position.y).at(position.x);
|
||||
@@ -102,7 +102,7 @@ std::ostream& operator<<(std::ostream& os, const Board& board) {
|
||||
for (int x = 0; x < board.width; x++) {
|
||||
ColorEnum block = board.grid.at(y).at(x);
|
||||
os << getColorCode(block);
|
||||
if (block != ColorEnum::NOTHING) {
|
||||
if (block != NOTHING) {
|
||||
os << "*";
|
||||
}
|
||||
else {
|
||||
@@ -113,7 +113,7 @@ std::ostream& operator<<(std::ostream& os, const Board& board) {
|
||||
}
|
||||
|
||||
// reset console color
|
||||
os << getColorCode(ColorEnum::NOTHING);
|
||||
os << getColorCode(NOTHING);
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ std::vector<Piece> GameBoard::getNextPieces() const {
|
||||
bool GameBoard::isActivePieceInWall(const Cell& shift) const {
|
||||
// check if every cell of the active piece is in an empty spot
|
||||
for (Cell cell : this->activePiece->getPositions()) {
|
||||
if (this->board.getBlock(cell + this->activePiecePosition + shift) != ColorEnum::NOTHING)
|
||||
if (this->board.getBlock(cell + this->activePiecePosition + shift) != NOTHING)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -316,7 +316,7 @@ std::ostream& operator<<(std::ostream& os, const GameBoard& gameboard) {
|
||||
}
|
||||
|
||||
// print the board
|
||||
ColorEnum pieceColor = (gameboard.activePiece == nullptr) ? ColorEnum::NOTHING : gameboard.activePiece->getColor();
|
||||
ColorEnum pieceColor = (gameboard.activePiece == nullptr) ? NOTHING : gameboard.activePiece->getColor();
|
||||
for (int y = gameboard.board.getBaseHeight() - 1; y >= 0; y--) {
|
||||
for (int x = 0; x < gameboard.board.getWidth(); x++) {
|
||||
bool hasActivePiece = (gameboard.activePiece == nullptr) ? false : gameboard.activePiece->getPositions().contains(Cell{x, y} - gameboard.activePiecePosition);
|
||||
@@ -331,7 +331,7 @@ std::ostream& operator<<(std::ostream& os, const GameBoard& gameboard) {
|
||||
else {
|
||||
ColorEnum block = gameboard.board.getBlock(Cell{x, y});
|
||||
os << getColorCode(block);
|
||||
if (block != ColorEnum::NOTHING) {
|
||||
if (block != NOTHING) {
|
||||
os << "*";
|
||||
}
|
||||
else {
|
||||
@@ -355,7 +355,7 @@ std::ostream& operator<<(std::ostream& os, const GameBoard& gameboard) {
|
||||
}
|
||||
|
||||
// reset console color
|
||||
os << getColorCode(ColorEnum::NOTHING);
|
||||
os << getColorCode(NOTHING);
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ const Color& getColor(ColorEnum color) {
|
||||
}
|
||||
|
||||
void setNextPieceColor(ColorEnum& color) {
|
||||
if (color == ColorEnum::GREEN)
|
||||
color = ColorEnum::PURPLE;
|
||||
if (color == GREEN)
|
||||
color = PURPLE;
|
||||
else
|
||||
color = ColorEnum(color + 1);
|
||||
}
|
||||
@@ -29,7 +29,7 @@ struct Color {
|
||||
* Returns the first color a piece can take
|
||||
*/
|
||||
inline ColorEnum firstPieceColor() {
|
||||
return ColorEnum::PURPLE;
|
||||
return PURPLE;
|
||||
}
|
||||
|
||||
const Color& getColor(ColorEnum color);
|
||||
|
||||
Reference in New Issue
Block a user