(not quite ready for Game Announcements and Feedback)
If it's not too buggy, I'll add the betting functions to it.
I got a little crazy with dictionaries and functions, but this seems to be fairly functional.
I'm halfway done with VERSION 2, and I'm using objects for the hands this go-round. (I just wanted to see what all I could pull off with dictionaries.)
As far as all the functions go, there are just too many being called in some of the scripts sometimes, and sometimes things go haywire when my scripts get ahead of each other. (Version 2 is much better in this regard already. This was the first time I really got function happy, and I'm surprised it works at all!)
The library with all of the images for the cards is here:
Everything says the card images are in the public domain.
It's all been converted to base64.
Feel free to use it.
If you want to display, say... the 10 of clubs, you could do something like this:
nm = StringDictionaryItem(card_images.img_dict, "10C") pic = "data:image/png;base64,"+nm msg("<image src='"+pic+"' id='10C' alt='the ten of clubs' title='the ten of clubs' />")
That Base64 image shows up in the preview of the post, but not in the actual post. (That's not fair.)
There are many flaws in this rough draft. (It's the first draft that worked.)
There are also many redundancies (I'm sure), and I rarely called
FlipDowncard() at the right time.
I also just realized that it was silly of me to put the cards in the player's hand in the player's inventory, seeming how they're on the table and we're not allowed to pick them up. (Whoops. I said it wasn't even ready for Game Announcements and Feedback! (But the library with card images is pretty cool, right? ))
Looks good, can always improve code, of course, but good 1st working version. Unfortunately, I don't know many card games, so I was only able to loosely look at the coding itself, and in the brevity, it looks really good. Lots of complexity/system, that you were able to code and get it working! That's the most important thing, it works, getting all the code to work together correctly, hehe.
The thing that kicked my butt for the longest time:
ShowMenuthe player couldn't ignore set up after a deck shuffle (which was called automatically when the deck ran out of shuffled cards), asking the player to cut the cards.
It took me hours to figure out what was causing the game to freeze up.
I had the
ShowMenu set up before I set the
ClearScreen up, and I added quite a few functions at the same time I decided to add all the screen clearing.
Lessons learned (or re-learned):
Just some thoughts. I know you are just getting a working copy together and you may know these things already but I am a long time casino blackjack player and could not resist piping in. These are just suggestions to keep in mind at this point.
Again these are just reminders so you don't get to far into scripting and have to go back and rewrite. I have spent an easy million dollars over the years learning the game. I learned you always lose if you leave the casino down. Then, I spent several years living 5 minutes from a casino 6 years ago and earned enough to live on. Up until automatic shufflers came along. Plus they break up play by changing dealers, cards, or adding chips. Anything to cause a card to be pulled from the deck and put in the dead pile, changing the Shoe. Of course, this is using multiple decks, but it still changes things in a single deck game. Mainly my demeanor.
Love the game. This script will make a great "Magic, the gathering", D&D, card game. Or any other game for that matter.
I've only won a few hundred bucks a few different times, and I was just about to ask if anyone had any suggestions.
So a blackjack is only on
a soft handthe initial deal (or a split)... That's easy to fix.
I've got a double-down script written. I just haven't updated what I've got online yet.
(Plus, it's screwy. It doesn't show up sometimes. I'm whittling away at some functions right now, too.)
I've got it asking if you want to play again because I'm planning on dropping this into my Gambling Hall game, which has a craps game that's set up much like this one.
Initially, I was going to have it where you always had access to a slot machine, craps, blackjack, or poker, but I've got it set up so a table is a room right now (which would make it easier to keep up with the players if NPCs were thrown in).
Now the plan is to throw you back into the main room of the casino after each hand is over, and you can just throw another chip on the table, or enter DEAL or PLAY #whatever#, or just talk to whatever dealer to initiate another hand (or game, or what have you).
I've got the split set up, but I didn't know you couldn't hit after you split. That is very useful information!
You can only split four times. (I may have made that rule up. Is that a thing?)
I was thinking of adding a soft_seventeen attribute on the blackjack_game object, so that could be toggled, but the dealer stays at the moment.
I also need to add a script to allow the player to cut the cards after they're shuffled. (And can't a shuffle be requested?)
There's a string list that keeps track of wins. I plan to have a dealer switch every so often. It might not effect play, though. Simply cosmetic, so to speak.
I wanted to have at least two decks, but I'm scared to mess with that right now.
This is what version 2 looks like right now:
I do appreciate suggestions!
Keep 'em coming, if you've got 'em!
I am not 100% on the dealer's aces...
If it doesn't make him bust, it must be counted as 11, I think. (At least for the first two cards, right?)
Doesn't it work pretty much like the player's hand, except the dealer doesn't get to pick?
if (hand_value < 17) all_aces = 11 if (hand_value>21) reduce one ace to 1 if (hand_value>21) reduce the next ace to 1 ...
Having buttons for hit, stand, split or double down or any of player options like leave table (taking you to casino floor with other gaming options) would look nice.
something that you can do instead of having it ask every time if you want to continue or quit:
ask at the very beginning (thus only once) of a playing 'session' (choosing to play the blackjack game), for the players/users to enter how many games they want to play, and have scripting to handle it, of course. When the number of games entered, have been played, the 'session' ends. They can, then of course play again, being asked how many games they want to play, for this new 'session' of playing.