ajoute la possiblilité d'ajouter des lignes de garbage
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user