This commit is contained in:
@@ -11,9 +11,9 @@
|
||||
|
||||
Piece::Piece(const Polyomino& polyomino, Block blockType) :
|
||||
polyomino(polyomino),
|
||||
blockType(blockType) {
|
||||
|
||||
this->rotationState = NONE;
|
||||
blockType(blockType),
|
||||
rotationState(NONE),
|
||||
positions(polyomino.getPositions()) {
|
||||
}
|
||||
|
||||
void Piece::rotate(Rotation rotation) {
|
||||
@@ -25,6 +25,7 @@ void Piece::rotate(Rotation rotation) {
|
||||
this->polyomino.rotateCCW();
|
||||
|
||||
this->rotationState += rotation;
|
||||
this->positions = polyomino.getPositions();
|
||||
}
|
||||
|
||||
void Piece::defaultRotation() {
|
||||
@@ -36,10 +37,11 @@ void Piece::defaultRotation() {
|
||||
this->polyomino.rotateCW();
|
||||
|
||||
this->rotationState = NONE;
|
||||
this->positions = polyomino.getPositions();
|
||||
}
|
||||
|
||||
const std::set<Position>& Piece::getPositions() const {
|
||||
return this->polyomino.getPositions();
|
||||
const std::vector<Position>& Piece::getPositions() const {
|
||||
return this->positions;
|
||||
}
|
||||
|
||||
int Piece::getLength() const {
|
||||
@@ -54,3 +56,7 @@ std::ostream& operator<<(std::ostream& os, const Piece& piece) {
|
||||
os << getConsoleColorCode(piece.blockType) << piece.polyomino << getResetConsoleColorCode();
|
||||
return os;
|
||||
}
|
||||
|
||||
bool Piece::containsSquare(const Position& position) const {
|
||||
return polyomino.contains(position);
|
||||
}
|
||||
Reference in New Issue
Block a user