Ok, here is my hack
- source only, files assumed in subdirectory BlackJack
- Game messages in game (no msgboxes)
- (Hot)key support
- splash suppressed
- game over and blackjack animations suppressed
Hotkeys:
Double Down: D or Alt-D
Surrender: U or Alt-U
Split: P or Alt-P
Hit: H or Alt-H
Stand: S or Alt-S
Deal: Enter or Space
Code:
#SingleInstance Force
#Persistent
#NoEnv
SetBatchLines, -1
Total_Amount = 100
SoundPlay = On
BlackJack_Dir = %A_ScriptDir%\BlackJack ; C:\Documents and Settings\%A_UserName%\BlackJack
IfExist, %BlackJack_Dir%
{
SetWorkingDir, %BlackJack_Dir%
Gosub, TrayMenu
Loop, %BlackJack_Dir%\*.*
File_Cnt = %A_Index%
If File_Cnt < 71
Msgbox Error ; <---
/*
Else
{
SplashImage, BlackJack_Logo.bmp, B
Sleep, 3000
SplashImage, Off
Progress, Off
}
*/
}
Else ; <---
Msgbox Error
Hotkey, IfWinActive, BlackJack ahk_class AutoHotkeyGUI
Hotkey, h, ButtonHit
Hotkey, s, ButtonStand
Hotkey, p, ButtonSplit
Hotkey, d, ButtonDoubleDown
Hotkey, u, ButtonSurrender
Hotkey, Enter, ButtonDeal
Hotkey, Space, ButtonDeal
New_Game:
Sleep, 1000
Gui, Destroy
Gui, Margin, 0, 0
SetTimer, Flasher, Off
Gui +LastFound
hWnd := WinExist()
hSysMenu:=DllCall("GetSystemMenu","Int",hWnd,"Int",FALSE)
nCnt:=DllCall("GetMenuItemCount","Int",hSysMenu)
DllCall("RemoveMenu","Int",hSysMenu,"UInt",nCnt-6,"Uint","0x400")
DllCall("DrawMenuBar","Int",hWnd)
Cnt = 0
Bet = Off
Stand = Off
Split = Off
Card_List =
DoubleDown =
Split_Hand =
Dealer_Hand =
Player_Hand =
Split_Hand_1 =
Split_Hand_2 =
Progress = Off
Insurance = Off
Player_Ace_Cnt = 0
Dealer_Ace_Cnt = 0
Player_Hit_Cnt = 3
Dealer_Hit_Cnt = 3
Double_Down_Cnt = 4
Double_Bet_Amount = 0
Split_Hand_1_Hit_Cnt = 3
Split_Hand_2_Hit_Cnt = 3
DoubleDown_Split_Hand_1 = No
DoubleDown_Split_Hand_2 = No
Loop, 5
{
Dealer_Card_%A_Index%_Value = 0
Player_Card_%A_Index%_Value = 0
Split_Hand_1_Card_%A_Index%_Value = 0
Split_Hand_2_Card_%A_Index%_Value = 0
}
Gui, Add, Picture, , BlackJack_Table.bmp
Gui, Add, Picture, gInsurance vInsurance x311 y226, Insurance.bmp
Gui, Add, Picture, vInsurance_Chip x505 y220
Gui, Add, Picture, vChip_Stack_1 x110 y233
Gui, Add, Picture, vChip_Stack_2 x637 y233
Gui, Add, Picture, vDealer_Card_1 x330 y110
Gui, Add, Picture, vDealer_Card_2 x350 y110
Gui, Add, Picture, vDealer_Card_3 x370 y110
Gui, Add, Picture, vDealer_Card_4 x390 y110
Gui, Add, Picture, vDealer_Card_5 x410 y110
Gui, Add, Picture, vPlayer_Card_1 x199 y307
Gui, Add, Picture, vPlayer_Card_2 x286 y307
Gui, Add, Picture, vPlayer_Card_3 x373 y307
Gui, Add, Picture, vPlayer_Card_4 x460 y307
Gui, Add, Picture, vPlayer_Card_5 x547 y307
Gui, Add, Picture, vSplit_Hand_1_Card_1 x289 y280
Gui, Add, Picture, vSplit_Hand_1_Card_2 x289 y310
Gui, Add, Picture, vSplit_Hand_1_Card_3 x289 y340
Gui, Add, Picture, vSplit_Hand_1_Card_4 x289 y370
Gui, Add, Picture, vSplit_Hand_1_Card_5 x289 y400
Gui, Add, Picture, vSplit_Hand_2_Card_1 x458 y280
Gui, Add, Picture, vSplit_Hand_2_Card_2 x458 y310
Gui, Add, Picture, vSplit_Hand_2_Card_3 x458 y340
Gui, Add, Picture, vSplit_Hand_2_Card_4 x458 y370
Gui, Add, Picture, vSplit_Hand_2_Card_5 x458 y400
Gui, Font, s11 Bold
Gui, Add, Button, vDouble_Down x007 y505 w100 h35, &Double Down
Gui, Font, s12 Bold
Gui, Add, Button, vSurrender x118 y505 w100 h35, S&urrender
Gui, Add, Button, vSplit x229 y505 w100 h35, S&plit
Gui, Add, Button, vHit x340 y505 w100 h35, &Hit
Gui, Add, Button, vStand x451 y505 w100 h35, &Stand
Gui, Add, Button, vDeal x562 y505 w100 h35 Default, Deal
Gui, Add, Text, x90 y288 cRed Backgroundtrans vHand_1_Bet w70
Gui, Add, Text, x650 y288 cRed Backgroundtrans vHand_2_Bet w70
Gui, Font, s14 Bold
Gui, Add, Text, x302 y108 cYellow Backgroundtrans vDealer_Hand_Cnt w25
Gui, Add, Text, x400 y420 cYellow Backgroundtrans vPlayer_Hand_Cnt w25
Gui, Add, Text, x255 y280 cYellow Backgroundtrans vSplit_Hand_1_Cnt w25
Gui, Add, Text, x545 y280 cYellow Backgroundtrans vSplit_Hand_2_Cnt w25
Gui, Font, s24 Bold cRed
Gui, Add, Text, Backgroundtrans x670 y506, $
Gui, Font, s13 Bold cRed
Gui, Add, Text, Backgroundtrans x693 y482 vBet_Amount_Text, Bet Amount
Gui, Font, s14 Bold cLime
Gui, Add, Text, Backgroundtrans x7 y150, Total Amount
Gui, Add, Text, Backgroundtrans x670 y150 w120 h300 vScore,
Gui, Font, s16
Total_Amount := Ceil(Total_Amount)
Gui, Add, Text, Backgroundtrans x7 y175, $ %Total_Amount%
Gui, Font, s18 Bold cRed
Gui, Add, Edit, x692 y505 w100 h35 Number Limit vBet_Amount, %BetAmount%
GuiControl, Disable, Surrender
GuiControl, Disable, Double_Down
GuiControl, Disable, Split
GuiControl, Disable, Hit
GuiControl, Disable, Stand
GuiControl, Disable, Deal
Gui, Show, Center AutoSize, BlackJack
SetTimer, Check_Bet_Amount, 250
If Total_Amount = 0
{
SetTimer, Check_Bet_Amount, Off
GuiControl, Disable, Deal
yPos = 150
PosVar = Minus
Gui, 4:+AlwaysOnTop -Border +Owner
Gui, 4:Font, s60 Bold cRed
Gui, 4:Color, Black
Gui, 4:Add, Text, vText Backgroundtrans, GAME OVER
Gui, 4:Show
/*
Loop
{
If PosVar = Plus
yPos++
If PosVar = Minus
yPos--
GuiControl, 4:Move, Text, y%yPos%
If yPos = -25
PosVar = Plus
If yPos = 115
PosVar = Minus
If A_Index = 9487
Break
}
*/
If SoundPlay = On
SoundPlay, GameOver.wav, Wait
Gui, 4:Destroy
MsgBox, 49, Game over..., Play again?
IfMsgBox OK
Gosub NewGame
Else
ExitApp
Return
}
If SoundPlay = On
SoundPlay, Shuffle.wav, Wait
Return
ButtonDeal:
GuiControlGet, aState, Enabled, Deal
If !aState
Return
GuiControl, Disable, Bet_Amount
Gui, Submit, NoHide
If Bet_Amount > %Total_Amount%
{
GuiControl, , Score, You do not have enough money to make this bet.`n`nPlease bet again.
If SoundPlay = On
SoundPlay, Error.wav
;MsgBox, 8208, BlackJack, You do not have enough money to make this bet.`n`n%A_Tab%%A_Space%%A_Space%Please bet again.
GuiControl, , Bet_Amount, %Total_Amount%
GuiControl, Enable, Bet_Amount
GuiControl, Focus, Bet_Amount
Return
}
BetAmount = %Bet_Amount%
GuiControl, , Hand_1_Bet, $%Bet_Amount%
GuiControl, , Chip_Stack_1, Chip_Stack.bmp
If SoundPlay = On
SoundPlay, Bet.wav, Wait
SetTimer, Check_Bet_Amount, Off
GoSub, Get_Card
Player_Card_1 = %Card%
Player_Card_1_Value = %Card_Value%
Player_Card_1_Pic = %Pic%
GuiControl, , Player_Card_1, %Player_Card_1_Pic%
GoSub, Get_Card
Dealer_Card_1 = %Card%
Dealer_Card_1_Value = %Card_Value%
Dealer_Card_1_Pic = %Pic%
GuiControl, , Dealer_Card_1, Dealer_Down_Card.bmp
GoSub, Get_Card
Player_Card_2 = %Card%
Player_Card_2_Value = %Card_Value%
Player_Card_2_Pic = %Pic%
GuiControl, , Player_Card_2, %Player_Card_2_Pic%
Player_Hand = %Player_Card_1%,%Player_Card_2%
GoSub, Get_Card
Dealer_Card_2 = %Card%
Dealer_Card_2_Value = %Card_Value%
Dealer_Card_2_Pic = %Pic%
GuiControl, , Dealer_Card_2, %Dealer_Card_2_Pic%
Dealer_Hand = %Dealer_Card_1%,%Dealer_Card_2%
GuiControl, Disable, Deal
GuiControl, Enable, Hit
GuiControl, Enable, Stand
GuiControl, Enable, Surrender
GoSub, Dealer_Hand_Cnt
GoSub, Player_Hand_Cnt
Double_Bet_Amount := (Bet_Amount + Bet_Amount)
If Double_Bet_Amount <= %Total_Amount%
GuiControl, Enable, Double_Down
If Player_Card_1 = %Player_Card_2%
If Double_Bet_Amount <= %Total_Amount%
GuiControl, Enable, Split
If (Player_Card_1_Value + Player_Card_2_Value = 21)
{
GuiControl, Disable, Surrender
GuiControl, Disable, Double_Down
GuiControl, Disable, Split
GuiControl, Disable, Hit
GuiControl, Disable, Stand
GuiControl, Disable, Deal
Sleep, 1000
yPos = 150
PosVar = Minus
Gui, 4:-Border +Owner +AlwaysOnTop
Gui, 4:Color, Black
Gui, 4:Font, s60 Bold cTeal
Gui, 4:Add, Text, vText Backgroundtrans, BlackJack
Gui, 4:Submit, NoHide
Gui, 4:Show, AutoSize
/*
Loop
{
If PosVar = Plus
yPos++
If PosVar = Minus
yPos--
GuiControl, 4:Move, Text, y%yPos%
If yPos = -25
PosVar = Plus
If yPos = 115
PosVar = Minus
If A_Index = 9487
Break
}
*/
If SoundPlay = On
SoundPlay, BlackJack.wav, Wait
Sleep, 2000
Gui, 4:Destroy
Half_Bet_Amount := (Bet_Amount / 2)
Total_Amount := (Total_Amount + Bet_Amount + Half_Bet_Amount)
Goto, New_Game
}
Return
ButtonHit:
GuiControlGet, aState, Enabled, Hit
If !aState
Return
GuiControl, Disable, Double_Down
GuiControl, Disable, Surrender
GuiControl, Disable, Split
Insurance = On
GoSub, Get_Card
If Split = On
{
If Split_Hand = 1
{
Split_Hand_1_Card_%Split_Hand_1_Hit_Cnt% = %Card%
Split_Hand_1_Card_%Split_Hand_1_Hit_Cnt%_Value = %Card_Value%
Split_Hand_1_Card_%Split_Hand_1_Hit_Cnt%_Pic = %Pic%
GuiControl, , Split_Hand_1_Card_%Split_Hand_1_Hit_Cnt%, %Pic%
GoSub, Split_Hand_1_Cnt
If Split_Hand_1_Cnt > 21
{
GuiControl, , Score, Hand (1) Bust
If SoundPlay = On
SoundPlay, Lose.wav, Wait
SoundSet, +, , Mute
;MsgBox, 8192, BlackJack, Hand (1) Bust
SoundSet, -, , Mute
Split_Hand_1 = Bust
Split_Hand = 2
GoSub, Split_Hand_1_Cnt
GuiControl, Enable, Double_Down
Return
}
If Double_Down_Cnt = 1
{
Split_Hand = 2
DoubleDown_Split_Hand_1 = Yes
GoSub, Split_Hand_1_Cnt
GuiControl, Disable, Double_Down
If (Double_Bet_Amount + Double_Bet_Amount <= Total_Amount)
GuiControl, Enable, Double_Down
Return
}
If Split_Hand_1_Hit_Cnt = 5
Goto, ButtonStand
Split_Hand_1_Hit_Cnt++
Return
}
If Split_Hand = 2
{
Split_Hand_2_Card_%Split_Hand_2_Hit_Cnt% = %Card%
Split_Hand_2_Card_%Split_Hand_2_Hit_Cnt%_Value = %Card_Value%
Split_Hand_2_Card_%Split_Hand_2_Hit_Cnt%_Pic = %Pic%
GuiControl, , Split_Hand_2_Card_%Split_Hand_2_Hit_Cnt%, %Pic%
GoSub, Split_Hand_2_Cnt
If Split_Hand_2_Cnt > 21
{
GuiControl, , Score, Hand (2) Bust
If SoundPlay = On
SoundPlay, Lose.wav, Wait
SoundSet, +, , Mute
;MsgBox, 8192, BlackJack, Hand (2) Bust
SoundSet, -, , Mute
SetTimer, Flasher, Off
GoSub, Split_Hand_2_Cnt
If Split_Hand_1 = Bust
{
GuiControl, , Score, Hand (1) Loses!`n`nHand (2) Loses!
If SoundPlay = On
SoundPlay, Bust.wav, Wait
SoundSet, +, , Mute
;MsgBox, 8192, BlackJack, Hand (1) Loses!`n`nHand (2) Loses!
SoundSet, -, , Mute
If DoubleDown_Split_Hand_1 = Yes
Total_Amount := (Total_Amount - Bet_Amount)
If DoubleDown_Split_Hand_2 = Yes
Total_Amount := (Total_Amount - Bet_Amount)
Total_Amount := (Total_Amount - Double_Bet_Amount)
Goto, New_Game
}
Goto, ButtonStand
}
If Double_Down_Cnt = 2
{
DoubleDown_Split_Hand_2 = Yes
Goto, ButtonStand
}
If Split_Hand_2_Hit_Cnt = 5
Goto, ButtonStand
Split_Hand_2_Hit_Cnt++
}
Return
}
Else
{
Player_Card_%Player_Hit_Cnt% = %Card%
Player_Card_%Player_Hit_Cnt%_Value = %Card_Value%
Player_Card_%Player_Hit_Cnt%_Pic = %Pic%
GuiControl, , Player_Card_%Player_Hit_Cnt%, %Pic%
Player_Hand = %Player_Hand%,Player_Card_%Player_Hit_Cnt%,
GoSub, Player_Hand_Cnt
If Player_Hit_Cnt = 5
If Player_Hand_Cnt <= 21
Goto, ButtonStand
Player_Hit_Cnt++
}
If Player_Hand_Cnt > 21
{
GuiControl, , Score, You Bust`n`nYou Lose!
If SoundPlay = On
SoundPlay, Lose.wav, Wait
SoundSet, +, , Mute
If Double_Down_Cnt = 0
Bet_Amount = %Double_Bet_Amount%
Total_Amount := (Total_Amount - Bet_Amount)
;MsgBox, 8192, BlackJack, You Bust`n`nYou Lose!
SoundSet, -, , Mute
Goto, New_Game
}
If Double_Down_Cnt = 0
Goto, ButtonStand
Return
ButtonStand:
GuiControlGet, aState, Enabled, Stand
If !aState
Return
If SoundPlay = On
SoundPlay, Stand.wav, Wait
Stand = On
GuiControl, Disable, Double_Down
GuiControl, Disable, Surrender
GuiControl, Disable, Split
GuiControl, Disable, Hit
GuiControl, Disable, Stand
GuiControl, Disable, Deal
If Split_Hand = 1
{
GuiControl, Enable, Double_Down
GuiControl, Enable, Hit
GuiControl, Enable, Stand
Split_Hand = 2
GoSub, Split_Hand_1_Cnt
Return
}
If Split_Hand = 2
{
GuiControl, Disable, Stand
SetTimer, Flasher, Off
GoSub, Split_Hand_2_Cnt
}
GoSub, Player_Hand_Cnt
GoSub, Dealer_Hand_Cnt
GuiControl, , Dealer_Card_1, %Dealer_Card_1_Pic%
Loop:
Loop
{
If Dealer_Hand_Cnt < 17
{
Sleep, 1500
GoSub, Get_Card
Dealer_Card_%Dealer_Hit_Cnt% = %Card%
Dealer_Card_%Dealer_Hit_Cnt%_Value = %Card_Value%
Dealer_Card_%Dealer_Hit_Cnt%_Pic = %Pic%
GuiControl, , Dealer_Card_%Dealer_Hit_Cnt%, %Pic%
Dealer_Hand = %Dealer_Hand%,Dealer_Card_%Dealer_Hit_Cnt%,
GoSub, Dealer_Hand_Cnt
If Dealer_Hit_Cnt = 5
Break
Dealer_Hit_Cnt++
If Dealer_Hand_Cnt >= 17
Break
Goto, Loop
}
Break
}
Sleep, 500
If Split = On
{
If Dealer_Hand_Cnt > 21
{
If Split_Hand_1_Cnt <= 21
{
If DoubleDown_Split_Hand_1 = Yes
Total_Amount := (Total_Amount + Bet_Amount)
Total_Amount := (Total_Amount + Bet_Amount)
Split_Hand_1 = Hand (1) Wins!
}
If Split_Hand_1_Cnt > 21
{
If DoubleDown_Split_Hand_1 = Yes
Total_Amount := (Total_Amount - Bet_Amount)
Total_Amount := (Total_Amount - Bet_Amount)
Split_Hand_1 = Hand (1) Loses!
}
If Split_Hand_2_Cnt <= 21
{
If DoubleDown_Split_Hand_2 = Yes
Total_Amount := (Total_Amount + Bet_Amount)
Total_Amount := (Total_Amount + Bet_Amount)
Split_Hand_2 = Hand (2) Wins!
}
If Split_Hand_2_Cnt > 21
{
If DoubleDown_Split_Hand_2 = Yes
Total_Amount := (Total_Amount - Bet_Amount)
Total_Amount := (Total_Amount - Bet_Amount)
Split_Hand_2 = Hand (2) Loses!
}
}
If Dealer_Hand_Cnt <= 21
{
If Split_Hand_1_Cnt > 21
{
If DoubleDown_Split_Hand_1 = Yes
Total_Amount := (Total_Amount - Bet_Amount)
Total_Amount := (Total_Amount - Bet_Amount)
Split_Hand_1 = Hand (1) Loses!
}
If Split_Hand_2_Cnt > 21
{
If DoubleDown_Split_Hand_2 = Yes
Total_Amount := (Total_Amount - Bet_Amount)
Total_Amount := (Total_Amount - Bet_Amount)
Split_Hand_2 = Hand (2) Loses!
}
If Split_Hand_1_Cnt < %Dealer_Hand_Cnt%
{
If DoubleDown_Split_Hand_1 = Yes
Total_Amount := (Total_Amount - Bet_Amount)
Total_Amount := (Total_Amount - Bet_Amount)
Split_Hand_1 = Hand (1) Loses!
}
If Split_Hand_2_Cnt < %Dealer_Hand_Cnt%
{
If DoubleDown_Split_Hand_2 = Yes
Total_Amount := (Total_Amount - Bet_Amount)
Total_Amount := (Total_Amount - Bet_Amount)
Split_Hand_2 = Hand (2) Loses!
}
If Split_Hand_1_Cnt <= 21
{
If Split_Hand_1_Cnt > %Dealer_Hand_Cnt%
{
If DoubleDown_Split_Hand_1 = Yes
Total_Amount := (Total_Amount + Bet_Amount)
Total_Amount := (Total_Amount + Bet_Amount)
Split_Hand_1 = Hand (1) Wins!
}
}
If Split_Hand_2_Cnt <= 21
{
If Split_Hand_2_Cnt > %Dealer_Hand_Cnt%
{
If DoubleDown_Split_Hand_2 = Yes
Total_Amount := (Total_Amount + Bet_Amount)
Total_Amount := (Total_Amount + Bet_Amount)
Split_Hand_2 = Hand (2) Wins!
}
}
If Split_Hand_1_Cnt = %Dealer_Hand_Cnt%
Split_Hand_1 = Hand (1) Ties
If Split_Hand_2_Cnt = %Dealer_Hand_Cnt%
Split_Hand_2 = Hand (2) Ties
If Split_Hand_1_Hit_Cnt = 5
If Split_Hand_1_Cnt <= 21
{
Total_Amount := (Total_Amount + Bet_Amount)
Split_Hand_1 = Hand (1) Wins!
}
If Split_Hand_2_Hit_Cnt = 5
If Split_Hand_2_Cnt <= 21
{
Total_Amount := (Total_Amount + Bet_Amount)
Split_Hand_2 = Hand (1) Wins!
}
}
SoundSet, +, , Mute
;MsgBox, 8192, BlackJack, %Split_Hand_1%`n`n%Split_Hand_2%
GuiControl, , Score, %Split_Hand_1%`n`n%Split_Hand_2%
SoundSet, -, , Mute
Goto, New_Game
}
Else
{
If Double_Down_Cnt = 0
Bet_Amount = %Double_Bet_Amount%
If Dealer_Hand_Cnt > 21
If Player_Hand_Cnt <= 21
{
GuiControl, , Score, Dealer Bust`n`nYou Win!
If SoundPlay = On
SoundPlay, Win.wav, Wait
SoundSet, +, , Mute
Total_Amount := (Total_Amount + Bet_Amount)
;MsgBox, 8192, BlackJack, Dealer Bust`n`nYou Win!
SoundSet, -, , Mute
Goto, New_Game
}
If Dealer_Hand_Cnt <= 21
If Player_Hand_Cnt > %Dealer_Hand_Cnt%
{
GuiControl, , Score, You Win!
If SoundPlay = On
SoundPlay, Win.wav, Wait
SoundSet, +, , Mute
Total_Amount := (Total_Amount + Bet_Amount)
;MsgBox, 8192, BlackJack, You Win!
SoundSet, -, , Mute
Goto, New_Game
}
If Dealer_Hand_Cnt <= 21
If Player_Hand_Cnt < %Dealer_Hand_Cnt%
{
GuiControl, , Score, You Lose!
If SoundPlay = On
SoundPlay, Bust.wav, Wait
SoundSet, +, , Mute
Total_Amount := (Total_Amount - Bet_Amount)
;MsgBox, 8192, BlackJack, You Lose!
SoundSet, -, , Mute
Goto, New_Game
}
If Player_Hand_Cnt = %Dealer_Hand_Cnt%
{
GuiControl, , Score, You Tie...
If SoundPlay = On
SoundPlay, Tie.wav, Wait
SoundSet, +, , Mute
;MsgBox, 8192, BlackJack, You Tie...
SoundSet, -, , Mute
Goto, New_Game
}
}
Goto, New_Game
ButtonSplit:
GuiControlGet, aState, Enabled, Split
If !aState
Return
Split = On
Split_Hand = 1
Insurance = On
If SoundPlay = On
SoundPlay, Bet.wav, Wait
GuiControl, Disable, Double_Down
GuiControl, Disable, Surrender
GuiControl, Disable, Split
GuiControl, Hide, Player_Hand_Cnt
GuiControl, , Hand_2_Bet, $%Bet_Amount%
GuiControl, , Chip_Stack_2, Chip_Stack.bmp
GuiControl, Hide, Player_Card_1
GuiControl, Hide, Player_Card_2
If (Double_Bet_Amount + Bet_Amount <= Total_Amount)
GuiControl, Enable, Double_Down
If Player_Card_1_Value = 11
Player_Card_2_Value = 11
If Player_Card_2_Value = 11
Player_Card_1_Value = 11
Split_Hand_1_Card_1 = %Player_Card_1%
Split_Hand_1_Card_1_Value = %Player_Card_1_Value%
Split_Hand_1_Card_1_Pic= %Player_Card_1_Pic%
Split_Hand_2_Card_1 = %Player_Card_2%
Split_Hand_2_Card_1_Value = %Player_Card_2_Value%
Split_Hand_2_Card_1_Pic= %Player_Card_2_Pic%
GuiControl, , Split_Hand_1_Card_1, %Split_Hand_1_Card_1_Pic%
GuiControl, , Split_Hand_2_Card_1, %Split_Hand_2_Card_1_Pic%
GoSub, Get_Card
Split_Hand_1_Card_2 = %Card%
Split_Hand_1_Card_2_Value = %Card_Value%
Split_Hand_1_Card_2_Pic = %Pic%
GuiControl, , Split_Hand_1_Card_2, %Split_Hand_1_Card_2_Pic%
GoSub, Get_Card
Split_Hand_2_Card_2 = %Card%
Split_Hand_2_Card_2_Value = %Card_Value%
Split_Hand_2_Card_2_Pic = %Pic%
GuiControl, , Split_Hand_2_Card_2, %Split_Hand_2_Card_2_Pic%
GoSub, Split_Hand_1_Cnt
GoSub, Split_Hand_2_Cnt
SetTimer, Flasher, 1000
GoSub, Flasher
Return
Insurance:
If Insurance = On
Return
Insurance = On
If Dealer_Card_2_Value = 11
{
If SoundPlay = On
SoundPlay, Bet.wav, Wait
GuiControl, , Insurance_Chip, Insurance_Chip.bmp
GuiControl, Disable, Surrender
GuiControl, Disable, Double_Down
GuiControl, Disable, Split
GuiControl, Disable, Hit
GuiControl, Disable, Stand
Insurance_Amount := (Bet_Amount / 2)
Gui, 4:+AlwaysOnTop -Border +Owner
Gui, 4:Font, s25 Bold
Gui, 4:Color, Black
Gui, 4:Add, Text, vText cSilver Backgroundtrans, The dealer is checking his cards...
Gui, 4:Show, AutoSize
Sleep, 4000
Gui, 4:Destroy
If (Dealer_Card_1_Value + Dealer_Card_2_Value = 21)
{
GuiControl, , Dealer_Card_1, %Dealer_Card_1_Pic%
GuiControl, , Dealer_Hand_Cnt, 21
Gui, 4:+AlwaysOnTop -Border +Owner
Gui, 4:Font, s25 Bold
Gui, 4:Color, Black
Gui, 4:Add, Text, vText cSilver Backgroundtrans, The dealer has 21`n%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%You Win!
Gui, 4:Show, AutoSize
Sleep, 4000
Gui, 4:Destroy
Total_Amount := (Total_Amount + Insurance_Amount * 2)
Goto, New_Game
}
Gui, 4:+AlwaysOnTop -Border +Owner
Gui, 4:Font, s25 Bold
Gui, 4:Color, Black
Gui, 4:Add, Text, vText cSilver Backgroundtrans, The dealer does not have 21
Gui, 4:Show, AutoSize
Sleep, 4000
Gui, 4:Destroy
Total_Amount:= (Total_Amount - Insurance_Amount)
If Double_Down_Cnt > 0
GuiControl, Enable, Double_Down
GuiControl, Enable, Surrender
GuiControl, Enable, Split
GuiControl, Enable, Hit
GuiControl, Enable, Stand
Return
}
Return
ButtonDoubleDown:
GuiControlGet, aState, Enabled, Double_Down
If !aState
Return
Double_Down_Cnt = 0
If Split = On
{
If Split_Hand = 1
{
Double_Down_Cnt = 1
GuiControl, Enable, Double_Down
}
If Split_Hand = 2
Double_Down_Cnt = 2
}
If Double_Down_Cnt = 0
{
GuiControl, , Hand_2_Bet, $%Bet_Amount%
GuiControl, , Chip_Stack_2, Chip_Stack.bmp
If SoundPlay = On
SoundPlay, Bet.wav, Wait
}
Goto, ButtonHit
ButtonSurrender:
GuiControlGet, aState, Enabled, Surrender
If !aState
Return
GuiControl, , Score, You Surrendered...
If SoundPlay = On
SoundPlay, Surrender.wav, Wait
SoundSet, +, , Mute
Total_Amount := (Total_Amount - Bet_Amount / 2)
;MsgBox, 8192, BlackJack, You Surrendered...
SoundSet, -, , Mute
Goto, New_Game
Check_Bet_Amount:
GuiControlGet, Check_Bet_Amount, , Bet_Amount
If Check_Bet_Amount =
GuiControl, Disable, Deal
If Check_Bet_Amount > 0
GuiControl, Enable, Deal
Return
Flasher:
GoSub, Split_Hand_%Split_Hand%_Cnt
Sleep, 600
GuiControl, , Split_Hand_%Split_Hand%_Cnt
Return
Dealer_Hand_Cnt:
Var_1 = Dealer_Hand_Cnt
Var_2 = Dealer_Card
If Stand = On
{
Dealer_Hand_Cnt := (Dealer_Card_1_Value + Dealer_Card_2_Value + Dealer_Card_3_Value + Dealer_Card_4_Value + Dealer_Card_5_Value)
GoSub, Check_Aces
GuiControl, , Dealer_Hand_Cnt, %Dealer_Hand_Cnt%
}
Else
{
Dealer_Hand_Cnt := (Dealer_Card_2_Value + Dealer_Card_3_Value + Dealer_Card_4_Value + Dealer_Card_5_Value)
GoSub, Check_Aces
GuiControl, , Dealer_Hand_Cnt, %Dealer_Hand_Cnt%
}
Return
Player_Hand_Cnt:
Var_1 = Player_Hand_Cnt
Var_2 = Player_Card
Player_Hand_Cnt := (Player_Card_1_Value + Player_Card_2_Value + Player_Card_3_Value + Player_Card_4_Value + Player_Card_5_Value)
GoSub, Check_Aces
GuiControl, , Player_Hand_Cnt, %Player_Hand_Cnt%
Return
Split_Hand_1_Cnt:
Var_1 = Split_Hand_1_Cnt
Var_2 = Split_Hand_1_Card
Split_Hand_1_Cnt := (Split_Hand_1_Card_1_Value + Split_Hand_1_Card_2_Value + Split_Hand_1_Card_3_Value + Split_Hand_1_Card_4_Value + Split_Hand_1_Card_5_Value)
GoSub, Check_Aces
GuiControl, , Split_Hand_1_Cnt, %Split_Hand_1_Cnt%
Return
Split_Hand_2_Cnt:
Var_1 = Split_Hand_2_Cnt
Var_2 = Split_Hand_2_Card
Split_Hand_2_Cnt := (Split_Hand_2_Card_1_Value + Split_Hand_2_Card_2_Value + Split_Hand_2_Card_3_Value + Split_Hand_2_Card_4_Value + Split_Hand_2_Card_5_Value)
GoSub, Check_Aces
GuiControl, , Split_Hand_2_Cnt, %Split_Hand_2_Cnt%
Return
Check_Aces:
If %Var_1% > 21
{
Loop, 5
{
If %Var_2%_%A_Index%_Value = 11
{
%Var_2%_%A_Index%_Value = 1
Goto, %Var_1%
}
}
}
Return
Get_Card:
;01-13 = Spades
;14-26 = Hearts
;27-39 = Clubs
;40-52 = Diamonds
Random, Card, 1, 52
If Card in %Card_List%
Goto, Get_Card
Card_List = %Card_List%%Card%,
If Card between 1 and 13
Suit = S
If Card between 14 and 26
{
Suit = H
Cnt = 14
GoSub, Card_Counter
}
If Card between 27 and 39
{
Suit = C
Cnt = 27
GoSub, Card_Counter
}
If Card between 40 and 52
{
Suit = D
Cnt = 40
GoSub, Card_Counter
}
If Card = 1
Card_Value = 11
If Card between 2 and 10
Card_Value = %Card%
If Card between 11 and 13
Card_Value = 10
Pic = %Suit%%Card%.bmp
If Card = 11
Card = J
IF Card = 12
Card = Q
If Card = 13
Card = K
Sleep, 100
If SoundPlay = On
SoundPlay, Deal.wav, Wait
Return
Card_Counter:
Loop, 13
{
If Card = %Cnt%
Card = %A_Index%
Cnt++
}
Return
TrayMenu:
Menu, Tray, Icon, BlackJack.ico
Menu, Tray, MainWindow
Menu, Tray, NoStandard
Menu, Tray, DeleteAll
Menu, Tray, Add, BlackJack, BlackJack
Menu, Tray, Add,
Menu, Submenu, Add, Premise of the game, Rules/Instructions
Menu, Submenu, Add, Values of the cards, Rules/Instructions
Menu, Submenu, Add, How the dealer plays his hand, Rules/Instructions
Menu, Submenu, Add, Hitting/Standing, Rules/Instructions
Menu, Submenu, Add, Splitting Pairs, Rules/Instructions
Menu, Submenu, Add, Doubling Down, Rules/Instructions
Menu, Submenu, Add, Surrender, Rules/Instructions
Menu, Submenu, Add, Insurance, Rules/Instructions
Menu, Tray, Add, Rules/Instructions, :Submenu
Menu, Tray, Add, Sounds, Sounds
Menu, Tray, Add, New Game, NewGame
Menu, Tray, Add, About, About
Menu, Tray, Add, Quit, GuiClose
Menu, Tray, Check, Sounds
Menu, Tray, Default, BlackJack
Return
BlackJack:
Gui, Show, Center AutoSize, BlackJack
Return
Rules/Instructions:
#LTrim
If A_ThisMenuItem = Premise of the game
{
Message =
(
The basic premise of the game is that you want to have a hand value that is closer
to 21 than that of the dealer, without going over 21. Other players at the table are
of no concern. Your hand is strictly played out against the hand of the dealer. The
rules of play for the dealer are strictly dictated, leaving no decisions up to the dealer.
Therefore, there is not a problem with the dealer or any of the other players at the table
seeing the cards in your hand.
)
Goto, Rules-Instructions
}
If A_ThisMenuItem = Values of the cards
{
Message =
(
In blackjack, the cards are valued as follows:
An Ace can count as either 1 or 11.
The cards from 2 through 9 are valued as indicated.
The 10, Jack, Queen, and King are all valued at 10.
)
Goto, Rules-Instructions
}
If A_ThisMenuItem = How the dealer plays his hand
{
Message =
(
The dealer must play his hand in a specific way, with no choices allowed. "Dealer stands on all 17s".
This is the most common rule. In this case, the dealer must continue to take cards ("hit") until his
total is 17 or greater. An Ace in the dealer's hand is always counted as 11 if possible without the
dealer going over 21. For example, (Ace,8) would be 19 and the dealer would stop drawing cards
("stand"). Also, (Ace,6) is 17 and again the dealer will stand. (Ace,5) is only 16, so the dealer would
hit. He will continue to draw cards until the hand's value is 17 or more. For example, (Ace,5,7) is only
13 so he hits again. (Ace,5,7,5) makes 18 so he would stop ("stand") at that point. This game is also
setup so the maximum number of cards the dealer can draw is 5. If his hand is over 21 with 5 cards
then of coursethe dealer "Bust", but if its not over 21 his hand is considered live and is played
against the players hand at that point no matter what his card count is.
)
Goto, Rules-Instructions
}
If A_ThisMenuItem = Hitting/Standing
{
Message =
(
The most common decision a player must make during the game is whether to
draw another card to the hand ("hit"), or stop at the current total ("stand").
This game is also setup so the maximum number of cards you can draw is 5. If
your hand is over 21 with 5 cards then of course you "Bust", but if its not
over 21 your hand is considered live and is played against the dealers hand at
that point no matter what your card count is.
)
Goto, Rules-Instructions
}
If A_ThisMenuItem = Splitting Pairs
{
Message =
(
When you are dealt a matching pair of cards you have the ability to split
the hand into two separate hands, and play them independently. Let's say
you are dealt a pair of eights for a total of sixteen. Sixteen is the worst
possible player hand, since it is unlikely to win as is, but is very likely
to bust if you draw to it. Here's a great chance to improve a bad situation.
)
Goto, Rules-Instructions
}
If A_ThisMenuItem = Doubling Down
{
Message =
(
This can only be done with a two card hand, before another card has been drawn.
Doubling down allows you to double your bet and receive one, and only one,
additional card to the hand. A good example of a doubling opportunity is when you
hold a total of 11, say a (6,5) against a dealer's upcard of 5. In this case, you have
a good chance of winning the hand by drawing one additional card, so you might as
well increase your bet in this advantageous situation. The amount of the double down
bet in this game is the full bet amount.
)
Goto, Rules-Instructions
}
If A_ThisMenuItem = Surrender
{
Message =
(
Surrender offers you as a player the choice to fold your hand,
at the cost of half of the original bet. You must make that
decision prior to taking any other action on the hand. For example,
once you draw a third card, or split, or double down, surrender
is no longer an option.
)
Goto, Rules-Instructions
}
If A_ThisMenuItem = Insurance
{
Message =
(
If the dealer turns an up-card of an Ace, he will offer "Insurance" to the players.
Insurance bets can be made by betting up to half your original bet amount in the
insurance betting stripe in front of your bet (this game has a set amount, which is
set to half the bet amount). The dealer will check to see if he has a 10-value card
underneath his Ace, and if he does have Blackjack, your winning Insurance bet will be
paid at odds of 2:1. You'll lose your original bet of course. Of course, if the dealer
does not have blackjack, you'll lose the insurance bet, and still have to play the original
bet out. If the dealer is showing an Ace and you want insurance, click on the word
'Insurance' on the table as seen in the picture below.
)
Goto, Rules-Instructions
}
Rules-Instructions:
Gui, 3:Destroy
Gui, 3:+AlwaysOnTop +Owner
Gui, 3:Font, s16
Gui, 3:Add, Text, cRed, %A_ThisMenuItem%
Gui, 3:Font, s12
Gui, 3:Add, Text, cNavy, %Message%`n
If A_ThisMenuItem = Insurance
Gui, 3:Add, Picture, , Insurance.bmp
Gui, 3:Show, , BlackJack - Rules/Instructions
#LTrim Off
Return
NewGame:
Reload
Sounds:
Menu, Tray, ToggleCheck, Sounds
If SoundPlay = On
SoundPlay = Off
Else
If SoundPlay = Off
SoundPlay = On
Return
About:
Gui, 2:Destroy
Pos1 = 100
Pos2 = 120
Pos3 = 155
Pos4 = 170
Gui, 2:+AlwaysOnTop +Owner
Gui, 2:Add, Picture, y10 gLogo, AHK.bmp
Gui, 2:Font, s10 Bold
Gui, 2:Add, Text, vText1 x175 y%Pos1%, Written by:
Gui, 2:Font, s14 Bold
Gui, 2:Add, Text, vText2 x172 y%Pos2% cBlue gaCkRiTe, aCkRiTe
Gui, 2:Font, s8 Bold
Gui, 2:Add, Text, vText3 x174 y%Pos3% cRed gVersion, Version 1.0.1
Gui, 2:Add, Text, vText4 x177 y%Pos4% cRed gVersion, 01/10/2007
Gui, 2:Show, h100, About BlackJack
Loop
{
Sleep, 35
Pos1--
Pos2--
Pos3--
Pos4--
GuiControl, 2:Move, Text1, y%Pos1%
GuiControl, 2:Move, Text2, y%Pos2%
GuiControl, 2:Move, Text3, y%Pos3%
GuiControl, 2:Move, Text4, y%Pos4%
If Pos1 = 10
Break
}
Return
Logo:
Run, iexplore.exe http://www.autohotkey.com, Max
Return
aCkRiTe:
Run, iexplore.exe http://www.autohotkey.com/forum/profile.php?mode=viewprofile&u=3082, Max
Return
Version:
Run, iexplore.exe http://www.autohotkey.com/forum/viewtopic.php?t=15988, Max
Return
GuiClose:
ExitApp