Variable value : Random from 0 to [Another variable value]

I think the title speaks for itself, but to clarify things, I want to know is it possible to make a variable value a random number from 0 to the value of another variable.
Let's assume that player in the game collecting special cards, and when he finds new card, variable that showing number of cards that he found, increases by 1.
And then in a specific event the game must show random card from his deck, so it must be random number from 0 to the final number of cards, that was found, and then many "if" conditions for each card to show it depending on random number.

Moreover, that system is bad because if the cards are just counts as +1 to a variable value, then the player must collect them in a strict sequence(if player will find 17 card after 15, then it will count as 16, so he can't break the sequence).
And because of that, ideally, i want to make a system, that will show random card from the one's, that he found and they can be found in any sequence. That would be just perfect.
that approach has so many issues (beyond what you already listed) that I would advice against it.

The correct approach would be to use arrays, with each array element being one card, and then copy or remove elements as needed, with one array as the deck and another as the hand.

Unfortunately the events have no array commands, so this will require you to learn some javascript.
And I don't have that ready in mind, so I suggest you ask a mod to move this topic into learning javascript and wait until someone with more current javascript knowledge tells you the commands needed (that are only half a dozen or so)
What I'd do is have a switch for every individual card unlock, which is switched ON when the card is obtained. When the event runs to display a random unlocked card, it'll run a random number between 0 and the total number of cards in the game. If the number lands on a card not yet unlocked (check conditional branch -> Switch), loop the randomiser from the start. It'll be a to set up, depending on the number of cards in the game, but it should work just fine.
What I'd do is have a switch for every individual card unlock, which is switched ON when the card is obtained. When the event runs to display a random unlocked card, it'll run a random number between 0 and the total number of cards in the game. If the number lands on a card not yet unlocked (check conditional branch -> Switch), loop the randomiser from the start. It'll be a ***** to set up, depending on the number of cards in the game, but it should work just fine.
That really works, thank you very much.

Original thread: https://forums.rpgmakerweb.com/threads/variable-value-random-from-0-to-another-variable-value.131432/