我知道这个问题是主观的,但有人可以帮忙吗?我确定这是一个非常愚蠢的问题,很容易修复。
如果您在批处理文件中保存并运行此代码,并且在创建名称后,如果您尝试购买多个项目,则游戏将关闭。我不知道它是否必须处理变量名称。我在这里有一些游戏的示例代码:
title Hack Wars by Geeketek
color 0a
@echo off
:new
set mon=500
set mas=1
set mult=1
set pop=0
set prot=100
set maxprot=100
set pc=None
set av=None
set ht=None
cls
echo What's your name?
echo.
set /p name=Enter:
goto main
:shop
cls
echo HACK WARS - SHOP
echo ----------------------------------------
echo %name% Money: $%mon%
echo ----------------------------------------
echo.
echo PCs: (currently using %pc%)
echo 1a) Blarqu 13 $200 Mastery: 1
echo 1b) Lonevo Power $600 Mastery: 3
echo 1c) Ledd v2 $1200 Mastery: 6
echo.
echo Antiviruses: (currently using %av%)
echo 2a) NoVi Basic $100 Mastery: 1
echo 2b) GetSecure $500 Mastery: 3
echo 2c) Master Pro $1000 Mastery: 7
echo.
echo Hacking Tools: (currently using %ht%)
echo 3a) DDOSer $100 Mastery: 1
echo 3b) Cracker $600 Mastery: 3
echo 3c) Hack Pro $1100 Mastery: 7
echo.
echo 4) Back
echo.
set /p choice=Enter:
if %choice% == 4 goto main
if %choice% == 1a (
if %mon% LSS 200 goto nofunds
set mon= %mon% - 200
set pc=Blarqu 13
goto purchase
)
if %choice% == 1b (
if %mon% LSS 600 goto nofunds
set mon= %mon% - 600
set pc=Lonevo Power
goto purchase
)
if %choice% == 1c (
if %mon% LSS 1200 goto nofunds
set mon= %mon% - 1200
set pc=Ledd v2
goto purchase
)
if %choice% == 2a (
if %mon% LSS 100 goto nofunds
set mon= %mon% - 100
set av=NoVi Basic
set maxprot=100
set prot=100
goto purchase
)
if %choice% == 2b (
if %mon% LSS 500 goto nofunds
set mon= %mon% - 500
set av=GetSecure
set maxprot=150
set prot=150
goto purchase
)
if %choice% == 2c (
if %mon% LSS 1000 goto nofunds
set mon= %mon% - 1000
set av=Master Pro
set maxprot=200
set prot=200
goto purchase
)
if %choice% == 3a (
if %mon% LSS 100 goto nofunds
set mon= %mon% - 100
set ht=DDOSer
set maxprot=200
set prot=200
goto purchase
)
if %choice% == 3b (
if %mon% LSS 600 goto nofunds
set mon= %mon% - 600
set ht=Cracker
set maxprot=200
set prot=200
goto purchase
)
if %choice% == 3c (
if %mon% LSS 1100 goto nofunds
set mon= %mon% - 1100
set ht=Hack Pro
set maxprot=200
set prot=200
goto purchase
)
goto shop
:nofunds
cls
echo You don't have enough money
echo to purchase this item.
pause >nul
goto shop
:nomas
cls
echo Your mastery isn't high enough
echo to purchase this item.
pause >nul
goto shop
:purchase
cls
echo Thank you for your purchase.
pause >nul
goto shop
答案 0 :(得分:-1)
我将所有数值变量更改为设置/ a并解决了问题。