Solved How to make a batch lottery?

July 13, 2012 at 14:46:10
Specs: Windows XP
Im wanting to make a batch game that allows me to have a lottery/ slots almost but i cant figure it out. please no insults like how dumb i am, im new to batch so give me a break :)

this is what i have

@echo off
:beginnigoflottery
set gold=100
goto lotterystart
:lotterystart
cls
set usernumber=1=%random% %% 10
set lotnumber=1=%random% %% 10
echo You Have %gold% Gold
echo 1
echo 10
echo 100
echo 1000
echo 10000
echo How Much Do You Want To Risk

set /p input=Risk

if %input% =="1" goto lotteryinput1
if %input% =="10" goto lotteryinput2
if %input% =="100" goto lotteryinput3
if %input% =="1000" goto lotteryinput4
if %input% =="10000" goto lotteryinput5
pause

:lotteryinput1
if %input% gtr %gold% goto error
set /a gold-=1
if %usernumber%equ%lotnumber% goto win1g
if not %usernumber%equ%lotnumber% goto sorryyoulost

:win1g
set /a gold+=2
echo You Won 2 Gold
echo.
echo You Now Have %gold% Gold
pause
goto lotterystart

:lotteryinput2
if %input% gtr %gold% goto error
set /a gold-=10
if %usernumber%==%lotnumber% goto win10g
if not %usernumber%==%lotnumber% goto sorryyoulost

:win10g
set /a gold+=20
echo You Won 20 Gold
echo.
echo You Now Have %gold% Gold
pause
goto lotterystart

:lotteryinput3
if %input% gtr %gold% goto error
set /a gold-=100
if %usernumber%==%lotnumber% goto win100g
if not %usernumber%==%lotnumber% goto sorryyoulost

:win100g
set /a gold+=200
echo You Won 200 Gold
echo.
echo You Now Have %gold% Gold
pause
goto lotterystart

:lotteryinput4
if %input% gtr %gold% goto error
set /a gold-=1000
if %usernumber%==%lotnumber% goto win1000g
if not %usernumber%==%lotnumber% goto sorryyoulost

:win1000g
set /a gold+=2000
echo You Won 2000 Gold
echo.
echo You Now Have %gold% Gold
pause
goto lotterystart


:lotteryinput5
if %input% gtr %gold% goto error
set /a gold-=10000
if %usernumber%==%lotnumber% goto win10000g
if not %usernumber%==%lotnumber% goto sorryyoulost

:win10000g
set /a gold+=20000
echo You Won 20000 Gold
echo.
echo You Now Have %gold% Gold
pause
goto lotterystart

:sorryyoulost
echo ===========================
echo You Lost
echo ===========================
pause
goto lotterystart

:error
echo Sorry Not Enough Gold
echo Pick Again
pause
goto lotterystart

i cant figure out what how to fix this i want it to tell whether u won or not
if %usernumber%==%lotnumber% goto win100g
if not %usernumber%==%lotnumber% goto sorryyoulost


See More: How to make a batch lottery?

Report •


#1
July 18, 2012 at 07:31:20
✔ Best Answer
perhaps something more simple (with the same kind of structure)

set /a gold=100

cls
:lotterystart
echo computing lottery numbers
echo this may take a moment
echo ===========================
:ans1
set /a ran=%random%
if /i %ran% GTR 10 goto :ans1
if /i %ran% LSS 1 goto :ans1
set usernum=%ran%
:ans2
set /a ran2=%random%
if /i %ran2% GTR 10 goto :ans2
if /i %ran2% LSS 1 goto :ans2
set lotnum=%ran2%
cls
echo ===========================
echo You Have %gold% Gold
echo ===========================
echo %lotnum% %usernum%
echo How Much Do You Want To Risk
set /p risk=Risk 1 to %gold%

if %risk% gtr %gold% goto error
if %usernum% equ %lotnum% goto winner
:sorryyoulost
set /a gold=(gold-risk)
echo ===========================
echo You Lost
echo ===========================
pause
cls
goto lotterystart

:error
echo Sorry Not Enough Gold
echo Pick Again
goto lotterystart

:winner
set /a gold=(gold+risk)
echo ===========================
echo You Won
echo ===========================
pause
cls
goto lotterystart

:: mike


Report •

#2
July 18, 2012 at 23:35:39
echo %lotnum% %usernum%
echo How Much Do You Want To Risk
set /p risk=Risk 1 to %gold%

I know how much to risk,i win always :)


Report •

#3
July 18, 2012 at 23:55:24
rem @echo off
:beginnigoflottery
set gold=100
goto lotterystart
:lotterystart
cls
set /a usernumber=%random% %% 10
set /a lotnumber=%random% %% 10
echo You Have %gold% Gold
echo 1
echo 10
echo 100
echo 1000
echo 10000
echo How Much Do You Want To Risk
set /p input=Risk
if %input% ==1 goto lotteryinput1
if %input% ==10 goto lotteryinput2
if %input% ==100 goto lotteryinput3
if %input% ==1000 goto lotteryinput4
if %input% ==10000 goto lotteryinput5
pause
:lotteryinput1
if %input% gtr %gold% goto error
set /a gold-=1
if %usernumber%==%lotnumber% goto win1g
if not %usernumber%==%lotnumber% goto sorryyoulost
:win1g
set /a gold+=2
echo You Won 2 Gold
echo.
echo You Now Have %gold% Gold
pause
goto lotterystart
:lotteryinput2
if %input% gtr %gold% goto error
set /a gold-=10
if %usernumber%==%lotnumber% goto win10g
if not %usernumber%==%lotnumber% goto sorryyoulost
:win10g
set /a gold+=20
echo You Won 20 Gold
echo.
echo You Now Have %gold% Gold
pause
goto lotterystart
:lotteryinput3
if %input% gtr %gold% goto error
set /a gold-=100
if %usernumber%==%lotnumber% goto win100g
if not %usernumber%==%lotnumber% goto sorryyoulost
:win100g
set /a gold+=200
echo You Won 200 Gold
echo.
echo You Now Have %gold% Gold
pause
goto lotterystart
:lotteryinput4
if %input% gtr %gold% goto error
set /a gold-=1000
if %usernumber%==%lotnumber% goto win1000g
if not %usernumber%==%lotnumber% goto sorryyoulost
:win1000g
set /a gold+=2000
echo You Won 2000 Gold
echo.
echo You Now Have %gold% Gold
pause
goto lotterystart

:lotteryinput5
if %input% gtr %gold% goto error
set /a gold-=10000
if %usernumber%==%lotnumber% goto win10000g
if not %usernumber%==%lotnumber% goto sorryyoulost
:win10000g
set /a gold+=20000
echo You Won 20000 Gold
echo.
echo You Now Have %gold% Gold
pause
goto lotterystart
:sorryyoulost
echo ===========================
echo You Lost
echo ===========================
pause
goto lotterystart
:error
echo Sorry Not Enough Gold
echo Pick Again
pause
goto lotterystart


I found some simple error,and the bat file above based on yours run well on my laptop. :)


Report •

Related Solutions


Ask Question