批处理文件莫名其妙地显示变量列表

时间:2015-09-08 17:30:21

标签: batch-file

我不知道我在这里做错了什么,但由于某种原因我得到了很多变量值

@echo off
if not exist gamedata mkdir gamedata
cd gamedata
if not exist batbox.exe cd .. && move batbox.exe gamedata
cd gamedata
if not exist pclass.gm echo. 2> pclass.gm
if not exist playername.gm echo. 2> playername.gm
if not exist username.gm echo. 2> username.gm
if not exist password.gm echo. 2> password.gm
if not exist class.gm echo. 2> class.gm
if not exist weapons mkdir weapons
cd weapons
if not exist wand.gm echo Wand> wand.gm
if not exist sword.gm echo Sword> sword.gm
cd..
if not exist classes mkdir classes
cd classes
if not exist mage.gm echo Mage> mage.gm
if not exist worrior.gm echo Worrior> worrior.gm
cd..
goto vars

:vars
set health=100
set strength=1
set /a rndm=%random% %%15 +1
set /p pclass=<class.gm
cd weapons
set /p wand=<wand.gm
set /p sword=<sword.gm
cd..
cd classes
set /p mage=<mage.gm
set /p worrior=<worrior.gm
cd ..
cd ..
goto menu

:menu
set /p pclass=<pclass.gm
set /p name=<playername.gm
cd gamedata
color 0f
title menu
cls
echo Welcome! What would you like to do?
echo.
echo 1) Login to existing account
echo 2) Create new account
echo 3) Exit the game
set /p menu=: 

if "%menu%" == "1" goto game
if "%menu%" == "2" goto newuser

:login
mode con: cols=50 lines=20
color 0f
cls
title Login
set /p user=<username.gm
set /p pass=<password.gm
echo ======================LOGIN======================
set /p login=Username : 

if %login% == %user% goto password
goto login
:password
cls
echo ======================LOGIN======================
set /p passw=Password : 

if %passw% == %pass% goto game && title GAME
goto password

:newuser
cd gamedata
cls
batbox /c 0x80 /d "%date% %time%"
batbox /g 0 1
echo Make a user:
batbox /g 0 5 /d "Password: "
batbox /g 0 3
set /p user=Username: 

echo %user%> username.gm
goto newpass

:newpass
color 0f
cd gamedata
cls
batbox /c 0x80 /d "%date% %time%"
batbox /g 0 1
echo Make a user:
batbox /g 0 3 /d "Username: %user%"
batbox /g 0 5
set /p pass=Password: 

echo %pass%> password.gm
goto charectarselect

:charectarselect
cd gamedata
color 0f
cls
batbox /g 0 0
echo Select class:
echo.
echo %mage%
echo %worrior%
set /p classes=Class: 

if "%classes%" == "1" echo %mage%>pclass.gm
if "%classes%" == "2" echo %worrior%>pclass.gm
batbox /c 0x0f
goto login

:: ###############GAME##############

:game
color 0f
batbox /c 0x0f
cls
SET /A test=%RANDOM% * 3 / 32768 + 1
set /a m1=%random% * 10 / 32768 + 1
set /a mh=%random% * 20 / 32768 + 5
set /a rph=%random% * 20 / 32768 + 5
set /a pd=%random% * 15 / 32768 + 1
goto display

:: ###############DISPLAY##############

:display
color 0f
batbox /c 0x0f
cls
batbox /c 0xc9 /d "Health: %health%"
batbox /g 11 0 /c 0x9c /d "Strength: %strength%"
batbox /g 3 2 /c 0x89 /d "%test%"
goto mechanics

:: ###############MECHANICS##############

:mechanics
cls
set /a health-=%m1%
set /a mh-=%pd%
if %mh% lss 1 set /a health+=%rph% && goto game
if %health% lss 1 goto shop
pause >nul
goto game


:shop
cls
pause

我现在发布了整个代码,是的 好吧,问题是我的idk ..我已经改变了所有颜色,但我仍然得到一个灰色的背景,我无法看到%health% %strength%pclass%

的文字

0 个答案:

没有答案