Files
jminos/src/Core/Bag.h
2025-03-01 19:13:49 +01:00

51 lines
1.6 KiB
C++

#pragma once
#include "../Pieces/Piece.h"
#include "PiecesList.h"
#include <vector>
#include <memory>
#include <utility>
/**
* A litteral bag of pieces, in which you take each of its piece randomly one by one then start again with a new bag
*/
class Bag {
private:
std::shared_ptr<PiecesList> piecesList; // the list of loaded pieces
std::vector<std::pair<int, int>> selectedPieces; // the list of pieces that can be given to the player
std::pair<int, int> next; // the next piece to give
std::vector<std::pair<int, int>> currentBag; // the list of pieces that are still to be taken out before starting a new bag
std::vector<std::pair<int, int>> nextBag; // the list of pieces that have been taken out of the current bag and have been placed in the next
public:
/**
* Creates a new bag with the pieces currently selected in the piece list
*/
Bag(std::shared_ptr<PiecesList> piecesList);
/**
* Ignores the remaining pieces in the current bag and startd fresh from a new bag
*/
void jumpToNextBag();
/**
* Looks at what the next picked piece will be, without removing it from the bag
* @return The next piece
*/
Piece lookNext();
/**
* Picks a new piece from the current bag, removing it from the bag
* @return The next piece
*/
Piece getNext();
private:
/**
* Prepare the next picked piece in advance
*/
void prepareNext();
};