我不知道你们是否对批次有任何了解(我敢肯定有人知道),但是关于这篇文章,我正在尝试创建一个愚蠢的DND Assist(您会告诉您统计信息的内容)比起掷骰子和自己做数学,这将帮助您更快地完成一个动作。 目前,我有一些随机数生成器可以工作(尽管我想对其进行改进)
此版本设置为选择1到20之间的随机数,我想找出一种方法来通知程序,如果您投掷1或20(暴击/暴击失败)
以后我还需要一些东西来告诉我如何将某些值保存为变量,
@echo off
:Start
Set /a ans="%RANDOM% %% 20"+1
echo %ans%
pause
goto Start
(关于保存变量,当程序运行时,它会告诉我我缺少操作。)
上色部分只是为了解决问题,如果有人可以向我展示一种简化该部分的方法,请告诉我们。
请使用lamens术语,我仍然不太善于理解这些内容。
(当前协助程序进度)
@echo off
cls
:BEGIN
Echo HI THERE! AND WELCOME TO MY GAME!!
Echo Lets begin by setting your prefered color!
:A
set choice=
set /p choice= RED, WHITE, OR BLUE?!?
if not '%choice%'=='' set '%choice%'=='Red, White, Blue'
if '%choice%'=='RED' goto RED
if '%choice%'=='WHITE' goto WHITE
if '%choice%'=='BLUE' goto BLUE
if '%choice%'=='Red' goto RED
if '%choice%'=='White' goto WHITE
if '%choice%'=='Blue' goto BLUE
if '%choice%'=='red' goto RED
if '%choice%'=='white' goto WHITE
if '%choice%'=='blue' goto BLUE
if '%choice%'=='9' goto 1Bs
echo "%choice%" is not a good color bro, do a different one
goto A
:RED
color 4
goto START SCREEN
:WHITE
color 7
goto START SCREEN
:BLUE
color 1
goto START SCREEN
:START SCREEN
cls
TITLE CHOOSER GAME BOI
Echo ---THE DND GAME---
echo Welcome to the DND game, we will first choose your Attributes
echo Strength (How hard you hit) (STR)
echo Constitution (Your health) (CNST)
echo Knowledge (Better Rolls against Vendors and Questions) (KNLG)
echo Dexterity (Your chances of dodging and Hitting) (DXT)
echo You have a total of 10 points to apply to each Attribute
echo Your points HAVE to equal 10 otherwise you will have to restart
:ATTRSET
set MXPNTS=10
set choice=
set /p STR= STR (1-10)
set choice=
set /p CNST= CNST (1-10)
set CNST=CNST
set choice=
set /p KNLG= KNLG (1-10)
set KNLG=KNLG
set choice=
set /p DXT= DXT (1-10)
set DXT=DXT
set /a ATTRTTL=STR+CNST+KNLG+DXT
echo ATTRTTL
if NOT ATTRTTL=MXPNTS goto ATTRSET
if ATTRTTL=MXPNTS goto testyay
pause
:testyay
pause
答案 0 :(得分:0)
我个人建议:
@echo off
cls
:begin
echo HI THERE! AND WELCOME TO MY GAME!!
echo Lets begin by setting your preferred color!
:a
set /p choice= RED, WHITE, OR BLUE?!?
if "%choice%" == "" (
echo Please enter something!
cls
goto :A
)
for %%A IN (red white blue) do if /I "%choice%" == "%%A" (call :%%A & goto :start_screen)
if "%choice%" == "9" (goto 1Bs)
echo "%choice%" is not a good color bro, do a different one.
goto :a
:red
color 4
exit /b
:white
color 7
exit /b
:blue
color 1
exit /b
:start_screen
cls
title CHOOSER GAME BOI
echo ---THE DND GAME---
echo Welcome to the DND game, we will first choose your Attributes
echo Strength (How hard you hit) (STR)
echo Constitution (Your health) (CNST)
echo Knowledge (Better Rolls against Vendors and Questions) (KNLG)
echo Dexterity (Your chances of dodging and Hitting) (DXT)
echo You have a total of 10 points to apply to each Attribute
echo Your points HAVE to equal 10 otherwise you will have to restart
:ATTRSET
set "mxpnts=10"
set /p "str=STR (1-10) "
set /p "cnst=CNST (1-10) "
set /p "knlg=KNLG (1-10) "
set /p "dxt=DXT (1-10) "
set /a "attrttl=str+cnst+knlg+dxt"
echo %ATTRTTL%
if not "%attrttl%" == "%mxpnts%" (goto :attrset) else (goto :testyay)
pause
:testyay
pause
choice
变量的全部内容。只是一个for
循环遍历颜色词并检查(不区分大小写)用户输入是red
,white
还是blue
。call
子例程,而不是使用goto
子例程来保存一些行-我通常在我的程序中这样做:您已经放置了3个单独的命令goto START SCREEN
,可以简化它们call
进入子程序(这意味着goto
,然后返回),然后goto
到您想要的位置。start_screen
。仅此而已,请遵循Squashman的出色建议并在注释中阅读cmd中某些命令的帮助,键入command /?
,您应该会很好。