|
-
Apr 26th, 2002, 05:26 PM
#1
Thread Starter
Fanatic Member
BlackJack (counting the score/points)
Hi,
I'm working on a BlackJack game but I can't figure out a good way to add the points on the cards. I have more then 100 lines of code for just the three first cards - there has to be a better way of doing this... The biggest problem is the aces... I want the label with the points to say "Points: 6 Or 16" if you have an ace and a five.
I have all the cards in an array, intDeck(51) and the points for all the cards in another, intPoints(51) so intDeck(0) is worth intPoints(0), intDeck(1) is worth intPoints(1) and so on. All the aces are set as 11 in the intPoints(51) array.
Any ideas how I can keep track of the scores?
Thanks in advance
Never argue with fools, they will only drag you down to their level, and beat you with experience.
Q: How do you tell an experienced hacker from a novice?
A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer
-
Apr 27th, 2002, 04:52 AM
#2
Hyperactive Member
You could use two variables P1score and p2score to keep a runnning tally. Whenever a new card comes just say p1score=p1score+intPoints(2) or whatever. Whenever an ace is drawn, ask the player if they want it worth 1 or 11. Or have a button that lets them change it between 1 and 11 and just set it's value to 1.
-Show me on the doll where the music touched you.
-
Apr 28th, 2002, 10:30 AM
#3
Thread Starter
Fanatic Member
Thanks for the reply
That's what I've been trying to do but it's really hard...
If I ask them when they get the card and they set it to 11 what if they need it to be 1 later? Or if I make it so they can change it all the time, what if they bust while the ace is 11 and could prevent that by changing it to 1, I would need some kind of system that checked if they had an ace somewhere set to 11 and the score is less or = to 31, and if I manage to write that code I wouldn't nedd the user to select weather they want the ace to be 1 or 11 as my program could figure it out by it self and we are back at square one...
Never argue with fools, they will only drag you down to their level, and beat you with experience.
Q: How do you tell an experienced hacker from a novice?
A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer
-
Apr 28th, 2002, 10:37 AM
#4
Not NoteMe
Cant you just detect whether making it work 11 would make the player bust, if so set it to 1, else set it to 11??
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Apr 28th, 2002, 03:57 PM
#5
Thread Starter
Fanatic Member
Yeah, if the user only could have one ace it would be easy, but what if the user has two or three or even four aces?
Never argue with fools, they will only drag you down to their level, and beat you with experience.
Q: How do you tell an experienced hacker from a novice?
A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer
-
Apr 29th, 2002, 09:13 AM
#6
Not NoteMe
When it's their turn (or you have to get the value of the aces), make them all = 11, then if they would be bust 1 by 1 make them worth only 1 point. If they are still over the limit, then the player has lost.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Apr 29th, 2002, 09:32 AM
#7
Thread Starter
Fanatic Member
That's a good idea, I'll try it as soon as I get home from school, thanks
It worked!!! Thank you so much!
Last edited by McCain; Apr 29th, 2002 at 07:17 PM.
Never argue with fools, they will only drag you down to their level, and beat you with experience.
Q: How do you tell an experienced hacker from a novice?
A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer
-
Apr 29th, 2002, 09:51 PM
#8
Thread Starter
Fanatic Member
I just realized that I don't know all the rules of blackjack... 
When do the dealer get his cards? Before the player get his? After the player is done? Every second one?
I've looked everywhere but it never says anything about the dealer, only what you are supposed to do and what your rules are...
Solved it, I played the java BJ over at http://www.blackjackinfo.com and saw that the dealer gets his cards after the player is finnished with his hand
Last edited by McCain; Apr 30th, 2002 at 09:55 PM.
Never argue with fools, they will only drag you down to their level, and beat you with experience.
Q: How do you tell an experienced hacker from a novice?
A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer
-
May 1st, 2002, 02:26 AM
#9
Hyperactive Member
Don't forget that if there's a tie, the dealer always wins!
-Show me on the doll where the music touched you.
-
May 1st, 2002, 07:48 PM
#10
Thread Starter
Fanatic Member
No he doesn't... If it's a tie or a "push" as it's called in BJ you get your bet back - you don't win anything you dont lose anything...
Never argue with fools, they will only drag you down to their level, and beat you with experience.
Q: How do you tell an experienced hacker from a novice?
A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer
-
May 2nd, 2002, 09:54 PM
#11
Thread Starter
Fanatic Member
For some reason my BJ program thinks the score is two points less then it actuallly is, and sometimes it keeps taking more/new cards even though the total score is more then 17. Any ideas why this happens anyone?
Here's the score keeping code:
VB Code:
Private Sub CalcCpoints()
If intCcards = 2 Then
intCpoints = intValues(1) + intValues(3) 'The dealer`s score is the value of the first card (1) and the second card (3)
If intCpoints = 21 Then lblCpoints.Caption = "BlackJack!!!"
If intCpoints = 22 Then intCpoints = 12 'If the dealer gets two aces the score is 12 (or 2...)
If intCpoints <> 21 Then lblCpoints.Caption = "Points: " & intCpoints
ElseIf intCcards = 3 Then
intCpoints = intValues(1) + intValues(3) 'the first two cards...
intCpoints = intCpoints + intValues(intCcards + 2) '... plus the third card
If intCpoints > 21 And intValues(intCcards + 2) = 11 Then 'If the score is higher then 21 and the third card is an ace...
intValues(intCcards + 2) = 1 '...the ace has to be counted as 1 point
Call CalcCpoints 're-calculate the points
End If
If intCpoints > 21 And intValues(3) = 11 Then
intValues(3) = 1
Call CalcCpoints
End If
If intCpoints > 21 And intValues(1) = 11 Then
intValues(1) = 1
Call CalcCpoints
End If
If intCpoints <= 21 Then
lblCpoints.Caption = "Points: " & intCpoints
ElseIf intCpoints > 21 Then
lblCpoints.ForeColor = vbRed
lblCpoints.Caption = "Busted! " & intCpoints & " points"
End If
ElseIf intCcards = 4 Then
intCpoints = intValues(1) + intValues(3)
intCpoints = intCpoints + intValues(intCcards + 2)
intCpoints = intCpoints + intValues(intCcards + 3)
If intCpoints > 21 And intValues(intCcards + 3) = 11 Then
intValues(intCcards + 3) = 1
Call CalcCpoints
End If
If intCpoints > 21 And intValues(intCcards + 2) = 11 Then
intValues(intCcards + 2) = 1
Call CalcCpoints
End If
If intCpoints > 21 And intValues(3) = 11 Then
intValues(3) = 1
Call CalcCpoints
End If
If intCpoints > 21 And intValues(1) = 11 Then
intValues(1) = 1
Call CalcCpoints
End If
If intCpoints <= 21 Then
lblCpoints.Caption = "Points: " & intCpoints
ElseIf intCpoints > 21 Then
lblCpoints.ForeColor = vbRed
lblCpoints.Caption = "Busted! " & intCpoints & " points"
End If
ElseIf intCcards = 5 Then
intCpoints = intValues(1) + intValues(3)
intCpoints = intCpoints + intValues(intCcards + 2)
intCpoints = intCpoints + intValues(intCcards + 3)
intCpoints = intCpoints + intValues(intCcards + 4)
If intCpoints > 21 And intValues(intCcards + 4) = 11 Then
intValues(intCcards + 4) = 1
Call CalcCpoints
End If
If intCpoints > 21 And intValues(intCcards + 3) = 11 Then
intValues(intCcards + 3) = 1
Call CalcCpoints
End If
If intCpoints > 21 And intValues(intCcards + 2) = 11 Then
intValues(intCcards + 2) = 1
Call CalcCpoints
End If
If intCpoints > 21 And intValues(3) = 11 Then
intValues(3) = 1
Call CalcCpoints
End If
If intCpoints > 21 And intValues(1) = 11 Then
intValues(1) = 1
Call CalcCpoints
End If
If intCpoints <= 21 Then
lblCpoints.Caption = "Points: " & intCpoints
ElseIf intCpoints > 21 Then
lblCpoints.ForeColor = vbRed
lblCpoints.Caption = "Busted! " & intCpoints & " points"
End If
End If
End Sub
Never argue with fools, they will only drag you down to their level, and beat you with experience.
Q: How do you tell an experienced hacker from a novice?
A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|