Creating a simple virtual "deck of cards"?

I know there are custom plugins for complex CCGs and card game minigames, but that's not what I need. Instead, here's what I want to do...

1) There are four different card "types" (for example: earth, fire, wind, water).
2) Sitting on a table is a "deck" of cards that contains the following 8 cards: x2 earth cards, x3 fire cards, x1 wind card, x2 water cards.
3) The player "uses" the object (event) deck and "draws" a card at RANDOM from the deck. The player is told what card they drew and the card is REMOVED from the deck.
4)The player can keep drawing cards until they have drawn them all, at which point they can reshuffle the deck and start over.

How would I go about doing this? It seems quite possible with just eventing and minor scripting but I'm not really sure how to make this work.

The bit I'm most stuck on is removing the card from the deck so the same card can't be drawn again until all the others have been.

Do I need to script a variable array, or is there a simpler option with conditions and normal variables?
This may be not the most practical solution, but maybe it can help you with something. You could number each card. Let's say: earth (1), earth (2), fire (3), fire (4), and so on.

Now when it hit the event deck you'll pull the random card. If 1, then it pulled earth; if 3, fire...

Store the pulled card number in another variable.

Hit the deck event again, if the number pulled is the same stored, repeat the process to pull another number and ignore this one. Repeat the process with (number of cards - 1) variables. I believe you could achieve this in a more easy way, but that's what came into my mind.
This can be done through variables. Set 4 variables to keep track of how many cards of that element are still in the deck, along with a 5th variable to keep track of the total cards remaining in the deck. When drawing a card, have a variable set for generating a random number. It can range from 1-4, or you can scale up the range to 1-8/12/16/etc. if you feel it will help balance the number generator.

When that number lands on whatever number the elements are assigned to, have it check to see if the variable keeping track of that number is greater than 0. You'll also need variables to keep track of how many cards the player is holding (as well as the hands of your opponent(s) if any). Not only 1 variable for the total cards held but a variable for each element in your hand as well.

When the number of cards in the deck reach 0, simply set all the variables for held cards to 0 & set the variables for cards in the deck (as well as cards per element) back to their default value.
You can do it with pure eventing the way @spec3 suggests, which is how I made my first card game in VX Ace. You'll have a lot of conditional branches checking the RNG result against each number stored as "already pulled", and then you will either exit or repeat the loop based on whether a match was found.

However, there's a much easier way to do this which involves populating all of the possible draws into an Array (you can store an array inside any of your game's Variables), randomly picking an integer from 0 to (the Array's current size - 1) as an index, taking the value of the entry at that index in the array, and then finally removing that value from the array (repopulating the array with all possible cards once it's empty). This can be done with like 5 lines of code (instead of a couple hundred lines of eventing), will process much quicker in-game, and is more expandable to extra features in your game.

I've been working with GameMaker Language all day, so I'm certainly going to make mistakes if I try to give you the actual code to do this with. You can check out Array documentation and this example of picking a random value from an array as a framework to get started. If you need some more help with the syntax, I suggest making a topic in the Learning JavaScript section and linking back to this topic.
Unfortunately i might not have time to help in, but it's quite easily doable, but like user wavelength said,it's easier to do it with array via scriptcall, create and array,randomize it, get value at the end of array via array.length -1, and the pop it so that used value will not occur again, hope that helps 🙂

Original thread: https://forums.rpgmakerweb.com/threads/creating-a-simple-virtual-deck-of-cards.123256/