- 5
- Posts
- 6
- Years
- 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
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.
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:
Code:
def pbValueBJ
numero=@index[1..-1]
if numero == "A"
if @turn==0
if (@pp+11)>21
return 1
else
return 11
end
else
if (@dp+11)>21
return 1
else
return 11
end
end
elsif numero == "J" or numero == "Q" or numero == "K"
return 10
else
return numero.to_i
end
end
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:
Code:
#-------------------------------------------------------------------------------
#BlackJack by alex995
#-------------------------------------------------------------------------------
#INTRO
#-------------------------------------------------------------------------------
#I was influenced by a feature of the Hack Rom Pokémon Prism.
#There's not graphical issues (at least for the moment), it's a text game.
#This script is written totally anew. It provides a BlackJack-like game.
#Credits are appreciated.
#-------------------------------------------------------------------------------
#HOW TO MAKE IT WORK
#-------------------------------------------------------------------------------
#For making this script work simply put a script in an event with BlackJack.new
#Note that I have reserved the variable 111 for store the money the player bets.
#If that variable is used by your project change the number 111 in the script,
#with any number you want (up to 5000).
#If you don't want to bet money comment the lines with the variable @im.
#-------------------------------------------------------------------------------
#MAIN GAME PART
#-------------------------------------------------------------------------------
class BlackJack
def initialize
@@semi = ["♥","♦","♣","♣"]
@@cards = ["A","2","3","4","5","6","7","J","Q","K"]
@@randomMazzo = []
@draft = nil
@pp=0 #punteggio giocatore
@dp=0 #punteggio banco
@index=nil
@turn=nil
@im=pbGet(111) #variabile dove sono memorizzati i soldi puntati
@exit=0
pbMazzoACaso
pbBlackJack
end
def pbBlackJack #struttura del gioco
pbInitialDrawBJ #prima manche
while pbCheckBJ == true #ciclo che fa ripetere fino alle condizioni di vittoria/sconfitta
pbDrawBJ #turno "classico"
end
pbBettingBJ #attribuzione vittoria e posta relativa
$game_variables[111]= @im
end
def pbInitialDrawBJ
@turn=0
pbPesca
pd1= @draft #sorteggio carta uno giocatore
@index=pd1 #variabile per il confronto carta/punteggio
vpd1=pbValueBJ.to_i #attribuzione punteggio
pbPesca
pd2=@draft
@index=pd2
vpd2=pbValueBJ.to_i
@pp=vpd1+vpd2 #punteggio giocatore dopo il primo turno
@turn=1
pbPesca
dd1=@draft
@index=dd1
vdd1=pbValueBJ.to_i
pbPesca
dd2=@draft
@index=dd2
vdd2=pbValueBJ.to_i
@dp=vdd1+vdd2 #punteggio banco dopo il primo turno
Kernel.pbMessage(INTL_("Your cards: "+pd1.to_s+" e "+pd2.to_s+"."))
Kernel.pbMessage (INTL_("Dealer's cards: "+dd1.to_s+" e "+dd2.to_s+"."))
Kernel.pbMessage(INTL_("Points: "[email protected]_s+". Dealer: "[email protected]_s+"."))
@turn=nil
end
def pbDrawBJ
@scelta = gets.chomp
if Kernel.pbConfirmMessage((INTL_"Do you want draw another card?"))
@turn=0
pbPesca
pd=@draft
@index=pd
vpd=pbValueBJ.to_i
@pp+=vpd
if pbAIBJ
@turn = 1
pbPesca
dd=@draft
@index=dd
vdd=pbValueBJ.to_i
@dp+=vdd
Kernel.pbMessage(INTL_("Your draft: "+pd.to_s+"."))
Kernel.pbMessage(INTL_("Dealer's draft: "+dd.to_s+"."))
Kernel.pbMessage((INTL_("Points: "[email protected]_s+". Dealer: "[email protected]_s+"."))
@turn = nil
@exit=0
else
Kernel.pbMessage((INTL_"Your draft: "+pd.to_s+"."))
Kernel.pbMessage(INTL_"Points: "[email protected]_s+". Dealer: "[email protected]_s+"."))
@exit=1
end
else
if pbAIBJ
@turn=1
pbPesca
dd=@draft
@index=dd
vdd=pbValueBJ.to_i
@dp+=vdd
Kernel.pbMessage((INTL_("Dealer's draft: "+dd.to_s+"."))
Kernel.pbMessage(INTL_("Points: "[email protected]_s+". Dealer: "[email protected]_s+"."))
@turn=nil
@exit=1
else
Kernel.pbMessage(INTL_("Points: "[email protected]_s+". Dealer: "[email protected]_s+"."))
@turn=nil
@exit=1
end
end
pbCheckBJ
end
def pbAIBJ #AI del banco (gioca carta o sta) forse da migliorare
if @dp < 17
return true
else
return false
end
end
def pbCheckBJ #check per le condizioni di vittoria/sconfitta, forse anche qui da migliorare
if @pp > 21 or @dp > 21 or @exit != 0
return false
else
return true
end
end
def pbValueBJ
if (@index =="♥A" or @index =="♦A" or @index =="♣A" or @index =="♣A")
if @turn==0
if (@pp+11)>21
return 1
else
return 11
end
else
if (@dp+11)>21
return 1
else
return 11
end
end
elsif (@index == "♥2" or @index == "♦2" or @index == "♣2" or @index=="♣2")
return 2
elsif (@index == "♥3" or @index == "♦3" or @index == "♣3" or @index == "♣3")
return 3
elsif (@index == "♥4" or @index == "♦4" or @index == "♣4" or @index == "♣4")
return 4
elsif (@index == "♥5" or @index == "♦5" or @index == "♣5" or @index == "♣5")
return 5
elsif (@index == "♥6" or @index == "♦6" or @index == "♣6" or @index == "♣6")
return 6
elsif (@index == "♥7" or @index == "♦7" or @index == "♣7" or @index == "♣7")
return 7
elsif (@index == "♥J" or @index == "♦J" or @index == "♣J" or @index == "♣J")
return 10
elsif (@index == "♥Q" or @index == "♦Q" or @index == "♣Q" or @index == "♣Q")
return 10
elsif (@index == "♥K" or @index == "♦K" or @index == "♣K" or @index == "♣K")
return 10
end
end
def pbBettingBJ
if @pp > @dp
if @pp <= 21
@im+=@im
Kernel.pbMessage("You won!")
if @pp == 21
Kernel.pbMessage("BlackJack!")
end
elsif @pp>21 && @dp>21
Kernel.pbMessage("Draw!")
else
@im=0
Kernel.pbMessage("The dealer won!")
end
elsif @pp==@dp
Kernel.pbMessage("Draw!")
elsif @pp<@dp
if @dp <= 21
@im=0
Kernel.pbMessage("The dealer won!")
elsif @pp <=21 && @dp > 21
@im+=@im
Kernel.pbMessage("You won!")
elsif
Kernel.pbMessage("Draw!")
end
end
end
#-------------------------------------------------------------------------------
#DECK PART
#-------------------------------------------------------------------------------
@@semi = ["♥","♦","♣","♠"]
@@cards = ["A","2","3","4","5","6","7","J","Q","K"]
@@randomMazzo = []
@draft = nil
def pbMazzoACaso
@@semi.each do |suit|
@@cards.each do |numero|
@@randomMazzo.push suit+numero
end
end
pbMischia
end
def pbMischia
@@randomMazzo.shuffle!
end
def pbPesca
@draft = @@randomMazzo.last
@@randomMazzo.pop
contrario=@@randomMazzo.reverse
contrario.push @draft
@@randomMazzo = contrario.reverse
end
end
Attachments
Last edited: