this function is meant to merge two "hands" of cards by alternating both hands into the one hand. CardSet is a class and newSet is passed to the function as an instance of the class.
void CardSet::MergeShuffle(CardSet& newSet)
{//merges two sets of cards together, alternating between the sets
int *Temp;
int a = newSet.nCards, a2 = a + nCards; //variables to store the size of Card from curret set and passed set
Temp = newint[a2]; //pointer array big enough to store all of the cards
for (int i = 0, x = 0, y = 0; i < a2; x++, y++) //alternate storing the cards
{
if (Card[x]) //if the card exists, store it
{
Temp[i] = Card[x];
i++;
}
if (newSet.Card[y]) //if the card exists, store it
{
Temp[i] = newSet.Card[y];
i++;
}
}
Card = newint[a2];
for (int i = 0; i < a2; i++) //copy the merged cards from Temp back into Card
Card[i] = Temp[i];
}
if you have can improve it, please let me know, thanks guys.