:blackjack
cls
echo Welcome to Blackjack.
echo These are your starting cards.
::It rolls a twice.
Set /a a=(%RANDOM%*11/32768)+1
Set /a a=(%RANDOM%*11/32768)+1
::This is what happens if you roll a 10, since there are 4 cards that are equal to 10.
pause
if %a%==10 (set /a fc=(%RANDOM%*4/32768)+1) else (goto skip_facecard)
if %a%==10 (set /a fc=(%RANDOM%*4/32768)+1) else (goto skip_facecard)
pause
if %fc%==1 (set /a a=10)
pause
if %fc%==2 (set /a a=Jack)
pause
if %fc%==3 (set /a a=Queen)
pause
if %fc%==4 (set /a a=King)
echo end of the pause test
pause
The crash always happens after the first pause. So it rolls for the a variable twice because for some reason if I told it to roll once the value wouldn't really be random and it would be the same every time you reboot the file. Then if you roll a 10, it should roll between 1 and 4 to determine if you get a 10, a jack, a queen, or a king, but instead it crashes. I've tried using both set /a and set /p, I've tried putting %a%= and I've tried a= but nothing seems to work and I don't know why.
::The user is asked if they would like to use an ace as an 11 or as a 1.
if %a%==11 set /p x=Would you like to use the ace as a 1 or as an 11?
if %b%==11 set /p y=Would you like to use the ace as a 1 or as an 11?
if %x%==1 set /a a=1
if %x%==11 set /a a=11
if %y%==1 set /a b=1
if %y%==11 set /a b=11
echo %a%
echo %b%
pause
I have the same issue here, it crashes before the pause, but after it asks the user for input.