fini PiecesList
This commit is contained in:
@@ -4,25 +4,91 @@
|
||||
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
|
||||
|
||||
/**
|
||||
* A container for all loaded pieces to prevent loading and copying them multiple times,
|
||||
* also allows for the player to select a list of pieces to be used in a game
|
||||
*/
|
||||
class PiecesList {
|
||||
private:
|
||||
int maximumLoadedSize;
|
||||
std::vector<std::vector<Piece>> loadedPieces;
|
||||
std::vector<std::pair<int, int>> selectedPieces;
|
||||
|
||||
int highestLoadedSize; // the highest size of pieces currently loaded
|
||||
std::vector<std::vector<Piece>> loadedPieces; // every loaded pieces by size
|
||||
std::vector<std::vector<int>> convexPieces; // the list of convex loaded pieces by size
|
||||
std::vector<std::vector<int>> holelessPieces; // the list of holeless loaded pieces by size
|
||||
std::vector<std::vector<int>> otherPieces; // the list of other loaded pieces by size
|
||||
std::vector<std::pair<int, int>> selectedPieces; // the list of all currently selected pieces
|
||||
|
||||
public:
|
||||
/**
|
||||
* Initializes a list of pieces up to size 0 (so no pieces)
|
||||
*/
|
||||
PiecesList();
|
||||
|
||||
/**
|
||||
* Makes the list load all pieces of the specified size
|
||||
* @return If it sucessfully loaded the pieces
|
||||
*/
|
||||
bool loadPieces(int size);
|
||||
|
||||
bool selectPieces(int size, int numbers);
|
||||
/**
|
||||
* Selects the specified piece
|
||||
* @return If the piece could be selected
|
||||
*/
|
||||
bool selectPiece(int size, int number);
|
||||
|
||||
/**
|
||||
* Selects all pieces of the specified size
|
||||
* @return If the pieces could be selected
|
||||
*/
|
||||
bool selectAllPieces(int size);
|
||||
|
||||
/**
|
||||
* Selects all convex pieces of the specified size
|
||||
* @return If the pieces could be selected
|
||||
*/
|
||||
bool selectConvexPieces(int size);
|
||||
|
||||
/**
|
||||
* Selects all holeless pieces of the specified size
|
||||
* @return If the pieces could be selected
|
||||
*/
|
||||
bool selectHolelessPieces(int size);
|
||||
|
||||
/**
|
||||
* Selects all other pieces of the specified size
|
||||
* @return If the pieces could be selected
|
||||
*/
|
||||
bool selectOtherPieces(int size);
|
||||
|
||||
/**
|
||||
* Unselects all previously selected pieces
|
||||
*/
|
||||
void unselectAll();
|
||||
|
||||
/**
|
||||
* @return The highest loaded size of pieces
|
||||
*/
|
||||
int getHighestLoadedSize();
|
||||
|
||||
/**
|
||||
* @return The number of pieces of the specified size
|
||||
*/
|
||||
int getNumberOfPieces(int size);
|
||||
|
||||
/**
|
||||
* @return The indexes of all selected pieces
|
||||
*/
|
||||
std::vector<std::pair<int, int>> getSelectedPieces();
|
||||
|
||||
int getNumberOfPiecesOfOneSize(int size);
|
||||
|
||||
std::shared_ptr<Piece> getPiece(int size, int number);
|
||||
/**
|
||||
* @return The piece corresponding to the specified index
|
||||
*/
|
||||
Piece getPiece(std::pair<int, int> pieceIndex);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Adds empty vectors at the end of every pieces list
|
||||
*/
|
||||
void pushBackEmptyVectors();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user