1

プログラムの「ハイスコア」セクションにアクセスすると、スコア自体が保存され、保存されたすべてのスコアが呼び出されるハイスコアオプションをメモリゲームに提供しようとしています。これまでのコードは次のとおりです。

@echo off
REM Produced by Calder Hutchins
REM This is a game
title Memory Game
:begin
set point=0
cls
echo.
echo Memeory Game
echo ------------------
echo 1) Play
echo 2) Instructions
echo 3) High Scores
echo ------------------
set /p pick=^>
if %pick%==1 goto one
if %pick%==2 goto two
if %pick%==3 goto three
goto begin
:one
cls
REM Determines the number
if %point% LSS 6  set /a rand=%random% %% (100 - 1 + 1)+ 1
if %point% LSS 12 if %point% GTR 5 set /a rand=%random% %% (500 - 100 + 1)+ 100
if %point% LSS 18 if %point% GTR 11 set /a rand=%random% %% (1000 - 500 + 1)+ 500
if %point% LSS 24 if %point% GTR 17 set /a rand=%random% %% (2000 - 1000 + 1)+ 1000
if %point% LSS 30 if %point% GTR 23 set /a rand=%random% %% (9000 - 1500 + 1)+ 1500
if %point% LSS 36 if %point% GTR 29 set /a rand=%random% %% (19000 - 5000 + 1)+ 5000
if %point% LSS 42 if %point% GTR 35 set /a rand=%random% %% (32000 - 10000 + 1)+ 10000
if %point% LSS 48 if %point% GTR 41 set /a rand=%random% %% (999 - 100 + 1)+ 100
if %point% LSS 48 if %point% GTR 41 set /a randtwo=%random% %% (999 - 100 + 1)+ 100
if %point% GTR 47 set /a rand=%random% %% (9999 - 1000 + 1)+ 1000
if %point% GTR 47 set /a randtwo=%random% %% (9999 - 1000 + 1)+ 1000
echo.
REM  Prints the number  
if %point% LSS 42 echo %rand% 
if %point% GTR 41 set rand=%rand%%randtwo%
if %point% GTR 41 echo %rand%
echo.
ping localhost -n 3 >nul
cls
echo.
echo.
echo.
set /p yourOption=Guess:
REM Determines correct or wrong
if %youroption%==%rand% set /a point=%point% +1 & goto one
cls
echo.
echo You scored: %point%
echo.
set /p name=Type name:
echo %name%  -  %point% >> E:\Scripts\Batch\memoryGame\score.txt
goto begin
:two
cls
echo. 
echo The objective of the game is to get as many points as possible.  To get points you must correctly retype the numbers that appear on the screen.  The numbers show for a short period of time.  As you get more points the numbers get longer!  When you have lost you will be prompted to enter your name.  You can view the highscores too!  
echo. 
pause
goto begin
:three
cls
echo.
sort E:\Scripts\Batch\memoryGame\score.txt
echo.
pause
goto begin

上記はファイルに保存するだけですが、可能であれば内部に保存したいです。変更したスクリプトを受け取りましたが、ゲームに実装する方法が見つかりません。スクリプトのコードは次のとおりです。

@echo off
for /f "tokens=1 delims=:" %%D in ('findstr /R /N "storedData" "%~f0"' ) do set end_batch=%%D
echo Make data

