I just made a function that will return a random card from a sorted deck, but I cant get it to stop shuffling the cards every time I goto retrieve one,
Anyone have an idea how to make it so that, that loop will only run ounce? I was thinking of using a “if” statement, but cant get it to work..Code:char get_card(short int c) { vector<char> cards; cards.push_back('A'); cards.push_back('2'); cards.push_back('3'); cards.push_back('4'); cards.push_back('5'); cards.push_back('6'); cards.push_back('7'); cards.push_back('8'); cards.push_back('9'); cards.push_back('10'); cards.push_back('J'); cards.push_back('Q'); cards.push_back('K'); for (int i=0; i<=randomNumber(0); i++) { random_shuffle(cards.begin(), cards.end()); } return cards[c]; }



LinkBack URL
About LinkBacks



