简体   繁体   English

goto目前无法预料{BATCH}

[英]goto Was Unexpected At This Time {BATCH}

Im am trying to make a simple coin game in batch. 我正在尝试批量制作一个简单的硬币游戏。 The problem I have is once the delay is completed (ping) "goto was unexpected at this time" is all I get before the window closes. 我的问题是,一旦延迟完成(ping),“我在这时出人意料”就关了窗口。 Any help would be appreciated! 任何帮助,将不胜感激!

@echo off
color f0
title Nim In Batch

::: Main Menu
:main
set /a coins=12
set /a time=0
cls
echo Nim In Batch!
echo.
choice /n /c pr /m "Play Or See Rules?"
if %errorlevel%==1 (
    goto play
)
if %errorlevel%==2 (
    goto rules
)

::: Rules
:rules
cls
echo Objective: Be the one to claim the last coin
echo.
echo Rules: 
echo      -You Play First
echo      -You Must Remove 1,2 Or 3 Coins Each Turn
echo      -Turns Switch Once Coins Are Removed
echo      -Coins Must Be Removed In Order
echo.
echo Ready?
pause>nul
goto main


::: Game
:play
cls
echo (%coins%) Coins
echo.
choice /n /c 123 /m "How Many Coins Do You Wish To Remove?"
if %errorlevel%==1 (
    set /a Coins=%coins%-1
)
if %errorlevel%==2 (
    set /a Coins=%coins%-2
)
if %errorlevel%==3 (
    set /a Coins=%coins%-3
)

cls
echo (%coins%) Coins
echo.
echo Computer Is Thinking
ping 1.1.1.1 -n 1 -w 3250 >NUL
if %errorlevel%==1 (
    set /a Coins=%coins%-3
)
if %errorlevel%==2 (
    set /a Coins=%coins%-2
)
if %errorlevel%==3 (
    set /a Coins=%coins%-1
    )

if %coin%==0 (
    goto end
) else (
    goto play
)


:end
cls
echo Computer Wins! 
echo He Collected The Final Coin!
echo.
pause
goto main

You forget an s in %coin s % here : 你忘了一个s在这里%硬币S%:

if %coins%==0 (
    goto end
) else (
    goto play
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM