此时 goto 出乎意料 {BATCH}

goto Was Unexpected At This Time {BATCH}

我正在尝试批量制作一个简单的投币游戏。我遇到的问题是一旦延迟完成 (ping) "goto was unexpected at this time" 就是我在 window 关闭之前得到的所有信息。如有任何帮助,我们将不胜感激!

@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

你忘记了 %coins% 中的 s :

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