Creating a Discard pile

Hi! That’s my first adventure creating apps. I am trying to create a card game. Each card contains a rule and I would like it to go to a discard pile as soon as it is drawn. Can I do this?

Also, each card taken is a different image and has a specific one that allows you to select one from the discard pile, is there also a way to add some rules so you can check the pile and select a removed card as soon as this card is taken?

Thanks!!!

Sure.
That is the point of programming: you can do almost anything.

The problem is that YOU have to make it do anything.
With your card game, that means you have to use some kind of code number and associate them with images and rules. Those values are static (such that card #12 would always retain its image and rule reference). Then, each card also has a dynamic set of attributes. If card #12 is at position 5 in the deck, that is the value its ‘position’ attribute has. If it is in the discard pile, then it would be -99 (for instance).
Discarding a card would therefore replace its position in the deck value from 5 (for instance) to -99.

Then you would have a internal deck position counter that says which position is now at the top of the pile (it would start with 1, and by the time you reach the 5th card, that position would be 5, and all the cards with position below 5 would have now been discarded (with values set to -99) or in the had of player 1 (position value -1), player 2 (position value -2).

For instance.

The point is that you make a system that would work. And you program accordingly.

1 Like