2017-10-12 9 views
0

좋아, 이제 배치 게임을 만들었고 지금은 자습서를 통해 작성 중입니다. 내 계획은 % 롤 % 이상 내 코드입니다 멀리 %enhealth%뭔가를 입력 할 때 예상치 못한 일괄 처리 프로그램

:foresttutorial 
cls 
echo. 
echo __________________________ 
echo |       | 
echo | An enemy appeared!  | 
echo | Enemy health: %enhealth% | 
echo | Your health: %yourhealth%| 
echo |       | 
echo | 1. ATK 2. USE POT  | 
echo | 3. GOLD 4. PASS  | 
echo | _________________________| 
echo. 
echo Here appears an attack screen! 
echo Quick, press 1 and enter! 
set /p choice8 
if %choice8% == 1 goto atkforesttutorial1 else goto invalidforesttutorial1 

:invalidforesttutorial1 
cls 
echo Invalid answer. You can try the other options soon, 
echo for now just press 1. 
pause 
goto foresttutorial 

:atkforesttutorial1 
set /a roll=(%random% %% 7) + 1 
set enhealth = %enhealth% - %roll% 
echo You attacked the enemy! 
echo. 
echo __________________________ 
echo |       | 
echo | An enemy appeared!  | 
echo | Enemy health: %enhealth% | 
echo | Your health: %yourhealth%| 
echo |       | 
echo | 1. ATK 2. USE POT  | 
echo | 3. GOLD 4. PASS  | 
echo | _________________________| 
echo. 
pause 

%yourhealth%을 복용

set /a roll=(%random% %% 7) + 1 

가능하게하는 것입니다. 첫 번째 상자에 1을 입력하고 Enter를 클릭하면 "1 was unexpected ..."또는 비슷한 것을 나타내는 플래시가 나타납니다. 이 문제를 해결하는 방법에 대한 아이디어가 있습니까? 여기 전체 코드 : https://pastebin.com/kBNgNV1G

+0

'|... '배치의 특수 문자가 그것을 사용하지 마십시오 | – SomethingDark

+0

재미를 (또는 사용하는'^ 당신이 절대적으로 그것을 사용해야하는 경우'), 아무런 문제가 내가 실행하지 않을 때 코드, 때 1을 입력하십시오 :/ – spokify

+0

안녕하세요, 귀하의 도움을 주셔서 감사합니다. 비록 코드를 수정하지 못했습니다, 그것은 코드를 디버깅하는 데 도움이되었습니다. 편집 : 신경 쓰지 마라, 다른 버그를 발견하고^| 나를 도와 주었다. 감사. – spokify

답변

0

