0
\$\begingroup\$

I made a little gambling batch file and wanted to know if there was a better way to do the randomization and the checker.

:num1
cls
echo Getting results! Please wait.
    set /A g11=%random% %% 10
    goto num2
:num2
cls
echo Getting results! Please wait..
    set /A g22=%random% %% 10
    goto num3
:num3
cls
echo Getting results! Please wait...
    set /A g33=%random% %% 10
    goto results
:results
    if %g1%==%g11% if %g2%==%g22% if %g3%==%g33% goto w3
    if not %g1%==%g11% if %g2%==%g22% if %g3%==%g33% goto w2
    if %g1%==%g11% if not %g2%==%g22% if %g3%==%g33% goto w2
    if %g1%==%g11% if %g2%==%g22% if not %g3%==%g33% goto w2
    if not %g1%==%g11% if not %g2%==%g22% if %g3%==%g33% goto w1
    if not %g1%==%g11% if %g2%==%g22% if not %g3%==%g33% goto w1
    if %g1%==%g11% if not %g2%==%g22% if not %g3%==%g33% goto w1
    if not %g1%==%g11% if not %g2%==%g22% if not %g3%==%g33% goto Lose

The above is the aforementioned code below is the whole code its pretty small I'm also open to any constructive criticism or suggestions for it!

 @echo off
    cls
:menu
echo Hello. Welcome to Gamblebot 2000!
echo You will start off with 100 credits. As you climb,
echo you can start to place larger and better bets!
echo Do your best to not run out of money, or you will
echo have to start over.
echo Have fun :)
echo .
echo Version alpha 1.4.9
echo .
    pause
:start
cls 
    set bal=100
echo The game is simple. Guess a number between 0 and 9
echo for 3 instances. (For example: 123, 456, 789, 111)
echo A dice will be rolled. If you guess the number, you get a
echo winning based on the amount of numbers guessed correctly.
echo .
echo 1 numbers gives you a 2x win.
echo 2 numbers gives you a 3x win.
echo 3 numbers gives you a 4x win.
echo No numbers means you lost.
    pause
    goto curr
:curr
cls
echo First, start by naming the currency.
echo Name it whatever you like. Then press enter.
    set /p curr=
    goto g1
:currchange
cls
echo Enter name of new currency.
    set /p curr=
    goto g1
:g1
cls
    if %bal% == 0 goto Bankrupt
echo Please make your first number selection!!!
    set /p g1=
    goto g2
:g2
cls
echo Please make your second number selection!!!
    set /p g2=
    goto g3
:g3
cls
echo Please make your third number selection!!!
    set /p g3=
    goto bet
:bet
cls 
echo Your balance is %bal% %curr%
echo Place your bet.
    set /p bet=
    if %bet% GTR %bal% (
    goto inf )
    goto num1
:inf
cls
echo You do not have enough credits for that bet. Please choose another bet!
echo
pause
    goto bet
:num1
cls
echo Getting results! Please wait.
    set /A g11=%random% %% 10
    goto num2
:num2
cls
echo Getting results! Please wait..
    set /A g22=%random% %% 10
    goto num3
:num3
cls
echo Getting results! Please wait...
    set /A g33=%random% %% 10
    goto results
:results
    if %g1%==%g11% if %g2%==%g22% if %g3%==%g33% goto w3
    if not %g1%==%g11% if %g2%==%g22% if %g3%==%g33% goto w2
    if %g1%==%g11% if not %g2%==%g22% if %g3%==%g33% goto w2
    if %g1%==%g11% if %g2%==%g22% if not %g3%==%g33% goto w2
    if not %g1%==%g11% if not %g2%==%g22% if %g3%==%g33% goto w1
    if not %g1%==%g11% if %g2%==%g22% if not %g3%==%g33% goto w1
    if %g1%==%g11% if not %g2%==%g22% if not %g3%==%g33% goto w1
    if not %g1%==%g11% if not %g2%==%g22% if not %g3%==%g33% goto Lose
:w3
cls
    set /a win=%bet%*4
    set /a bal=%bal%+%win%
