ajoute la possiblilité d'ajouter des lignes de garbage

This commit is contained in:
2025-03-01 18:41:09 +01:00
parent 66c2cf1013
commit 03281a6d70
4 changed files with 40 additions and 4 deletions

View File

@@ -8,6 +8,7 @@
#include <vector>
#include <set>
#include <memory>
#include <cstdlib>
GameBoard::GameBoard(int boardWidth, int boardHeight, const std::shared_ptr<PiecesList>& pieceList, int nextQueueLength) :
@@ -215,12 +216,23 @@ LineClear GameBoard::lockPiece() {
&& this->isActivePieceInWall(Position{-1, 0}) && this->isActivePieceInWall(Position{0, -1}));
for (Position position : this->activePiece->getPositions()) {
this->board.addBlock(position + this->activePiecePosition, this->activePiece->getBlockType());
this->board.changeBlock(position + this->activePiecePosition, this->activePiece->getBlockType());
}
return LineClear{this->board.clearRows(), isLockedInPlace, (!isLockedInPlace) && this->isLastMoveKick};
}
void GameBoard::addGarbageRows(int number) {
int holePosition = std::rand() % this->board.getWidth();
for (int i = 0; i < number; i++) {
this->board.insertRow(0, holePosition, GARBAGE);
if (this->touchesGround()) {
this->activePiecePosition.y += 1;
}
}
}
Board GameBoard::getBoard() const {
return this->board;
}