내가 약간 변경 한 일부는, * (주로 반복 최소화하기 위해 입력 선택을위한 Choice /CCall :label의 사용 당신이 일을하는 다른 방법을 볼 수 있도록 다른의 희망입니다 수정은 echo'd 텍스트

@Echo Off 
If /I Not "%CD%"=="directoryForscreed" CD /D "directoryForscreed" 2>Nul||Exit/B 
For %%A In ("premenupicture" "dice" "atkmenusample" "mainmenuforscreed" 
) Do If Not Exist "%%A.txt" Exit/B 
Title Forscreed 
Color 07 
Mode 80,25 

:premenu 
Echo= 
Type premenupicture.txt 
Echo= 
Choice /C 123 /M "Please type in your choice number: " 
If ErrorLevel 3 GoTo credits 
If ErrorLevel 2 GoTo loadgame 
If ErrorLevel 1 GoTo newgame 
ClS 
GoTo premenu 

:newgame 
Set/A "key=chest=level=rank=gold=playwon=playloss=enwon=enloss=dice=prestige=0" 
Set/A "atk=def=int=vit=1" 
Set "health=100" 

:prologue 
ClS 
Echo Wake up.. 
Timeout 2 /NoBreak>Nul 
ClS 
Echo Wake up! 
Timeout 2 /NoBreak>Nul 
ClS 
Call :prologEcho 
Choice /C 1234 
If ErrorLevel 4 GoTo tutorialfinish1 
If ErrorLevel 3 GoTo caveprologue 
If ErrorLevel 2 GoTo scavengeprologue 
If ErrorLevel 1 GoTo prologueboat 
GoTo prologue 

:prologueboat 
ClS 
Call :prologueboatEcho 
Choice /C 1234 
If ErrorLevel 4 GoTo prologue 
If ErrorLevel 3 GoTo prologuemast 
If ErrorLevel 2 GoTo prologuecaptaincabin 
If ErrorLevel 1 GoTo prologuedeck 
GoTo prologueboat 

:prologuedeck 
ClS 
Echo The deck is empty, except for a satchel. You reach inside and find a Rusty 
Echo Pistol and equip it. You walk out off the deck. 
Timeout -1 

:prologueboat2 
ClS 
Call :prologueboatEcho 
Choice /C 1234 
If ErrorLevel 4 GoTo prologue 
If ErrorLevel 3 GoTo prologuemast 
If ErrorLevel 2 GoTo prologuecaptaincabin 
If ErrorLevel 1 GoTo prologuedeck2 
GoTo prologueboat2 

:prologuedeck2 
ClS 
Echo Nothing here! 
Timeout -1 
GoTo prologueboat2 

:prologuecaptaincabin 
ClS 
Echo The captain's cabin is tiny. Cramped up, you walk into the room. There is a 
Echo bag of gold, a magazine for a pistol, and an old pair of boots. You walk out 
Echo of the captain's cabin. 
Timeout -1 

:prologueboat3 
ClS 
Call :prologueboatEcho 
Choice /C 1234 
If ErrorLevel 4 GoTo prologue 
If ErrorLevel 3 GoTo prologuemast 
If ErrorLevel 2 GoTo prologuecaptaincabin2 
If ErrorLevel 1 GoTo prologuedeck2 
GoTo prologueboat3 

:prologuecaptaincabin2 
ClS 
Echo Nothing here! 
Timeout -1 
GoTo prologueboat3 

:prologuemast 
ClS 
Echo You climb up the mast. Nothing here! You can use the ropes though, so you 
Echo take it off. 
Timeout -1 

:prologueboat4 
ClS 
Call :prologueboatEcho 
Choice /C 1234 
If ErrorLevel 4 GoTo prologue 
If ErrorLevel 3 GoTo prologuemast2 
If ErrorLevel 2 GoTo prologuecaptaincabin2 
If ErrorLevel 1 GoTo prologuedeck2 
GoTo prologueboat4 

:scavengeprologue 
ClS 
Echo A dice appeared! What do you do with it? Shrugging, you put it in your pocket. 
Echo (You can't scavenge anymore after this until you finish the tutorial!) 
Set/A dice+=1 
Timeout -1 

:prologue2 
ClS 
Call :prologEcho 
Choice /C 1234 
If ErrorLevel 4 GoTo tutorialfinish1 
If ErrorLevel 3 GoTo caveprologue 
If ErrorLevel 2 GoTo scavengeprologue2 
If ErrorLevel 1 GoTo prologueboat 
GoTo prologue2 

:scavengeprologue2 
ClS 
Echo Can't scavenge in the tutorial! Complete the tutorial first, then you can 
Echo scavenge again. 
Timeout -1 
GoTo prologue2 

:caveprologue 
Cls 
Echo You walk to the cave and find a warm fire lit up. How was it lit? You don't 
Echo know. You quickly scramble to near the fire for warmth, satisfied. 
Timeout -1 
GoTo prologue 

:tutorialfinish1 
ClS 
Echo You pull out what you found from your pockets. A rusty gun, a magazine for 
the gun, and a dice. I wonder what the dice does? 
Timeout -1 
ClS 
Echo The dice rolls in your hand, and you accidentally drop it. It glows golden! 
Timeout -1 
ClS 
Timeout 1 /NoBreak>Nul 
Type dice.txt 
Echo= 
Echo Rolling a 7-sided die... 
Timeout 2 /NoBreak>Nul 
Set/A roll=(%random% %% 7) + 1 
Echo You landed a %roll%! 
Timeout -1 
ClS 
Echo Your objective is to build up a boat to go find the artifacts which end the 
Echo game. The game is frequently updated, so check on the website for more quests 
Echo and islands, plus new artifacts. The main playing style is fighting, 
Echo equipping, trading, buying, leveling, and surviving as best as you can. 
Timeout -1 
ClS 
Type atkmenusample.txt 
Echo This is what you'll get upon questing or fighting in the woods! Monsters drop 
Echo food, which is what you need to survive. You lose health every time do you a 
Echo task, an estimated 0.712 health taken. You can regain the health with food. To 
Echo fight, you will normally type in 1 and attack. The golden dice will do 
Echo everything for you! The formula consists of your strength, weapons, and the 
Echo dice rolled. 
Timeout -1 
ClS 
Echo Then, the enemy takes his turn to attack! The computer will calculate all of 
Echo this for you, and deal in the damage. Press 2 to use a health potion, and 
Echo press 3 to your gold. If you're feeling it, you can also pass your turn, 
Echo allowing the enemy to go. Other that fighting, the game is really mainly about 
Echo a mystery storyline, which often requires equipment, gold, and equipment from 
Echo quests. You can level up tools this way too. One of the special things about 
Echo Forscreed is that there are no "different" swords. It simply levels up your 
Echo swords to deal more damage. 
Timeout -1 
ClS 
Echo Let's give attacking a try! 
Echo Travel to the main menu: 
Timeout -1 

:mainmenututorial 
ClS 
Echo Here we are, at the tutorial. When this tutorial ends, it should look a bit 
Echo like this: 
Echo= 
Type mainmenuforscreed.txt 
Echo= 
Echo Above is the main menu. You're going to want to attack, so let's hit 1. 
Choice /C 1 
If Not Errorlevel 1 goto invalidmainmenututorial1 
GoTo foresttutorial 

:invalidmainmenututorial1 
ClS 
Echo Invalid answer. You can try the other options soon, for now just press 1. 
Timeout -1 
GoTo mainmenututorial 

:foresttutorial 
ClS 
Echo= 
Echo __________________________ 
Echo ^|       ^| 
Echo ^| An enemy appeared! ^| 
Echo ^| Enemy health: %enhealth% ^| 
Echo ^| Your health: %yourhealth%^| 
Echo ^|       ^| 
Echo ^| 1. ATK 2. USE POT ^| 
Echo ^| 3. GOLD 4. PASS  ^| 
Echo ^| _________________________^| 
Echo= 
Echo Here appears an attack screen! Quick, press 1! 
Choice /C 1 
If Not ErrorLevel 1 GoTo invalidforesttutorial1 
GoTo atkforesttutorial1 

:invalidforesttutorial1 
ClS 
Echo Invalid answer. You can try the other options soon, or now just press 1. 
Timeout -1 
GoTo foresttutorial 

:atkforesttutorial1 
ClS 
Set/A roll=(%random% %% 7) + 1 
Set/A enhealth-=roll 
Echo You attacked the enemy! 
Echo= 
Echo __________________________ 
Echo ^|       ^| 
Echo ^| An enemy appeared! ^| 
Echo ^| Enemy health: %enhealth% ^| 
Echo ^| Your health: %yourhealth%^| 
Echo ^|       ^| 
Echo ^| 1. ATK 2. USE POT ^| 
Echo ^| 3. GOLD 4. PASS  ^| 
Echo ^| _________________________^| 
Echo= 
Timeout -1 

Exit/B 

:prologEcho 
Echo The sea is glimmering.. A broken boat seems to have crashed against a huge 
Echo wooden rod. A spiritual tomb of some sort! You remember now. The Queen of 
Echo Walkers sent you on a mission to save the kingdom by finding an artifact on 
Echo the other side of the world, but you faced a storm and crashed into this 
Echo wooden tomb. 
Echo= 
Echo Night is falling quick, what will you do? 
Echo 1. Go to the boat. 
Echo 2. Scavenge for resources. 
Echo 3. Look around that cave nearby, looks fishy. 
Echo 4. I already did all of these. 
GoTo :EOF 

:prologueboatEcho 
Echo You walk to the boat. It's broken at the side, so it can't be used. The 
Echo material is also weak. It's been thrashed by heavy waves and can't sail. 
Echo Where do you search on the boat? 
Echo 1. The deck 
Echo 2. The captain's cabin 
Echo 3. The mast 
Echo 4. Get off boat 
GoTo :EOF 
+0

고맙습니다. 선택 시스템을 그대로 사용하려면 선택/c를 사용하게 될지 잘 모르겠습니다. 하지만 해결책을 가져 주셔서 감사합니다. – spokify