Sign in to follow this  
Followers 0
Baku

A little blackjackclone..

11 posts in this topic

#1 ·  Posted (edited)

I think this is a good idea to introduce newcommers with the random-function.

#include <GuiConstants.au3>
GUICreate("WhiteJoe", 245, 65, (@DesktopWidth - 245) / 2, (@DesktopHeight - 105) / 2, $WS_SYSMENU + $WS_MINIMIZEBOX + $WS_EX_STATICEDGE)

HotKeySet("{ESC}", "_exit")

Func _exit()
    Exit
EndFunc  ;==>_exit

$points = "0"

$Button_3 = GUICtrlCreateButton("Take", 10, 10, 110, 20)
$Button_4 = GUICtrlCreateButton("Stop", 130, 10, 100, 20)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_3
            get()
        Case $msg = $Button_4
            computer()
        Case Else
        ;;;
    EndSelect
WEnd
Exit


Func get()
    $add = Random(1, 11, 1)
    $points = $add + $points
    If $points > 21 Then
        $msgbox = MsgBox(4 + 32, "You loose!", $points & " Points. - " & "You loose!" & @LF & "New game?")
        Select
            Case $msgbox = 7
                Exit
            Case Else
                $points = "0"
        EndSelect
        $points = "0"
    ElseIf $points = 1 Then
        MsgBox(64, "Points", "1 Point")
    Else
        MsgBox(64, "Points", $points & " points")
    EndIf
    Return $points
EndFunc  ;==>get

Func computer()
    $compoints = Random(14, 24, 1)
    
    If $compoints > $points And $compoints < 22 Then
        $msgbox = MsgBox(4 + 32, "Computer wins!", "Computer wins with " & $compoints & " points. (You have " & $points & " points)" & @LF & "New game?")
        Select
            Case $msgbox = 7
                Exit
            Case Else
                $punkte = "0"
        EndSelect
    ElseIf $compoints = $points Then
        $msglos = MsgBox(4 + 32, "Draw!", "Draw with " & $compoints & " points." & @LF & "New game?")
        Select
            Case $msglos = 7
                Exit
            Case Else
                $points = "0"
        EndSelect
    Else
        $msgwin = MsgBox(4 + 32, "You win!", "You win with " & $points & " points. (Computer has " & $compoints & " points)" & @LF & "New game?")
        Select
            Case $msgwin = 7
                Exit
            Case Else
                $points = "0"
        EndSelect
    EndIf
EndFunc  ;==>computer
Edited by Baku

Share this post


Link to post
Share on other sites



Small bug:

You win with 18 points. (Computer has 23 points.)

New game?

[Yes]

One more / Stop

[One more]

20 points

:)

Share this post


Link to post
Share on other sites

Whoops :) Thank you, fixed that, i forgot to reset the points :evil:

Share this post


Link to post
Share on other sites

Small bug:

You win with 21 points. (Computer has 18 points.)

New game?

[No]

One more / Stop

I think the script should be exiting at this point. :)

Share this post


Link to post
Share on other sites

I guess i figured it out now ;D

I'm gonna try add a static scoretable soon, if i find the command for updating labels ;D

Share this post


Link to post
Share on other sites

Good luck with that! :)

It will be great to see how far this gets. If you're interested in working on a GUI then look for cards.dll somewhere in your Windows folder tree -- it contains bitmaps of the cards and some nice backs too.

Share this post


Link to post
Share on other sites

I guess i figured it out now ;D

I'm gonna try add a static scoretable soon, if i find the command for updating labels ;D

<{POST_SNAPBACK}>

Is the code in you first post have all the fixes? Just wondering...

Cheers.. :)

Share this post


Link to post
Share on other sites

yup, the first post has no known bugs ;D

Share this post


Link to post
Share on other sites

yup, the first post has no known bugs ;D

<{POST_SNAPBACK}>

Thanks for the update..

Cheers.. :)

Share this post


Link to post
Share on other sites

You win with 17 points. (Computer has 15 points)

New game?

I think dealer is supposed to hit on anything under 17?

Share this post


Link to post
Share on other sites

I think dealer is supposed to hit on anything under 17?

<{POST_SNAPBACK}>

That is correct. :)

Cheers.. :evil:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0