Staff Pick: BlackJackDealer
By
RevdutchieCreated: 2016/09/25 05:38:13 UTC-07:00 (8 years and 89 days ago)
Edited: 2016/09/28 10:36:51 UTC-07:00 (8 years and 86 days ago)
Likes: 1
Staff pick as of: 2016/09/25 05:40:16 UTC-07:00 (8 years and 89 days ago)
Denizen Version: 1.0.0
Script Version: 1.0.2
Description:
A blackjack game with a nice GUI easy to navigate.
version 1.0.2
Added tracker
Added payout multiplier flags for easier configuration payout amount.
Fixed some flags
version 1.0.1
Some minor fixes
version 1.0
Fixed payout errors
Optimized code
Made used colors more consistent
Tested for hours could not find any bugs, so I think iy's save to call it version 1.0 now.
Download script |
View raw script###############################################################################################
# #
# BlackJackDealer GUI Script by: Revdutchie # !! This script requires Vault !! #
# #
# Credits to: BlackCoyote for his original blackjack text script #
# You can find it here http://one.denizenscript.com/denizen/repo/entry/4 #
# If you want to have a great text chat based blackjack script #
# #
# The Denizen IRC community who is always there to help #
# I can name many but mcmonkey and BlackCoyote helped me a lot. #
# #
###############################################################################################
# #
# /npc assign --set BlackJackDealer_assignment #
# #
###############################################################################################
BlackJackDealer_assignment:
type: assignment
debug: false
actions:
on assignment:
- trigger name:click state:true
on click: #### Set payout multiplier options here ####
- ^flag player TieHandPayout:1.0
- ^flag player HighHandPayout:2.0
- ^flag player 21HandPayout:2.1
- ^flag player BlackJackPayout:2.5
- if <player.flag[BlackJackStatus]||null> == "InAction" {
- inventory open d:in@Player_Action_Inventory
} else {
- run BlackJack_ResetFlags
- narrate "<&2>Hi <&e><player.name> <&2>Let's play some <&6>BlackJack!"
- WAIT 1s
- narrate "<&2>First you have to place a <&6>bet."
- wait 1s
- inventory open d:in@Set_Bet_Inventory
}
BlackJackDealer_version:
type: version
name: BlackJackDealer
id: 113
description: NPC blackjack dealer with GUI.
version: 1.0.2
BlackJackTracker:
type: world
debug: false
events:
on system time hourly:
- webget "http://stats.denizenscript.com/tracker?script=113&version=1.0.2"
################################## Set Bet Inventory ##########################################
Set_Bet_Inventory:
type: inventory
title: "<&4><&chr[2665]> <&0><&chr[2663]> <&4><&chr[2666]> <&0><&chr[2660]> <&9>Place your bet <&4><&chr[2665]> <&0><&chr[2663]> <&4><&chr[2666]> <&0><&chr[2660]>"
size: 27
slots:
- "[] [] [] [] [] [] [] [] []"
- "[] [i@Bet10] [i@Bet25] [i@Bet50] [i@Bet75] [i@Bet100] [i@Bet150] [i@Bet200] []"
- "[] [] [] [] [] [] [] [] []"
Bet10:
type: item
material: "16"
display name: "<&6>Bet <&a>$<&2>10"
Bet25:
type: item
material: "15"
display name: "<&6>Bet <&a>$<&2>25"
Bet50:
type: item
material: "21"
display name: "<&6>Bet <&a>$<&2>50"
Bet75:
type: item
material: "73"
display name: "<&6>Bet <&a>$<&2>75"
Bet100:
type: item
material: "14"
display name: "<&6>Bet <&a>$<&2>100"
Bet150:
type: item
material: "129"
display name: "<&6>Bet <&a>$<&2>150"
Bet200:
type: item
material: "56"
display name: "<&6>Bet <&a>$<&2>200"
Set_Bet_Inventory_Handler:
type: world
events:
on player clicks in Set_Bet_Inventory:
- determine cancelled
on player drags in Set_Bet_Inventory:
- determine cancelled
############################################
on player clicks Bet10 in Set_Bet_Inventory:
- flag <player> Betvalue:10
- flag <player> BetStartvalue:10
- run Set_Bet_Handler
on player clicks Bet25 in Set_Bet_Inventory:
- flag <player> Betvalue:25
- flag <player> BetStartvalue:25
- run Set_Bet_Handler
on player clicks Bet50 in Set_Bet_Inventory:
- flag <player> Betvalue:50
- flag <player> BetStartvalue:50
- run Set_Bet_Handler
on player clicks Bet75 in Set_Bet_Inventory:
- flag <player> Betvalue:75
- flag <player> BetStartvalue:75
- run Set_Bet_Handler
on player clicks Bet100 in Set_Bet_Inventory:
- flag <player> Betvalue:100
- flag <player> BetStartvalue:100
- run Set_Bet_Handler
on player clicks Bet150 in Set_Bet_Inventory:
- flag <player> Betvalue:150
- flag <player> BetStartvalue:150
- run Set_Bet_Handler
on player clicks Bet200 in Set_Bet_Inventory:
- flag <player> Betvalue:200
- flag <player> BetStartvalue:200
- run Set_Bet_Handler
################################## Action Inventory ###########################################
Player_Action_Inventory:
type: inventory
title: "<&4><&chr[2665]> <&0><&chr[2663]> <&4><&chr[2666]> <&0><&chr[2660]> <&9>Hit / Stay / Double <&4><&chr[2665]> <&0><&chr[2663]> <&4><&chr[2666]> <&0><&chr[2660]>"
size: 27
slots:
- "[] [] [] [] [] [] [] [] []"
- "[] [] [i@BlackJackHit] [] [i@BlackJackStay] [] [i@BlackJackDouble] [] []"
- "[] [] [] [] [] [] [] [] []"
BlackJackHit:
type: item
material: "129"
display name: "<green>Hit <&b>|<&a>$<&6><player.money.as_int||0><&b>|"
lore:
- "<&b>Click here for a card"
- ""
- "<&e>Your <&2>hand has <&e><player.flag[playerhandvalue].as_int||0><&2> points"
- "<&e>Your <&2>current bet <&a>$<&6><player.flag[Betvalue]||0>"
- ""
- "<&5>Dealer <&2>hand <&e><player.flag[computerhandvalue].as_int||0>"
- ""
BlackJackStay:
type: item
material: "73"
display name: "<red>Stay <&b>|<&a>$<&6><player.money.as_int||0><&b>|"
lore:
- "<&b>Click here to stand."
- ""
- "<&e>Your <&2>hand has <&e><player.flag[playerhandvalue].as_int||0><&2> points"
- "<&e>Your <&2>current bet <&a>$<&6><player.flag[Betvalue]>"
- ""
- "<&5>Dealer <&2>hand <&e><player.flag[computerhandvalue].as_int||0>"
- ""
BlackJackDouble:
type: item
material: "14"
display name: "<&6>Double Down <&b>|<&a>$<&6><player.money.as_int||0><&b>|"
lore:
- "<&2>Doubles your bet but you get <&b>1<&2> card only"
- ""
- "<&e>Your <&2>hand has <&e><player.flag[playerhandvalue].as_int||0><&2> points"
- "<&e>Your <&2>current bet <&a>$<&6><player.flag[Betvalue]||0>"
- ""
- "<&5>Dealer <&2>hand <&e><player.flag[computerhandvalue].as_int||0>"
- ""
Player_Action_Inventory_Handler:
type: world
events:
on player clicks in Player_Action_Inventory:
- determine cancelled
on player drags in Player_Action_Inventory:
- determine cancelled
################################################
on player clicks BlackJackHit in Player_Action_Inventory:
- ^inventory close
- ^wait 1s
- ^run BlackJack_givecard def:player instantly
- ^run BlackJackPlayerHandCheck
- narrate "<&e>You <&2>now have <&e><player.flag[playerhandvalue].as_int||0> points"
on player clicks BlackJackStay in Player_Action_Inventory:
- ^inventory close
- narrate "<&e>You <&2> deceided to <&6>stay, <&2>good luck."
- ^narrate "<&5>Dealer <&2> will finish his hand"
- ^wait 1s
- run BlackJackDealerHandCheck
on player clicks BlackJackDouble in Player_Action_Inventory:
- inventory close
- if <player.money> >= <player.flag[Betvalue]||0> {
- money take quantity:<player.flag[Betvalue]||0>
- flag player betvalue:<player.flag[betvalue].mul[2]>
- playsound <player> sound:BLOCK_ANVIL_USE pitch:2
- narrate "<&e>You <&2>doubled your bet to <&a>$<&6><player.flag[Betvalue]||0>"
- wait 1s
- run BlackJack_givecard def:player instantly
- flag <player> BlackJackStatus:!
- narrate "<&e>You <&2>now have <&e><player.flag[playerhandvalue].as_int||0> points"
- if <player.flag[playerhandvalue].as_int||0> > 21 {
- narrate "<&e>You <&4>Are BUSTED with <&6><player.flag[playerhandvalue].as_int||0> points!"
- ^playsound <player> sound:ENTITY_DONKEY_ANGRY pitch:1
- wait 2s
- run BlackJack_ResetFlags
- inventory open d:in@BlackJack_End_Game_Inventory
} else {
- narrate "<&e>You <&2> have to <&6>stay <&2>now, good luck."
- narrate "<&5>Dealer <&2> will finish his hand"
- wait 1s
- run BlackJackDealerHandCheck
}
} else {
- narrate "<&e>You <&4>do not have enough money!"
- wait 1s
- inventory open d:in@Player_Action_Inventory
}
################################## End Game Inventory ###########################################
BlackJack_End_Game_Inventory:
type: inventory
title: "<&4><&chr[2665]> <&0><&chr[2663]> <&4><&chr[2666]> <&0><&chr[2660]> <&9>Play a new game? <&4><&chr[2665]> <&0><&chr[2663]> <&4><&chr[2666]> <&0><&chr[2660]>"
size: 27
slots:
- "[] [] [] [] [] [] [] [] []"
- "[] [] [i@NewGameNewBet] [] [i@NewGameYes] [] [i@NewGameNO] [] []"
- "[] [] [] [] [] [] [] [] []"
NewGameNewBet:
type: item
material: "22"
display name: "<green>New Game Yes"
lore:
- "Set an other bet value"
NewGameYes:
type: item
material: "133"
display name: "<green>New Game Yes"
lore:
- "Start game with same bet value"
NewGameNo:
type: item
material: "152"
display name: "<green>New Game No"
lore:
- "No thanks, I am done"
Player_End_Game_Inventory_Handler:
type: world
events:
on player clicks in BlackJack_End_Game_Inventory:
- determine cancelled
on player drags in BlackJack_End_Game_Inventory:
- determine cancelled
################################################
on player clicks NewGameNewBet in BlackJack_End_Game_Inventory:
- run BlackJack_ResetFlags
- inventory open d:in@Set_Bet_Inventory
on player clicks NewGameYes in BlackJack_End_Game_Inventory:
- run BlackJack_ResetFlags
- flag player betvalue:<player.flag[BetStartvalue]||0>
- run Set_Bet_Handler
on player clicks NewGameNo in BlackJack_End_Game_Inventory:
- run BlackJack_ResetFlags
- inventory close
- Narrate "<&2>Goodbye, <&e><player.name> <&2>hope to see you back soon!"
########################## Handlers and checks #################################
Set_Bet_Handler:
type: task
script:
- if <player.money> >= <player.flag[Betvalue]||0> {
- ^money take quantity:<player.flag[Betvalue]||0>
- ^playsound <player> sound:BLOCK_ANVIL_USE pitch:2
- ^run BlackJack_ResetFlags
- ^flag player BlackJackStatus:InAction
- ^inventory close
- narrate "<&5>-----------------------------------------------------"
- run BlackJack_startdealing
} else {
- ^inventory close
- narrate "<&e>You <&4>do not have enough money!"
}
BlackJackPlayerHandCheck:
type: task
script:
- if <player.flag[playerhandvalue].as_int||0> > 21 {
- ^narrate "<&e>You <&4>Are BUSTED with <&e><player.flag[playerhandvalue].as_int||0> <&2>points!"
- playsound <player> sound:ENTITY_DONKEY_ANGRY pitch:1
- ^narrate "<&e>Your <&2>wallet is now <&a>$<&6><player.money.as_int||0>"
- ^run BlackJack_ResetFlags
- ^wait 2s
- inventory open d:in@BlackJack_End_Game_Inventory
} else if <player.flag[playerhandvalue].as_int||0> == 21 {
- narrate "<&e>You <&2>have <&e>21 <&2>points, good luck!"
- wait 1s
- run BlackJackDealerHandCheck
} else {
- inventory open d:in@Player_Action_Inventory
}
BlackJackDealerHandCheck:
type: task
script:
- if <player.flag[computerhandvalue].as_int||0> < 17 {
- ^run BlackJack_givecard def:computer instantly
- ^narrate "<&2>Dealer now has <&e><player.flag[computerhandvalue].as_int||0> points"
- ^wait 1s
- run BlackJackDealerHandCheck
} else if <player.flag[computerhandvalue].as_int||0> > 21 {
- ^narrate "<&4>Dealer Busted with <&e><player.flag[computerhandvalue].as_int||0> points"
- run BlackJackHighestHand
} else {
- run BlackJackEndResultCheck
}
BlackJackEndResultCheck:
type: task
script:
- if <player.flag[computerhandvalue].as_int||0> > <player.flag[playerhandvalue].as_int||0> {
- run BlackJack_ResetFlags
- ^narrate "<&5>Dealer <&6>Won! <&2>Better luck next time."
- ^playsound <player> sound:ENTITY_DONKEY_ANGRY pitch:1
- ^wait 2s
- inventory open d:in@BlackJack_End_Game_Inventory
} else if <player.flag[computerhandvalue].as_int||0> == <player.flag[playerhandvalue].as_int||0> {
- ^run BlackJack_ResetFlags
- narrate "<&2>It's a <&6>Tie! <&2>Your bet is returned"
- narrate "<&e>You <&2>recieve <&a>$<&6><player.flag[betvalue].mul[<player.flag[TieHandPayout]>]>"
- ^give money quantity:<player.flag[betvalue].mul[<player.flag[TieHandPayout]>]>
- ^narrate "<&e>Your <&2>wallet is now <&a>$<&6><player.money.as_int||0>"
- ^wait 2s
- inventory open d:in@BlackJack_End_Game_Inventory
} else if <player.flag[computerhandvalue].as_int||0> < <player.flag[playerhandvalue].as_int||0> {
- run BlackJackHighestHand
}
BlackJackHighestHand:
type: task
script:
- if <player.flag[playerhandvalue].as_int||0> == 21 {
- ^run BlackJack_ResetFlags
- narrate "<&e>You <&6>won <&2>this hand with <&e>21 <&2>points."
- ^narrate "<&e>You <&2>recieve <&a>$<&6><player.flag[betvalue].as_int.mul[<player.flag[21HandPayout]>]>"
- ^give money quantity:<player.flag[betvalue].mul[<player.flag[21HandPayout]>]>
- ^playsound <player> sound:ENTITY_PLAYER_LEVELUP pitch:0.8
- ^narrate "<&e>Your <&2>wallet is now <&a>$<&6><player.money.as_int||0>"
- ^wait 2s
- inventory open d:in@BlackJack_End_Game_Inventory
} else {
- ^run BlackJack_ResetFlags
- ^narrate "<&e>You <&6>won! <&2>You recieve <&a>$<&6><player.flag[betvalue].as_int.mul[<player.flag[HighHandPayout]>]>."
- ^give money quantity:<player.flag[betvalue].mul[<player.flag[HighHandPayout]>]>
- ^playsound <player> sound:ENTITY_PLAYER_LEVELUP pitch:0.8
- ^narrate "<&e>Your <&2>wallet is now <&a>$<&6><player.money.as_int||0>"
- ^wait 2s
- inventory open d:in@BlackJack_End_Game_Inventory
}
BlackJackPayout:
type: task
script:
- run BlackJack_ResetFlags
- narrate "<&e>You <&2>have <&6>BLACKJACK! <&2>"
- ^narrate "<&e>You <&2>instantly win <&a>$<&6><player.flag[betvalue].as_int.mul[<player.flag[BlackJackPayout]>]>"
- ^give money <player.flag[betvalue].mul[<player.flag[BlackJackPayout]>]>
- ^playsound <player> sound:ENTITY_PLAYER_LEVELUP pitch:0.8
- wait 1s
- ^playsound <player> sound:ENTITY_PLAYER_LEVELUP pitch:0.8
- ^narrate "<&e>Your <&2>wallet is now <&a>$<&6><player.money.as_int||0>"
- ^wait 2s
- inventory open d:in@BlackJack_End_Game_Inventory
#################################################################################
######################### BlackJack Mechanics Below #############################
#################################################################################
BlackJack_startdealing:
type: task
debug: false
script:
- narrate "<&e>Your <&2>bet is <&a>$<&6><player.flag[betvalue]||0>"
- narrate "<&e>Your <&2>wallet is now <&a>$<&6><player.money.as_int||0>"
- wait 1s
- run BlackJack_givecard def:player instantly
- wait 1s
- run BlackJack_givecard def:computer instantly
- wait 1s
- run BlackJack_givecard def:player instantly
- wait 1s
- narrate "<&5>Dealer <&2>recieved <&a>undisclosed <&2>card"
- playsound <player> sound:ENTITY_BAT_TAKEOFF pitch:1.5
- wait 1s
- if <player.flag[playerhandvalue].as_int||0> == 21 {
- run BlackJackPayout
} else {
- narrate "<&e>Your <&2>hand has <&e><player.flag[playerhandvalue].as_int||0> points"
- wait 1s
- inventory open d:in@Player_Action_Inventory
}
BlackJack_givecard:
type: task
debug: false
speed: 1
script:
- define card <player.flag[cardpack].random[1].as_list.get[1]>
- flag <player> cardpack:<-:%card%
- flag <player> %1%hand:->:%card%
- flag <player> %1%handvalue:+:<proc[BlackJack_cardvalueprocedure].context[%card%|%1%]>
- playsound <player> sound:ENTITY_BAT_TAKEOFF pitch:1.5
- if %1% == player narrate "<&e>You <&2>recieved <proc[BlackJack_cardnameprocedure].context[%card%]>"
- if %1% == computer narrate "<&5>Dealer <&2>recieved <proc[BlackJack_cardnameprocedure].context[%card%]>"
BlackJack_cardvalueprocedure:
type: procedure
definitions: card|type
debug: false
speed: 1
script:
- if <el@val[%card%].starts_with[a]> {
- define value <el@val[%card%].after[a]>
- if %value% > 10 define value 10
- if %value% == 1 {
- if <player.flag[%type%handvalue]||0> < 11 define value 11
}
}
- if <el@val[%card%].starts_with[b]> {
- define value <el@val[%card%].after[b]>
- if %value% > 10 define value 10
- if %value% == 1 {
- if <player.flag[%type%handvalue]||0> < 11 define value 11
}
}
- if <el@val[%card%].starts_with[c]> {
- define value <el@val[%card%].after[c]>
- if %value% > 10 define value 10
- if %value% == 1 {
- if <player.flag[%type%handvalue]||0> < 11 define value 11
}
}
- if <el@val[%card%].starts_with[d]> {
- define value <el@val[%card%].after[d]>
- if %value% > 10 define value 10
- if %value% == 1 {
- if <player.flag[%type%handvalue]||0> < 11 define value 11
}
}
- determine %value%
BlackJack_cardnameprocedure:
type: procedure
definitions: card
debug: false
speed: 1
script:
- if <el@val[%card%].starts_with[a]> {
- define type <&4><&chr[2665]><&a>
- define value <el@val[%card%].after[a]>
- if %value% == 1 define value Ace
- if %value% == 13 define value King
- if %value% == 12 define value Queen
- if %value% == 11 define value Jack
}
- if <el@val[%card%].starts_with[b]> {
- define type <&4><&chr[2666]><&a>
- define value <el@val[%card%].after[b]>
- if %value% == 1 define value Ace
- if %value% == 13 define value King
- if %value% == 12 define value Queen
- if %value% == 11 define value Jack
}
- if <el@val[%card%].starts_with[c]> {
- define type <&7><&chr[2663]><&a>
- define value <el@val[%card%].after[c]>
- if %value% == 1 define value Ace
- if %value% == 13 define value King
- if %value% == 12 define value Queen
- if %value% == 11 define value Jack
}
- if <el@val[%card%].starts_with[d]> {
- define type <&7><&chr[2660]><&a>
- define value <el@val[%card%].after[d]>
- if %value% == 1 define value Ace
- if %value% == 13 define value King
- if %value% == 12 define value Queen
- if %value% == 11 define value Jack
}
- determine '<el@val[%type%]||no><&a> <el@val[%value%]||cards>'
BlackJack_ResetFlags:
type: task
debug: false
script:
- flag <player> BlackJackStatus:!
- flag <player> computerstay:!
- flag <player> playerhandvalue:!
- flag <player> computerhandvalue:!
- flag <player> playerhand:!
- flag <player> computerhand:!
- flag <player> cardpack:!
- flag <player> cardpack:|:a1|a2|a3|a4|a5|a6|a7|a8|a9|a10|a12|a13|b1|b2|b3|b4|b5|b6|b7|b8|b9|b10|b12|b13|c1|c2|c3|c4|c5|c6|c7|c8|c9|c10|c12|c13|d1|d2|d3|d4|d5|d6|d7|d8|d9|d10|d12|d13|
View History