Next: , Up: Operations on Stacks   [Contents][Index]


3.5.1 Creating the Deck

A quite common operation is the creation of a card deck. The deck will initially be represented by an open stack (see TMCG_OpenStack) called deck. Every player creates his own instance of the deck, which consists of 52 open cards of different type in our example.

TMCG_OpenStack<VTMF_Card> deck;
for (size_t type = 0; type < 52; type++)
{
  VTMF_Card c;
  tmcg->TMCG_CreateOpenCard(c, vtmf, type);
  deck.push(type, c);
}

Note that the instances of the deck must be consistent for all players, that means, the order of the open cards and their types must be exactly the same for all players.

Finally, we copy the deck to a regular stack s for further processing:

TMCG_Stack<VTMF_Card> s;
s.push(deck);