allow resetting games

This commit is contained in:
2025-03-01 19:13:49 +01:00
parent 03281a6d70
commit d443b25de1
10 changed files with 97 additions and 14 deletions

View File

@@ -19,6 +19,19 @@ Bag::Bag(std::shared_ptr<PiecesList> piecesList) :
this->prepareNext();
}
void Bag::jumpToNextBag() {
// if the bag is empty switch to the next bag
if (this->currentBag.empty()) {
std::swap(this->currentBag, this->nextBag);
}
// get the already used pieces back to the current bag
for (const std::pair<int, int>& pieceIndex : this->nextBag) {
this->currentBag.emplace_back(pieceIndex);
}
this->nextBag.clear();
}
Piece Bag::lookNext() {
return this->piecesList->getPiece(this->next);
}