Files
jminos/src/Pieces/Piece.h

51 lines
1.2 KiB
C++

#pragma once
#include "Polyomino.h"
#include "Rotation.h"
#include "Block.h"
#include "Color.h"
#include <set>
/**
* An abstraction of a polyomino as a playable piece in a stacker game
*/
class Piece {
private:
Polyomino polyomino; // a polyomino representing the piece, (0, 0) is downleft
Block blockType; // the block type of the piece
public:
/**
* Creates a piece with a specified shape and block type
*/
Piece(const Polyomino& piece, Block blockType);
/**
* Rotates the piece in the specified direction
*/
void rotate(Rotation rotation);
/**
* @return A copy of the list of positions of the piece
*/
std::set<Position> getPositions() const;
/**
* @return The length of the piece
*/
int getLength() const;
/**
* @return The block type of the piece
*/
Block getBlockType() const;
/**
* Stream output operator, adds a 2D grid representing the piece
* @return A reference to the output stream
*/
friend std::ostream& operator<<(std::ostream& os, const Piece& piece);
};