【发布时间】:2012-04-04 06:16:32
【问题描述】:
此代码旨在类似于口袋妖怪战斗游戏的更简单版本。我只编写了攻击代码。我一直在进行彻底的测试,发现每当用户确认他们的攻击时都会出现错误消息(此时 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 只是一个示例。所有攻击都不起作用。) 编辑:如果用户输入“是”、“否”、胡言乱语或什么都不输入,它仍然会传递相同的错误消息(此时 goto 是意外的)
【问题讨论】:
-
我对否决票很好奇; asker 发布了代码,挑出了一个示例问题区域,甚至给出了错误消息。对我来说似乎是个好问题。只是对批处理文件不屑一顾吗?这不应该影响问题的好坏。
-
@WesleyPetrowski,可能是因为他发布了他的整个剧本。然后发布了有问题的代码的附加副本。他应该只发布有问题的代码。
-
If %move%==Catpure goto capture我知道那只猫是纯洁的,但我认为这是一个错字^^
标签: windows-7 batch-file goto