mardi 31 mai 2016

My BatchRPG is not doing to If statements correctly

@echo off
title Batch RPG V1
color 0a
setlocal enabledelayedexpansion

:menu
cls
echo Welcome Home!
timeout /t 3 >nul
cls
echo Batch RPG Game!
echo ---------------
echo.
echo 1) Begin
echo.
echo 2) Exit
echo.
set /p input=C:\

if "%input%" == "1" goto name
if "%input%" == "2" exit
goto menu

:name
cls
echo Please select a name!
echo ---------------------
echo.
set /p name=Name:
cls
echo Is "%name%" correct?
echo ------------------
echo.
echo 1) Yes
echo.
echo 2) No
echo.
set /p input=C:\
if "%input%" == "1" goto new
if "%input%" == "2" goto name
goto name

:new
cls
set hp=100
set mhp=30
set pdmg=10
set mdmg=3
set lvl=1
set pexp=0
echo Would you like to battle an enemy?
echo ----------------------------------
echo.
echo 1) Yes
echo.
echo 2) No
echo.
set /p input=C:\

if "%input%" == "1" goto encounter1
if "%input%" == "2" goto new
goto new

:new2
cls
set hp=100
set mhp=30
set pdmg=10
set mdmg=3
echo Would you like to battle an enemy?
echo ----------------------------------
echo.
echo 1) Yes
echo.
echo 2) No
echo.
set /p input=C:\

if "%input%" == "1" goto encounter1
if "%input%" == "2" goto new
goto new

:encounter1
cls
echo %name% Level: %lvl%
echo Damage: %pdmg%
echo Health: %hp%
echo.
echo Skeleton Level: 1
echo Damage: %mdmg%
echo Health: %mhp%
echo.
echo.
echo What would you like to do?
echo --------------------------
echo.
echo 1) Attack
echo.
echo 2) Run
echo.
set /p input=C:\

if "%input%" == "1" goto attack
if "%input%" == "2" goto new
if "%input%" == " " goto encounter1
goto encounter1

:attack
cls
echo You are now attacking the enemy!
echo --------------------------------
timeout /t 2 >nul
echo.
echo The enemy is now attacking you!
echo -------------------------------
echo.
timeout /t 1 >nul
set /a hp=%hp% - %mdmg%
set /a mhp=%mhp% - %pdmg%

if %hp% == leq 0 goto lose
if %mhp% == leq 0 goto win
goto encounter1

:win
echo     You Win!    
echo ----------------
echo.
set /a pexp=%pexp%+25
echo 25 EXP Awarded! You now have %pexp%!
timout /t 1 >nul
echo.
echo.
echo Returning Home!
timeout /t 5 >nul
goto new2

:lose
echo     You Lost!    
echo -----------------
timeout /t 1 >nul
echo.
echo.
echo Returning Home!
timeout /t 5 >nul
goto new

I beleive that is is somewhere near the bottom, but when you run this, it will continue the fight even though i call for it to say you win when the monster hits 0 or less health. I beleive that it is the if-statements, but i can not prove that, im a beginer, so if you could make an other adjustments to make my code more compact, that would also help :D!

Aucun commentaire:

Enregistrer un commentaire