echo echo data entry 4^>^>"%~f0"
echo(>>"%~f0"
echo data entry ^4>>"%~f0"

echo Print Data
type "%~f0" | more +%end_batch%
exit /b 0


:storedData

どうすればそれを機能させることができるかについて何か提案はありますか?

4

2 に答える 2

2

うーん..以前の回答よりも良いアイデアがあります-代替データストリーム(NTFSでのみ機能します):

    echo You scored: %point%
    echo.
    set /p name=Type name:
    echo %name%  -  %point% >>"%~f0:scores"
    goto begin
    :two
    cls
    echo. 
    echo The objective of the game is to get as many points as possible.  To get points you must correctly retype the numbers that appear on the screen.  The numbers show for a short period of time.  As you get more points the numbers get longer!  When you have lost you will be prompted to enter your name.  You can view the highscores too!  
    echo. 
    pause
    goto begin
    :three
   cls
   echo.
   more<"%~f0:scores" | sort
   echo.
   pause
   goto begin

しかし、これは文字通りのソートになります...

編集:

@echo off
REM Produced by Calder Hutchins
REM This is a game
title Memory Game
:begin
set point=0
cls
echo.
echo Memeory Game
echo ------------------
echo 1) Play
echo 2) Instructions
echo 3) High Scores
echo ------------------
set /p pick=^>
if %pick%==1 goto one
if %pick%==2 goto two
if %pick%==3 goto three
goto begin
:one
cls
REM Determines the number
if %point% LSS 6  set /a rand=%random% %% (100 - 1 + 1)+ 1
if %point% LSS 12 if %point% GTR 5 set /a rand=%random% %% (500 - 100 + 1)+ 100
if %point% LSS 18 if %point% GTR 11 set /a rand=%random% %% (1000 - 500 + 1)+ 500
if %point% LSS 24 if %point% GTR 17 set /a rand=%random% %% (2000 - 1000 + 1)+ 1000
if %point% LSS 30 if %point% GTR 23 set /a rand=%random% %% (9000 - 1500 + 1)+ 1500
if %point% LSS 36 if %point% GTR 29 set /a rand=%random% %% (19000 - 5000 + 1)+ 5000
if %point% LSS 42 if %point% GTR 35 set /a rand=%random% %% (32000 - 10000 + 1)+ 10000
if %point% LSS 48 if %point% GTR 41 set /a rand=%random% %% (999 - 100 + 1)+ 100
if %point% LSS 48 if %point% GTR 41 set /a randtwo=%random% %% (999 - 100 + 1)+ 100
if %point% GTR 47 set /a rand=%random% %% (9999 - 1000 + 1)+ 1000
if %point% GTR 47 set /a randtwo=%random% %% (9999 - 1000 + 1)+ 1000
echo.
REM  Prints the number  
if %point% LSS 42 echo %rand% 
if %point% GTR 41 set rand=%rand%%randtwo%
if %point% GTR 41 echo %rand%
echo.
ping localhost -n 3 >nul
cls
echo.
echo.
echo.
set /p yourOption=Guess:
REM Determines correct or wrong
if %youroption%==%rand% set /a point=%point% +1 & goto one
cls
echo.
echo You scored: %point%
echo.
set /p name=Type name:
echo %name%  -  %point% >>"%~f0:scores"
goto begin
:two
cls
echo. 
echo The objective of the game is to get as many points as possible.  To get points you must correctly retype the numbers that appear on the screen.  The numbers show for a short period of time.  As you get more points the numbers get longer!  When you have lost you will be prompted to enter your name.  You can view the highscores too!  
echo. 
pause
goto begin
:three
cls
echo.
more<"%~f0:scores" | sort
echo.
pause
goto begin
于 2013-05-27T20:12:15.450 に答える
2

以下のバッチ ファイルは、まさにあなたが要求したことを実行します。つまり、プログラムの「ハイ スコア」セクションにアクセスすると、スコア自体が保存され、保存されているすべてのスコアが呼び出されます。

echo You scored: %point%
echo.
set /p name=Type name:
echo %name%  -  %point% >> "%~F0"
goto begin
:two
cls
echo. 
echo The objective of the game is to get as many points as possible.  To get points you must correctly retype the numbers that appear on the screen.  The numbers show for a short period of time.  As you get more points the numbers get longer!  When you have lost you will be prompted to enter your name.  You can view the highscores too!  
echo. 
pause
goto begin
:three
cls
echo.
for /F "delims=:" %%n in ('findstr /N "^:savedScores" "%~F0"') do set n=%%n
more +%n% "%~F0" | sort
echo.
pause
goto begin
:savedScores
于 2013-05-28T00:25:57.663 に答える