initial commit

This commit is contained in:
2025-02-25 12:07:16 +01:00
commit 0657bc9b25
34 changed files with 3069 additions and 0 deletions

48
src/Pieces/Piece.h Normal file
View 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);
};