• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

A little gift: BlackJack Script

5
Posts
5
Years
  • Age 30
  • Seen Jan 26, 2023
EDIT:
2019/02/28
The script was corrected by the error reported by guyver.
2019/02/12
Thanks for helping me mgriffin! I do a trial with the changes you adviced and they seem all to work, except for the value assignment part (pbValueBJ), due by your suggest I make this

Spoiler:

In a Ruby Interpreter this code returns the right values, but in Pokémon Essentials it returns only 0.
-------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------
Hi!
I'm working on my project in Pokémon Essentials for at least one and half year.
In this time I've solved lots of problems and I learned about programming and about the use of RPG Maker.

Often I used tools, materials or scripts that community's people share, now for the first time I've written this script totally anew, and I would share with anyone would be interested.

One of the thing I would insert inmy project is a more featured casino, so, inspired by a similar feature in the Hack Rom "Pokémon Prism" I tried to write this text-based BlackJack Game.

At the moment there isn't any graphical issue, pure text.

I hope you enjoy this and I hope also to improve this work, to make others and finally publish my project.

NOTES:

- Copy the script in Printable Version to preserve the integrity of the script.

- The language of the script is English, name of variables and other things in this script could be in Italian (my mother language), so if you are confident with scripting or doubtful about the translation don't modify the script or it couldn't work.

- Other information are in comment lines above the script.

- For make properly display the card suits symbols the font need to had those! In Pokémon Essentials the only default font which has this set is DP-style one.

- Look at the attachment to see how to configure (how i did, you could do anything you want) an event that start the script.
Spoiler:
 

Attachments

  • Esempio.png
    Esempio.png
    32.8 KB · Views: 136
Last edited:
1,403
Posts
10
Years
  • Seen Apr 18, 2024
Very cool!


A few small comments:
Code:
  elsif (@index == "♥J" or @index == "♦J" or @index == "♣J" or @index == "♣J")
    return 8
  elsif (@index == "♥Q" or @index == "♦Q" or @index == "♣Q" or @index == "♣Q")
    return 9
I think this is saying that jack and queen are worth 8 and 9, but I think they're both supposed to be 10 (like king).

Code:
	@@cards.each do |numero|
	@@randomMazzo.push @@semi[0]+numero
	end

	@@cards.each do |numero|
	@@randomMazzo.push @@semi[1]+numero
	end

	@@cards.each do |numero|
	@@randomMazzo.push @@semi[2]+numero
	end

	@@cards.each do |numero|
	@@randomMazzo.push @@semi[3]+numero
	end
You could write this as two loops, one over the suits and one over the numbers, e.g.:
Code:
@@semi.each do |suit| # Sorry, don't know the Italian!
  @@cards.each do |numero|
    @@randomMazzo.push suit+numero
  end
end

I don't know if it exists in Essentials, but you could use sort_by! to simplify pbMischia:
Code:
def pbMischia
@@randomMazzo.sort_by! {rand}
end
Or better yet, just use shuffle!.

Finally in your code that converts cards to values you could remove the suit before the if/elses so that you don't have to check for "♥X" or "♦X" or "♣X" or "♣X". Something like this:
Code:
def pbValueBJ
  numero=@index[1..-1]
  if numero=="A"
    ...
  elsif numero=="2"
    ...
  ... # etc
end
 
24
Posts
15
Years
  • Seen Oct 23, 2022
All I get after plugging this script in is a syntax error in line 71. Do I need to put this somewhere specific? I've tried multiple locations in the script list.
 
5
Posts
5
Years
  • Age 30
  • Seen Jan 26, 2023
The line 71 is
"#scelta = gets.chomp" it is an error, it should be "@scelta = gets.chomp, with "@" in place of "#".

It is my fault, I'll correct the main script. Try and let my know! Thank you for the warning.
 
24
Posts
15
Years
  • Seen Oct 23, 2022
The line 71 is
"#scelta = gets.chomp" it is an error, it should be "@scelta = gets.chomp, with "@" in place of "#".

It is my fault, I'll correct the main script. Try and let my know! Thank you for the warning.

Line 71 for me is "@turn=nil" so nothing has changed, I tried poking around with it but my ruby is rusty.
 
5
Posts
5
Years
  • Age 30
  • Seen Jan 26, 2023
I found an error in your line 70 (68 for me). There's a missed parenthesis at the end of the line. I corrected the script.

Due to the discrepancy between the number of my lines and yours, I suggest you (if you hadn't) to copy the code in print view mode. For doing this search in "Thread Tools" at the thread heading.


I hope to be useful! Let me know!
 
Last edited:
Back
Top