initial commit
This commit is contained in:
48
src/Pieces/Piece.h
Normal file
48
src/Pieces/Piece.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include "Polyomino.h"
|
||||
#include "Rotation.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
|
||||
Color color; // the color of the piece
|
||||
|
||||
public:
|
||||
/**
|
||||
* Creates a piece with a specified shape and color
|
||||
*/
|
||||
Piece(const Polyomino& piece, Color color);
|
||||
|
||||
/**
|
||||
* Rotates the piece in the specified direction
|
||||
*/
|
||||
void rotate(Rotation rotation);
|
||||
|
||||
/**
|
||||
* Returns a copy of the list of cells of the piece
|
||||
*/
|
||||
std::set<Cell> getPositions() const;
|
||||
|
||||
/**
|
||||
* Returns the length of the piece
|
||||
*/
|
||||
int getLength() const;
|
||||
|
||||
/**
|
||||
* Returns the color of the piece
|
||||
*/
|
||||
Color getColor() const;
|
||||
|
||||
/**
|
||||
* Stream output operator, adds a 2D grid representing the piece
|
||||
*/
|
||||
friend std::ostream& operator<<(std::ostream& os, const Piece& piece);
|
||||
};
|
||||
Reference in New Issue
Block a user