Pr0gramer icon

Golpea La Rata (Batch)

Pr0gramer | PRO | 04/20/14 01:55:46 AM UTC | 0 ⭐ | 264 👁️ | Never ⏰ | []
Winbatch |

13.52 KB

|

None

|

0 👍

/

0 👎

@echo off
mode con cols=80 lines=30
if /i "%1"=="Attrib" (
goto checkhighscore.txt
)
if /i "%1"=="Countermode" (
goto countermode
)
title Golpea La Rata
setlocal enabledelayedexpansion
for %%I in (%0) do set filename=%%~sI
if exist highscore-%username%.txt (
start /MIN CMD.exe /c "%FILENAME% Attrib"
)
if exist rat-game-info_%username%.dat del rat-game-info_%username%.dat
:menu
title Golpea La Rata -Hecho Por DarkSight
cls
echo Menu Principal
echo ---------
echo.
echo Ingresa 1, Para jugar.
echo Ingresa 2, Para ver las instrucciones.
echo Ingresa 3, Para ver el marcador de puntajes.
echo Ingresa 4, Para salir.
echo.
set menu=
set /p menu=Numero:
if not defined menu goto menu
if %menu%==1 goto startgame
if %menu%==2 goto instructions
if %menu%==3 goto Displayscores
if %menu%==4 exit
goto menu
:checkhighscore.txt
attrib highscore-%username%.txt | find "SHR" >nul
if %errorlevel%==0 (exit)
attrib highscore-%username%.txt +S +H +R
exit
:instructions
cls
echo Golpea La Rata
echo -------------
echo El objetivo del juego es golpear la rata con su bate en cuanto
echo sale de su agujero. Puedes tratar de golpear la rata
echo con el tiempo de reaccion mas rapido, o golpear tantas ratas en una fila como
echo sea posible. Su puntuacion se registra en el mismo directorio que el juego.
echo.
echo.
echo Presiona cualquier tecla para ver la siguiente pagina.
pause >nul
cls
echo Golpea La Rata
echo -------------
echo Tan pronto como empiece el juego aparecera una ventana adicional, titulada
echo 'Rat Window' esta ventana muestra la actividad de la rata. Tan pronto
echo como aparezca la ventana hay que arrastrarla fuera de la ventana original
echo Para que puedas ver las 2 ventanas simultaneamente. Debes dar click en
echo la ventana titulada 'Golpea La Rata' para poder continuar.
echo.
echo.
echo Presiona cualquier tecla para ver la siguiente pagina.
pause>nul
cls
echo Golpea La Rata
echo -------------
echo Para golpear la rata, manten seleccionada la ventana titulada 'Golpea La Rata'
echo y presiona cualquier tecla tan pronto veas que aparece la rata
echo en la ventana titulada 'Rat Window'
echo.
echo.
echo Presiona cualquier tecla para volver al menu principal.
pause>nul
goto menu
:displayscores
cls
if not exist highscore-%username%.txt (
echo Aun no hay puntajes.
echo.
echo Presiona cualquier tecla para volver al menu.
pause>nul
goto menu
)
find /i "Reaccion-Mas-Rapida=" highscore-%username%.txt >nul
set count=%errorlevel%
find /i "Mas-Ratas-Golpeadas=" highscore-%username%.txt >nul
set /a count= %count% + %errorlevel%
find /i "Mejor-Promedio-De-Reaccion=" highscore-%username%.txt >nul
set /a count= %count% + %errorlevel%
if %count%==3 (
echo Record del archivo incorreco
echo.
echo Presiona cualquier tecla para volver al menu.
pause>nul
goto menu
)
echo Marcador de Puntajes
echo -----------
echo.
type highscore-%username%.txt | find /i "Reaccion-Mas-Rapida"
type highscore-%username%.txt | find /i "Mas-Ratas-Golpeadas"
type highscore-%username%.txt | find /i "Mejor-Promedio-De-Reaccion"
echo.
echo.
echo Presiona cualquier tecla para volver al menu.
pause>nul
goto menu
:startgame
title Golpea La Rata -Hecho Por DarkSight
cls
set fastestreaction=999
set SN=0
set totalmil=0
set offset=10
echo nul >rat-game-info_%username%.dat
start cmd /c "%filename% Countermode"
Echo Mueve la ventana 'Rat Window' de manera que puedas ver ambas
echo ventanas, luego clickea esta ventana.
echo.
echo Presiona cualquier tecla para empezar el juego.
pause>nul
echo START >rat-game-info_%username%.dat
cls
echo Presiona cualquier tecla para batear.
Pause>nul
set swingtime=%time:~2%
echo Y%SN%-%swingtime% >>rat-game-info_%username%.dat
:result
find /i "w%SN%" rat-game-info_%username%.dat >nul
if %errorlevel%==0 (
cls
set /a sn= %SN% + 1
goto Swingagain
)
find /i "l" rat-game-info_%username%.dat >nul
if %errorlevel%==0 (
cls
echo Game Over
goto gotresult
)
goto result
:swingagain
echo Bueno Golpe!
if %sn%==1 (
echo Haz conseguido 1 rata hasta el momento.
) else (
echo Haz conseguido %sn% ratas hasta el momento.
)
:processreactiontime
if %sn% geq 11 set offset=11
if %sn% geq 101 set offset=12
set x=1
for /f %%A in (rat-game-info_%username%.dat) do set data=%%A & call :Setswingtime
set x=1
for /f %%A in (rat-game-info_%username%.dat) do set data=%%A & call :Setfalltime
set /a CFN= ( %sn% * 3 ) - 1
set /a CSN= %sn% * 3
set truefalltime=!falltime%CFN%!
set truefalltime=!truefalltime:~%offset%,2!
set trueswingtime=!swingtime%CSN%!
set trueswingtime=!trueswingtime:~%offset%,2!
if /i %trueswingtime%==08 (
set trueswingtime=8
)
if /i %trueswingtime%==09 (
set trueswingtime=9
)
if /i %truefalltime%==08 (
set truefalltime=8
)
if /i %truefalltime%==09 (
set truefalltime=9
)
set /a reactionmil= %trueswingtime% - %truefalltime%
if /i %reactionmil% lss 0 (
set /a reactionmil= %reactionmil% + 100
)
if /i %reactionmil% leq 9 (
echo Tu tiempo de reaccion fue 0.0%reactionmil% Segundos
) else (
echo Tu tiempo de reaccion fue 0.%reactionmil% Segundos
)
goto continueswingagain
:setswingtime
set Swingtime%x%=%data%
set /a x= %x% + 1
exit /b
:setfalltime
set falltime%x%=%data%
set /a x= %x% + 1
exit /b
:continueswingagain
echo.
echo Presiona cualquier tecla para batear.
pause>nul
set swingtime=%time:~2%
echo Y%SN%-%swingtime% >>rat-game-info_%username%.dat
set /a totalmil= %totalmil% + %reactionmil%
if not defined fastestreaction (set fastestreaction=%reactionmil%)
if /i %fastestreaction% gtr %reactionmil% (
set fastestreaction=%reactionmil%
)
goto result
:Gotresult
if %sn% equ 0 (
echo Lo siento, No le diste a ninguna rata.
goto moreresults
)
if %sn% equ 1 (
echo Lo siento, solo conseguiste darle a una rata.
goto Moreresults
)
if /i %sn% leq 3 (
echo Lo siento, solo conseguiste %sn% ratas
) else (
echo Bien Hecho!, le diste a %sn% ratas
)
:moreresults
find /i rat-game-info_%username%.dat "LL" >nul
if /i %errorlevel% equ 0 (
Echo En esa ultima, te haz tardado mucho, la rata se ha ido.
) else (
echo En esa ultima, bateaste mucho antes.
)
IF %sn%==0 goto end
:processrats
set /a averagetime= %totalmil% / %sn%
echo Haz conseguido %sn% ratas
echo Tu tiempo de reaccion promedio fue 0.%averagetime% segundos
if /i %fastestreaction% leq 9 (
echo Tu tiempo de reaccion fue 0.0%fastestreaction% Segundos
) else (
echo Tu tiempo de reaccion fue 0.%fastestreaction% Segundos
)
if not exist highscore-%username%.txt goto noscorelist
goto scorelistexists
:noscorelist
set most=1
set best=1
set fastest=1
goto changescore
:scorelistexists
set most=
set fastest=
set best=
find /i "Mas-Ratas-Golpeadas" highscore-%username%.txt >nul
if /i NOT %errorlevel% equ 0 (
set Most=1
)
find /i "Reaccion-Mas-Rapida" highscore-%username%.txt >nul
if /i NOT %errorlevel% equ 0 (
set Fastest=1
)
find /i "Mejor-Promedio-De-Reaccion" highscore-%username%.txt >nul
if /i NOT %errorlevel% equ 0 (
set Best=1
)
goto Mustcompare
:Mustcompare
for /f %%A in (highscore-%username%.txt) do set data=%%A & call :RHset
set sorted=
for /f %%A in (highscore-%username%.txt) do set data=%%A & call :BAset
set sorted=
for /f %%A in (highscore-%username%.txt) do set data=%%A & call :FRset
set sorted=
set oldRH=%oldRH:~20%
set oldBA=%oldBA:~30,2%
set oldFR=%oldFR:~32,2%
goto comparetime
:rhset
set variable=OldRH
set keyword=Most
call :sortvariables
exit /b
:baset
set variable=OldBA
set keyword=Best
call :sortvariables
exit /b
:frset
set variable=OldFR
set keyword=Fastest
call :sortvariables
exit /b
:sortvariables
if defined sorted (goto endsortvariables)
set %variable%=%data%
echo !%variable%! | find /i "%keyword%" >nul
if NOT errorlevel 1 (
set sorted=1
) else (
set %variable%=
)
:endsortvariables
exit /b
:comparetime
if defined fastest goto alreadyfastest
if /i %fastestreaction% lss %oldfr% (
set fastest=1
)
:alreadyfastest
if defined Most goto alreadymost
if /i %oldRH% lss %SN% (
set Most=1
)
:alreadymost
if defined best goto alreadybest
if /i %averagetime% lss %OldBA% (
set Best=1
)
:alreadybest
if defined best goto Changescore
if defined most goto Changescore
if defined fastest goto Changescore
goto end
:changescore
echo.
Echo Nuevo Puntaje Alto!
echo ---------------
echo Nueva puntuacion En:
echo.
if defined most (
echo Mas Ratas Golpeadas
)
if defined best (
echo Mejor Tiempo Promedio
)
if defined fastest (
echo Reaccion Individual Mas Rapida
)
echo.
set initials=
echo Porfavor Introduce Tus Iniciales (Maximo 3 Caracteres)
echo.
set /p initials=""
IF NOT defined initials (
cls
goto changescore
)
if "%initials:~1%"=="" (
set initials=%initials%--
)
if "%initials:~2%"=="" (
set initials=%initials%-
)
set initials=%initials:~0,3%
if defined most goto editmost
goto checkeditbest
:editmost
if /i %fastestreaction% leq 9 (
set fastestreaction=0%fastestreaction%
)
if exist highscore-%username%.txt (
type highscore-%username%.txt | find /i /v "Mas-Ratas-Golpeadas" >Highscore
attrib highscore-%username%.txt -s -h -r
type highscore >highscore-%username%.txt
attrib highscore-%username%.txt +s +h +r
del highscore
attrib highscore-%username%.txt -s -h -r
echo %initials%---Mas-Ratas-Golpeadas=%sn% >>highscore-%username%.txt
attrib highscore-%username%.txt +s +h +r
) else (
echo %initials%---Mas-Ratas-Golpeadas=%sn% >>highscore-%username%.txt
attrib highscore-%username%.txt +s +h +r
)
:checkeditbest
if defined best goto editbest
goto checkeditfastest
:editbest
if exist highscore-%username%.txt (
type highscore-%username%.txt | find /i /v "Mejor-Promedio-De-Reaccion" >Highscore
attrib highscore-%username%.txt -s -h -r
type highscore >highscore-%username%.txt
attrib highscore-%username%.txt +s +h +r
del highscore
attrib highscore-%username%.txt -s -h -r
echo %initials%---Mejor-Promedio-De-Reaccion=0.%averagetime% >>highscore-%username%.txt
attrib highscore-%username%.txt +s +h +r
) else (
echo %initials%---Mejor-Promedio-De-Reaccion=0.%averagetime% >>highscore-%username%.txt
attrib highscore-%username%.txt +s +h +r
)
:checkeditfastest
if defined fastest goto editfastest
goto scoresedited
:editfastest
if exist highscore-%username%.txt (
type highscore-%username%.txt | find /i /v "Reaccion-Mas-Rapida" >Highscore
attrib highscore-%username%.txt -s -h -r
type highscore >highscore-%username%.txt
attrib highscore-%username%.txt +s +h +r
del highscore
attrib highscore-%username%.txt -s -h -r
echo %initials%---Reaccion-Mas-Rapida=0.%fastestreaction% >>highscore-%username%.txt
attrib highscore-%username%.txt +s +h +r
) else (
echo %initials%---Reaccion-Mas-Rapida=0.%fastestreaction% >>highscore-%username%.txt
attrib highscore-%username%.txt +s +h +r
)
:Scoresedited
echo Puntajes Guardados
echo.
goto end
:end
del rat-game-info_%username%.dat
ping localhost -n 1 >nul
echo.
:playagain
echo Volver al Menu? (S/N)
:playagain1
set choice=
set /p choice=""
if /i "%choice:~0,1%"=="S" (
goto menu
)
if /i "%choice:~0,1%"=="N" (
exit
)
goto playagain
::###################################################################
:COUNTERMODE
@echo off
mode con cols=60 lines=25
color f0
title Rat Window -Hecho Por DarkSight
setlocal enabledelayedexpansion
echo Mueve esta ventana de manera que puedas ver
echo ambas ventanillas.
echo Clickea la ventana titulada 'Golpea La Rata'.
:waittostart
type rat-game-info_%username%.dat | find /i "start" >nul
if %errorlevel%==0 (goto TimeTostart) else (goto waittostart)
:TimeToStart
set timestart=%time:~2%
echo X%timestart% >rat-game-info_%username%.dat
set SN=-1
set w=0
cls
goto timesetup
:1
find rat-game-info_%username%.dat "Y%sn%" >nul
if %errorlevel%==0 goto stop
if /i %time:~6,2% equ %timechange% goto ShowRat
goto noRats
:ShowRat
set ztime%sn%=Z%sn%-%time:~2%
cls
call :showrat
set w=1
set timechange=CHANGE_DONE
echo !ztime%sn%! >>rat-game-info_%username%.dat
:noRats
if /i %time:~6,2% equ %timeback% (
cls
call :norat
echo.
echo Haz perdido la rata!
echo Batea para terminar el juego
set w=0
set timeback=CHANGE_DONE
set L=L
)
goto 1
:STOP
if /i %w%==1 (
echo W%sn% >>rat-game-info_%username%.dat
) else (
echo L%L% >>rat-game-info_%username%.dat
exit /b
)
:Timesetup
cls
call :norat
set w=0
set /a sn= %sn% + 1
set timestart=%time:~2%
set timechange=%timestart:~4,2%
if /i %timechange% equ 08 (set timechange=8)
if /i %timechange% equ 09 (set timechange=9)
set /a timechange= %timechange% + 2 + %random:~1,1%
if %timechange% geq 60 (
set /a timechange= %timechange% - 60
)
set /a timeback= %timechange% + 1
if %timeback% geq 60 (
set /a timeback=%timeback% - 60
)
if /i %timechange% equ 8 (
set timechange=08
)
if /i %timechange% equ 9 (
set timechange=09
)
if /i %timeback% equ 8 (
set timeback=08
)
if /i %timeback% equ 9 (
set timeback=09
)
goto 1
:NORAT
echo __ __ __ __ __ __ __ __ __
echo [__][__][__][__][__][__][__][__][__] 
echo _][__][__][__][__][__][__][__][__][_
echo [__][__][__][__][__][__][__][__][__] 
echo _][__][__][__][__][__][__][__][__][_
echo [__][__][__][__][__][__][__][__][__] 
echo _][__][__][__][__][__][__][__][__][_
echo [__][__][__][__][__][__][__][__][__] 
echo ____________________________________
exit /b
:showrat
echo __ __ __ __ __ __ __ __ __
echo [__][__][__][__][__][__][__][__][__] 
echo _][__][__][__][__][__][__][__][__][_
echo [__][__][__] __ __ _][__][__][__] 
echo _][__][__] (_.)__(._) __][__][__][_
echo [__][__][__] (- -) _][__][__][__] 
echo _][__][__][ --{()}-- [__][__][__][_
echo [__][__][__] (____) _][__][__][__] 
echo ______________''__''________________
exit /b
:close
exit

Comments