Since This Post didn't exactly answer my question I'm going to start a new one.
I'm encoutering a problem when moving an element from one vector to another.
The originating vector is a simple deck of cards and the end vector is supposed to represent cards in the player's hand.
I'm using Hand.push_back(Deck.back())
to copy the "top" card and then Deck.pop_back()
to remove it from the Deck vector.
Strangely though the next time I call the Draw Card function it "draws" the same card that should have been removed last turn.
I'm guessing it's a problem with resizing the vector? Should I try Deck.resize(Deck.size() - 1)
after each pop_back()
?
void Player::DrawStartingHand(int num)
{
for(int i = 0; i < num; i++)
{
Hand.push_back(Deck.back());
Deck.pop_back();
}
}
void Player::DrawCard()
{
std::cout<< "Drawing next card..." << std::endl;
if(Deck.size() >= 1)
{
//copy card from top of deck
//place at front of hand
Hand.push_back(Deck.back());
//remove care from top of deck
Deck.pop_back();
}
else
{
std::cout<< "No cards left to draw\n";
}
}
EDIT:: Each of the above functions are currently only called in one place a piece, and not under any extreme circumstances or anything weird. Just very basic, simple calls.