mardi 30 juin 2015

Why does this AND system not work?

So, I'm making an RPG where the player can fight using various weapons, and I was testing this code:

:TEST
set /a bottomlimit=25
set /a upperlimit=50
set /a hp = %bottomlimit% + %random% %% (%upperlimit% - %bottomlimit% + 1)
cls
echo Oh no! goblins are attacking!
echo The party has 3 members, and they have %hp% health!
echo.
echo You can use:
if %fists% equ 1 echo fists
if %glass% equ 1 echo glass
if %knife% equ 1 echo knife
if %sword% equ 1 echo sword
if %ender_scythe% equ 1 echo ender_scythe
set /p answer=
if %fists% equ 1 (
   if %answer% equ fists set /a "hp=hp-5"
)
if %glass% equ 1 (
   if %answer% equ glass set /a "hp=hp-10"
)
if %knife% equ 1 (
    if %answer% equ knife set /a "hp=hp-14"
)
if %sword% equ 1 (
    if %answer% equ sword set /a "hp=hp-20"
)
if %ender_scythe% equ 1 (
    if %answer% equ ender_scythe set /a "hp=hp-50"
)
if %hp% equ 0 goto Win

When I attempt to fight using the weapons, it ALWAYS goes to Win. I have set the weapon's variables to 1 previously, so it should work, right?

Aucun commentaire:

Enregistrer un commentaire