Banjo

Veteran
Veteran
Joined
Jan 4, 2013
Messages
96
Reaction score
20
First Language
English
Primarily Uses
RMVXA
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?
 

spec3

blep
Veteran
Joined
Jun 20, 2020
Messages
49
Reaction score
107
First Language
portuguese
Primarily Uses
RMMV
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.
 
  • Like
Reactions: Bex

Animebryan

Need more resources!
Veteran
Joined
Jul 31, 2012
Messages
456
Reaction score
241
First Language
English
Primarily Uses
RMMZ
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.
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
6,013
Reaction score
5,662
First Language
English
Primarily Uses
RMVXA
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.
 

Kazimoria

Warper
Member
Joined
Jan 30, 2019
Messages
3
Reaction score
1
First Language
English
Primarily Uses
RMMV
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 :)
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

A side story is almost getting into the next stage. Almost everything in this game has real-life references.
unfinishedbuildingwip1.jpg
Everyday life is full of absurdity. This is just a reflection.
TFW you discover how the script batching works in VNMaker... after you've had the program for almost 3 years.
hAx6iQ3.gif

Writes that the characters have to climb a mountain.

Realized that I have to draw six sets of models where characters are climbing.

At least I know how to draw something. :)
I'm currently scratching my head on how to design plains. What do I even put in plains? Some trees (but not too many or it turns into a forest)? Grass? A few bushes? That's a bit dull.
I'm looking for tutorials but Google didn't seem to find much (or maybe I have the wrong keywords). I don't know how to map plains and I don't know how to learn.

Forum statistics

Threads
111,406
Messages
1,060,897
Members
144,760
Latest member
Belphegor
Top