Tutorial-Blog Card Game Eventing: Flipping Cards & Drawing a Hand

ShadowDragon

Realist
Regular
Joined
Oct 8, 2018
Messages
7,756
Reaction score
3,162
First Language
Dutch
Primarily Uses
RMMV
this is something really neat, I wish you had a demo for MV/MZ for this one,
so I can take a better look and action on it.

I would take a much different way for this, but this is really nice and clean too.
awesome tutorial, can come in handy, ty you for this one :).
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
5,027
Reaction score
4,360
First Language
EN
Primarily Uses
RMMZ
:kaoswt: I dislike the way this tutorial picks cards:
  1. Selection of 1 card only needs 1 random roll, e.g. an "ID" from 1 to 52 (inclusive).
    • This can be converted to "suit-#" format afterwards, e.g. 20 -> diamond-7.

  2. Looping to avoid duplicates may bias the RNG and seems inefficient.
As usual, though, the rest looks great~ :kaothx:
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,087
Reaction score
9,015
First Language
English
Primarily Uses
RMMV
Selection of 1 card only needs 1 random roll...store deck card IDs in an array and splice them out when drawn.
That seems the most efficient. Make an array of the card IDs in the first place and use one random number based on the length of that array.

It should make the randomness more fair and eliminate the need for a separate "cards drawn from deck" array. (a common need to replace that might be a "discard pile" array, depending on what the nature of the card game is.)
 

Lady_JJ

Regular
Regular
Joined
May 6, 2019
Messages
478
Reaction score
394
First Language
English
Primarily Uses
RMMZ
What a great tutorial! I never realized you could 'flip' an image without using a plugin. That trick alone is worth the time reading the tutorial. I would also shuffle the deck by splicing an array. I just love these tutorials. I learn something from each and every one.
 

hiddenone

Lurker Extraordinaire
Global Mod
Joined
Feb 19, 2014
Messages
3,065
Reaction score
6,230
First Language
english
Primarily Uses
RMMZ
@caethyril Looking back at it, I agree that using an array for the deck would probably be a better method. I wanted to try something else for this tutorial so I played around with a few ways to pick a card, and the one I ended up using seemed to work the best while being random (though that could just be because of how much rng likes to mess with me :rswt ).
 

BreakerZero

Regular
Regular
Joined
Jul 8, 2018
Messages
1,208
Reaction score
524
First Language
English (USA)
Primarily Uses
RMMV
Great tutorial. I was able to get a standard poker draw going with this which will replace a plugin that has sadly been abandoned. Not to mention that what I have isn't as flexible as it relies on mouse controls which are impractical for my Xbox port. All I need now is for someone to help me with the payout logic and I should be good to go.

Also, does anyone have any ideas on how to modify this for Blackjack?
 

Trihan

Speedy Scripter
Regular
Joined
Apr 12, 2012
Messages
6,543
Reaction score
7,083
First Language
English
Primarily Uses
RMMZ
Great tutorial. I was able to get a standard poker draw going with this which will replace a plugin that has sadly been abandoned. Not to mention that what I have isn't as flexible as it relies on mouse controls which are impractical for my Xbox port. All I need now is for someone to help me with the payout logic and I should be good to go.

Also, does anyone have any ideas on how to modify this for Blackjack?
What modifications would you need help implementing?
 

BreakerZero

Regular
Regular
Joined
Jul 8, 2018
Messages
1,208
Reaction score
524
First Language
English (USA)
Primarily Uses
RMMV
What modifications would you need help implementing?
Drawing the first two cards, then drawing the next card if you choose to until you hit 21 or go over (aka hand bust). I would also need a mechanism for saving two individual cards if you hand split. And an automatic stop to the game if you draw a perfect hand at the start.

As for the poker draw, how do you suggest I run the calculations?
 

Trihan

Speedy Scripter
Regular
Joined
Apr 12, 2012
Messages
6,543
Reaction score
7,083
First Language
English
Primarily Uses
RMMZ
Drawing the first two cards, then drawing the next card if you choose to until you hit 21 or go over (aka hand bust). I would also need a mechanism for saving two individual cards if you hand split. And an automatic stop to the game if you draw a perfect hand at the start.

As for the poker draw, how do you suggest I run the calculations?
I can only speak for myself, but honestly I would approach this from the opposite end: rather than having an array to track which cards are "out" of the deck, I'd simply have an array for the deck itself, and shuffle it by randomising the elements. Then to draw, I'd just pop off the first value. So drawing 2 cards would be as simple as popping 2 values. I think this ultimately works out cleaner, because it's impossible to confuse which cards are in the deck and which aren't: if it's not in the deck, it's been drawn.

As for the split thing, I'd just have two player hand arrays in that case.
 

exnem

Regular
Regular
Joined
Sep 13, 2015
Messages
65
Reaction score
8
First Language
english
Primarily Uses
I'm trying your tutorial, and after creating the events and testing, I get this error:

require(...).Window.get(...).isDevToolsOpen is not a function

Does anyone have any idea why that is?
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
5,027
Reaction score
4,360
First Language
EN
Primarily Uses
RMMZ
require(...).Window.get(...).isDevToolsOpen is not a function
I suspect you are also using a very old plugin that changes how errors are displayed: isDevToolsOpen hasn't worked in NWJS for years.

Try turning off all plugins, save your project to apply Plugin Manager changes, and test. If that helps, then make sure all your plugins are up-to-date.

Once that is fixed, I imagine you will get a more relevant error, probably a typo in one of your Script commands.
 

exnem

Regular
Regular
Joined
Sep 13, 2015
Messages
65
Reaction score
8
First Language
english
Primarily Uses
I suspect you are also using a very old plugin that changes how errors are displayed: isDevToolsOpen hasn't worked in NWJS for years.

Try turning off all plugins, save your project to apply Plugin Manager changes, and test. If that helps, then make sure all your plugins are up-to-date.

Once that is fixed, I imagine you will get a more relevant error, probably a typo in one of your Script commands.
Thank you very much, I will try that :)
 

Latest Threads

Latest Profile Posts

I keep thinkin' that someday I'll be a real girl. I dunno, maybe today is the day.:kaopride:

alice_curved_citadel.png
Counting down to Wind Ryder release
milhouse-time.gif


Hello everyone, I inform you that you can now freely try my new Plugin: Dynamic Switch for RPG MAKER MZ.

You can see the official post in the forum: https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-mz-plugin-dynamic-switches.161525/

I hope you like it and I'm looking forward to your comments and suggestions! :)
Right, finally responded to everyone who had an open commission query with me. If I've missed anyone, please let me know.
Okay, so it looks like I've bamboozled by that dastardly placebo effect again. Still taking the meds, which seemed to help at first, but yesterday evening my chest got this odd numbness, which didn't last long, but still. AND its still difficult to breathe. Guess I'll go spend the money I was saving for homebuying costs on another doctor visit :\

Forum statistics

Threads
134,852
Messages
1,251,192
Members
177,644
Latest member
Valya
Top