début de la classe PiecesFile
This commit is contained in:
@@ -1,19 +1,18 @@
|
||||
#include "Bag.h"
|
||||
|
||||
#include "../Pieces/Piece.h"
|
||||
#include "PiecesList.h"
|
||||
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
Bag::Bag(const std::vector<Piece>& pieces) :
|
||||
pieces(pieces) {
|
||||
Bag::Bag(std::shared_ptr<PiecesList> piecesList) :
|
||||
piecesList(piecesList) {
|
||||
|
||||
// initialize bags
|
||||
this->currentBag.clear();
|
||||
for (int i = 0; i < this->pieces.size(); i++) {
|
||||
this->currentBag.push_back(i);
|
||||
}
|
||||
this->currentBag = this->piecesList->getSelectedPieces();
|
||||
this->nextBag.clear();
|
||||
|
||||
// prepare first piece
|
||||
@@ -21,18 +20,18 @@ Bag::Bag(const std::vector<Piece>& pieces) :
|
||||
}
|
||||
|
||||
Piece Bag::lookNext() {
|
||||
return this->pieces.at(this->next);
|
||||
return *this->piecesList->getPiece(this->next.first, this->next.second);
|
||||
}
|
||||
|
||||
Piece Bag::getNext() {
|
||||
// get the piece to return
|
||||
int nextIndex = this->next;
|
||||
std::pair<int, int> nextIndex = this->next;
|
||||
|
||||
// prepare the piece even after the next
|
||||
this->prepareNext();
|
||||
|
||||
// return the next piece
|
||||
return this->pieces.at(nextIndex);
|
||||
return *this->piecesList->getPiece(nextIndex.first, nextIndex.second);
|
||||
}
|
||||
|
||||
void Bag::prepareNext() {
|
||||
|
||||
Reference in New Issue
Block a user