initial commit
This commit is contained in:
38
src/Pieces/Piece.cpp
Normal file
38
src/Pieces/Piece.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "Piece.h"
|
||||
|
||||
#include "Polyomino.h"
|
||||
#include "Rotation.h"
|
||||
#include "Color.h"
|
||||
|
||||
#include <Set>
|
||||
#include <String>
|
||||
|
||||
|
||||
Piece::Piece(const Polyomino& polyomino, Color color) : polyomino(polyomino), color(color) {
|
||||
}
|
||||
|
||||
void Piece::rotate(Rotation rotation) {
|
||||
if (rotation == CLOCKWISE)
|
||||
this->polyomino.rotateCW();
|
||||
if (rotation == DOUBLE)
|
||||
this->polyomino.rotate180();
|
||||
if (rotation == COUNTERCLOCKWISE)
|
||||
this->polyomino.rotateCCW();
|
||||
}
|
||||
|
||||
std::set<Cell> Piece::getPositions() const {
|
||||
return this->polyomino.getCells();
|
||||
}
|
||||
|
||||
int Piece::getLength() const {
|
||||
return this->polyomino.getLength();
|
||||
}
|
||||
|
||||
Color Piece::getColor() const {
|
||||
return this->color;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const Piece& piece) {
|
||||
os << COLOR_CODES[piece.color] << piece.polyomino << COLOR_RESET;
|
||||
return os;
|
||||
}
|
||||
Reference in New Issue
Block a user