How to code a deck of custom cards?

combosmooth

  • Posts: 22
Hi,
For my next game I'd like to be able to code a deck of custom cards. The player starts with a deck of 81 cards.  There are 4  card suits, but the cards have no numbers. At some points, the player will have the ability to permanently add and remove cards from the deck.

I'm not sure how to get this part even started. Should I use an actor behavior with some kind of list of attributes?

Once I figure that out. Then comes drawing cards, discard piles and shuffling the deck back together once everything is in the discard pile. Hopefully these things come easier once i understand how to code a deck.

Any help is appreciated. Thanks.

JeffreyDriver

  • Posts: 2262
Lists would be the way to go. If you had one actor for your card, and it had an animation  for each card type.

I guess you'd have a list of all the cards (master deck), then a separate list (player deck) that the player can customise.

Shuffling is easy. Using a couple of temporary lists, use the random number block to pick an entry from one list and add it at position 0 in the other list. You can just loop through that.