gpt4 book ai didi

windows-7 - Goto此时出乎意料批处理windows 7 starter

转载 作者:行者123 更新时间:2023-12-03 18:33:17 26 4
gpt4 key购买 nike

此代码旨在类似于 Pokemon 战斗游戏玩法的更简单版本。我只在攻击中编码。我一直在进行彻底的测试,发现每当用户确认他们的攻击时都会出现一条错误消息(此时 Goto 是意外的)。警告!!代码长 96 行。最后,我会放上问题部分,所以你可以跳过这第一大块。

@echo off
Set H1=20
Set A1=8
Set D1=6
Set S1=5
Set H2=14
Set A2=5
Set D2=4
Set S2=8
:Begin
CLS
Echo Bulbasur
Echo %H2%/14 /\
Echo (__) ___
Echo l __lo.ol
Echo l_\ l_\"
Echo.
Echo _
Echo * / \
Echo \\l )
Echo \\__l Charmander
Echo %H1%/20
Echo -Attack -Capture
Echo -Item -Run
Set /p Move=Action?
If %move%==Attack goto Attack
If %move%==Catpure goto capture
If %move%==Item goto Item
If %move%==Run Goto Run
Echo I'm sorry, Charmander can't do that.
Pause
goto Begin
:Attack
ClS
Echo Attacks
Echo 1)Tackle
Echo 2)Growl
Echo 3)Ember
Echo 4)Scratch
Set /p attack=Which one?
If %attack%==Tackle goto Tackle
If %attack%==1 goto Tackle
If %attack%==Growl Goto Growl
If %attack%==2 goto Growl
If %attack%==Ember goto Ember
If %attack%==3 goto Ember
If %attack%==Scratch goto Scratch
If %attack%==4 goto Scratch
If %attack%==Cancel goto Begin
Echo I didn't get that
Goto Attack
:Tackle
CLS
Echo Tackle Hits The opponent where it hurts. EVERYWHERE.
Echo Do you want to?
set /p accept=Yes/No?
If %acccept%==Yes goto Combat
If %acccept%==No goto Begin
Echo I didn't get that.
goto Tackle
:Growl
CLS
Echo Growl lowers the opponents attack.
Echo Do you want to?
set /p accept=Yes/No?
If %acccept%==Yes goto Status
If %acccept%==No goto Begin
Echo I didn't get that.
goto Growl
:Scratch
CLS
Echo Scratch hits the foe with a claw.
Echo Do you want to?
set /p accept=Yes/No?
If %acccept%==Yes goto Combat
If %acccept%==No goto Begin
Echo I didn't get that.
goto Scratch
:Ember
CLS
Echo Ember hits the opponent with a small fire.
Echo Do you want to?
set /p accept=Yes/No?
If %acccept%==Yes goto Combat
If %acccept%==No goto Begin
Echo I didn't get that.
goto Ember
:Combat
CLS
If NOT %attack%==Growl If NOT %attack%==2 set /a H2=%H2%-(%A1%^2/%D2%)
set /a H1=%H1%-(%A2%^2/%D1%)
goto Begin
:Status
CLS
Set /a A1=%A1%-1
goto Combat

问题区域:
:Tackle
CLS
Echo Tackle Hits The opponent where it hurts. EVERYWHERE.
Echo Do you want to?
set /p accept=Yes/No?
If %acccept%==Yes goto Combat
If %acccept%==No goto Begin
Echo I didn't get that.
goto Tackle

代码在这里很好,但是一旦我在这里,它就不会期望 goto 命令。谁能修好这块牛肉? (注意:Tackle 只是一个例子。所有攻击都不起作用。) 编辑:如果用户输入"is"、“否”、胡言乱语或什么都不做,它仍然会提供相同的错误消息(此时 goto 是意外的)

最佳答案

你必须把它放在引号中:

if "%accept%"=="yes" goto combat
if "%accept%"=="no" goto begin

或者更确切地说,如果您不想区分大小写:
if /i "%accept%"=="yes" goto combat
if /i "%accept%"=="no" goto begin

关于windows-7 - Goto此时出乎意料批处理windows 7 starter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9775644/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com