# Cards: Stacking, drawing, hand, and shuffling

I am trying to make a code to simulate simple card mechanics. Moving and drawing cards won't be very hard, but I am struggling with how to make the different cards work as a deck. For example I can make cards out of two sided planes, and move and flip these cards; but I can't get it so that I can shuffle a deck, or place cards back in a deck.

So my questions are, how do I make a group of cards act as a deck to call a shuffle function on?

How do I remove cards from the deck so when I call the shuffle function, it won't shuffle cards that I have played on the table?

How can I add cards to a deck so the shuffle function will work on the deck, even though I added new cards to the original deck?

First off, to animate the cards, and actually make them, I'd suggest actually modeling and animating in 3D software, if you want to use Unity, go right ahead however...

Then, make an array the size of the deck (56?), and have it randomly give it a number, have each number 1-56 (0-55 in code) recieve a random number, then have a switch statement for each number to have a texture, a type, and a number, so that for example (psuedo code):

if card is 1, make ace hearts, if card is 2, make 2 of hearts, etc. Apply the texture, and the definition...

Then, when a card is taken out of the deck, have it subtract that from the array (sense arrays are non-mutatable... I guess you can use an ArrayList, unless those aren't used in Unity?)... Use that, can do the same thing, and then you can add and subtract cards with ease... Just have a functions for every little thing, then add them in the main code, and have it do its work...

Hope that steered you in a good direction...

For info on ArrayList's in Unity, check here: http://forum.unity3d.com/threads/24473-Problem-with-ArrayList-with-Prefab-Scripts.-(c-)

And also look around some on here and the forums more... Their are a couple things.

Good luck!