echo Congratulations you have guessed all three numbers correctly!
echo the numbers were: %g11%%g22%%g33%!
echo .
echo You have won "%win%" %curr%!
echo .
echo Your new credit balance is %bal% %curr%.
echo .
echo Would you like to make another bet? 
echo (Y/N)
set /p ha= 
    if %ha% == y goto g1
    if %ha% == Y goto g1
    if %ha% == n goto save
    if %ha% == N goto save
:w2
cls
    set /a win=%bet%*3
    set /a bal=%bal%+%win%
echo Congratulations you have guessed two numbers correctly!
echo the numbers were: %g11% %g22% %g33%!
echo Your numbers were %g1% %g2% %g3%
echo .
echo You have won "%win%" %curr%!
echo .
echo Your new credit balance is %bal% %curr%.
echo .
echo Would you like to make another bet? 
echo (Y/N)
set /p ha= 
    if %ha% == y goto g1
    if %ha% == Y goto g1
    if %ha% == n goto save
    if %ha% == N goto save
:w1
cls
    set /a win=%bet%*2
    set /a bal=%bal%+%win%
echo Congratulations you have guessed one correctly!
echo the numbers were: %g11% %g22% %g33%!
echo Your numbers were %g1% %g2% %g3%
echo .
echo You have won "%win%" %curr%!
echo .
echo Your new credit balance is %bal% %curr%.
echo .
echo Would you like to make another bet? 
echo (Y/N)
    set /p ha= 
    if %ha% == y goto g1
    if %ha% == Y goto g1
    if %ha% == n goto save
    if %ha% == N goto save
:lose
cls
    set /a bal=%bal%-%bet%
echo I am sorry but you did not guess any of the numbers correctly.
echo .
echo The numbers were: %g11% %g22% %g33%!
echo Your numbers were %g1% %g2% %g3%
echo .
echo You have lost %bet% %curr%.
echo .
echo Your new credit balance is %bal% %curr%.
echo Would you like to make another bet? 
echo (Y/N)
    set /p ha= 
    if %ha% == y goto g1
    if %ha% == Y goto g1
    if %ha% == n goto save
    if %ha% == N goto save
:change
cls
echo Would you like to change or keep the name of your currency?
echo Type k for keep or c for change.
    set /p ha=
    if %ha% == k goto g1
    if %ha% == K goto g1
    if %ha% == c goto currchange
    if %ha% == C goto currchange
:Bankrupt
cls
Echo Im sorry but you have no more money ;-;
Echo Would you like to add more credits?
Echo (Y/N)
    set /p ha= 
    if %ha% == y goto Purchase
    if %ha% == Y goto Purchase
    if %ha% == n Exit
    if %ha% == N Exit
:Purchase
cls
Echo Please select your purchase amount!
echo .
echo .
echo 1) 100 credits   $0.99
echo 2) 500 credits   $4.99
echo 3) 1000 credits  $8.99
echo 4) 5000 credits  $18.99
    set /p pur=
    if %pur% == 1 goto p
    if %pur% == 2 goto p
    if %pur% == 3 goto p
    if %pur% == 4 goto p
:p
cls
echo you have chosen Option %pur%!
echo please send an email with funds attached to buisness@fakemail.dum
echo and your credits will be applied instantly!
    pause
    Goto con
:con
cls
echo thank you for your support goodbye!
    pause
    Exit
:save
cls
echo Sorry. The save mechanic is not yet set up. It will be coming
echo in a future update Thanks for playing. I hope you had fun!
    Exit
\$\endgroup\$
  • 2
    \$\begingroup\$ Welcome to Code Review! Please change your title to describe what you code does in a way that might draw interest of users skimming the question list, not your concerns about it (see How to Ask). \$\endgroup\$ – AlexV Jul 2 '19 at 7:54
  • 1
    \$\begingroup\$ The current question title, which states your concerns about the code, is too general to be useful here. Please edit to the site standard, which is for the title to simply state the task accomplished by the code. Please see How to get the best value out of Code Review: Asking Questions for guidance on writing good question titles. \$\endgroup\$ – BCdotWEB Jul 2 '19 at 13:13
  • \$\begingroup\$ Wouldn't it be better to put each section in functions instead of gotoing to random labels? See Call /? \$\endgroup\$ – Neko Musume May 18 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.