Pr0gramer

Golpea La Rata (Batch)

Apr 19th, 2014
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Winbatch 13.52 KB | None | 0 0
  1. @echo off
  2. mode con cols=80 lines=30
  3. if /i "%1"=="Attrib" (
  4. goto checkhighscore.txt
  5. )
  6. if /i "%1"=="Countermode" (
  7. goto countermode
  8. )
  9. title Golpea La Rata
  10. setlocal enabledelayedexpansion
  11. for %%I in (%0) do set filename=%%~sI
  12. if exist highscore-%username%.txt (
  13. start /MIN CMD.exe /c "%FILENAME% Attrib"
  14. )
  15. if exist rat-game-info_%username%.dat del rat-game-info_%username%.dat
  16. :menu
  17. title Golpea La Rata -Hecho Por DarkSight
  18. cls
  19. echo Menu Principal
  20. echo ---------
  21. echo.
  22. echo Ingresa 1, Para jugar.
  23. echo Ingresa 2, Para ver las instrucciones.
  24. echo Ingresa 3, Para ver el marcador de puntajes.
  25. echo Ingresa 4, Para salir.
  26. echo.
  27. set menu=
  28. set /p menu=Numero:
  29. if not defined menu goto menu
  30. if %menu%==1 goto startgame
  31. if %menu%==2 goto instructions
  32. if %menu%==3 goto Displayscores
  33. if %menu%==4 exit
  34. goto menu
  35. :checkhighscore.txt
  36. attrib highscore-%username%.txt | find "SHR" >nul
  37. if %errorlevel%==0 (exit)
  38. attrib highscore-%username%.txt +S +H +R
  39. exit
  40. :instructions
  41. cls
  42. echo Golpea La Rata
  43. echo -------------
  44. echo El objetivo del juego es golpear la rata con su bate en cuanto
  45. echo sale de su agujero. Puedes tratar de golpear la rata
  46. echo con el tiempo de reaccion mas rapido, o golpear tantas ratas en una fila como
  47. echo sea posible. Su puntuacion se registra en el mismo directorio que el juego.
  48. echo.
  49. echo.
  50. echo Presiona cualquier tecla para ver la siguiente pagina.
  51. pause >nul
  52. cls
  53. echo Golpea La Rata
  54. echo -------------
  55. echo Tan pronto como empiece el juego aparecera una ventana adicional, titulada
  56. echo 'Rat Window' esta ventana muestra la actividad de la rata. Tan pronto
  57. echo como aparezca la ventana hay que arrastrarla fuera de la ventana original
  58. echo Para que puedas ver las 2 ventanas simultaneamente. Debes dar click en
  59. echo la ventana titulada 'Golpea La Rata' para poder continuar.
  60. echo.
  61. echo.
  62. echo Presiona cualquier tecla para ver la siguiente pagina.
  63. pause>nul
  64. cls
  65. echo Golpea La Rata
  66. echo -------------
  67. echo Para golpear la rata, manten seleccionada la ventana titulada 'Golpea La Rata'
  68. echo y presiona cualquier tecla tan pronto veas que aparece la rata
  69. echo en la ventana titulada 'Rat Window'
  70. echo.
  71. echo.
  72. echo Presiona cualquier tecla para volver al menu principal.
  73. pause>nul
  74. goto menu
  75. :displayscores
  76. cls
  77. if not exist highscore-%username%.txt (
  78. echo Aun no hay puntajes.
  79. echo.
  80. echo Presiona cualquier tecla para volver al menu.
  81. pause>nul
  82. goto menu
  83. )
  84. find /i "Reaccion-Mas-Rapida=" highscore-%username%.txt >nul
  85. set count=%errorlevel%
  86. find /i "Mas-Ratas-Golpeadas=" highscore-%username%.txt >nul
  87. set /a count= %count% + %errorlevel%
  88. find /i "Mejor-Promedio-De-Reaccion=" highscore-%username%.txt >nul
  89. set /a count= %count% + %errorlevel%
  90. if %count%==3 (
  91. echo Record del archivo incorreco
  92. echo.
  93. echo Presiona cualquier tecla para volver al menu.
  94. pause>nul
  95. goto menu
  96. )
  97. echo Marcador de Puntajes
  98. echo -----------
  99. echo.
  100. type highscore-%username%.txt | find /i "Reaccion-Mas-Rapida"
  101. type highscore-%username%.txt | find /i "Mas-Ratas-Golpeadas"
  102. type highscore-%username%.txt | find /i "Mejor-Promedio-De-Reaccion"
  103. echo.
  104. echo.
  105. echo Presiona cualquier tecla para volver al menu.
  106. pause>nul
  107. goto menu
  108. :startgame
  109. title Golpea La Rata -Hecho Por DarkSight
  110. cls
  111. set fastestreaction=999
  112. set SN=0
  113. set totalmil=0
  114. set offset=10
  115. echo nul >rat-game-info_%username%.dat
  116. start cmd /c "%filename% Countermode"
  117. Echo Mueve la ventana 'Rat Window' de manera que puedas ver ambas
  118. echo ventanas, luego clickea esta ventana.
  119. echo.
  120. echo Presiona cualquier tecla para empezar el juego.
  121. pause>nul
  122. echo START >rat-game-info_%username%.dat
  123. cls
  124. echo Presiona cualquier tecla para batear.
  125. Pause>nul
  126. set swingtime=%time:~2%
  127. echo Y%SN%-%swingtime% >>rat-game-info_%username%.dat
  128. :result
  129. find /i "w%SN%" rat-game-info_%username%.dat >nul
  130. if %errorlevel%==0 (
  131. cls
  132. set /a sn= %SN% + 1
  133. goto Swingagain
  134. )
  135. find /i "l" rat-game-info_%username%.dat >nul
  136. if %errorlevel%==0 (
  137. cls
  138. echo Game Over
  139. goto gotresult
  140. )
  141. goto result
  142. :swingagain
  143. echo Bueno Golpe!
  144. if %sn%==1 (
  145. echo Haz conseguido 1 rata hasta el momento.
  146. ) else (
  147. echo Haz conseguido %sn% ratas hasta el momento.
  148. )
  149. :processreactiontime
  150. if %sn% geq 11 set offset=11
  151. if %sn% geq 101 set offset=12
  152. set x=1
  153. for /f %%A in (rat-game-info_%username%.dat) do set data=%%A & call :Setswingtime
  154. set x=1
  155. for /f %%A in (rat-game-info_%username%.dat) do set data=%%A & call :Setfalltime
  156. set /a CFN= ( %sn% * 3 ) - 1
  157. set /a CSN= %sn% * 3
  158. set truefalltime=!falltime%CFN%!
  159. set truefalltime=!truefalltime:~%offset%,2!
  160. set trueswingtime=!swingtime%CSN%!
  161. set trueswingtime=!trueswingtime:~%offset%,2!
  162. if /i %trueswingtime%==08 (
  163. set trueswingtime=8
  164. )
  165. if /i %trueswingtime%==09 (
  166. set trueswingtime=9
  167. )
  168. if /i %truefalltime%==08 (
  169. set truefalltime=8
  170. )
  171. if /i %truefalltime%==09 (
  172. set truefalltime=9
  173. )
  174. set /a reactionmil= %trueswingtime% - %truefalltime%
  175. if /i %reactionmil% lss 0 (
  176. set /a reactionmil= %reactionmil% + 100
  177. )
  178. if /i %reactionmil% leq 9 (
  179. echo Tu tiempo de reaccion fue 0.0%reactionmil% Segundos
  180. ) else (
  181. echo Tu tiempo de reaccion fue 0.%reactionmil% Segundos
  182. )
  183. goto continueswingagain
  184. :setswingtime
  185. set Swingtime%x%=%data%
  186. set /a x= %x% + 1
  187. exit /b
  188. :setfalltime
  189. set falltime%x%=%data%
  190. set /a x= %x% + 1
  191. exit /b
  192. :continueswingagain
  193. echo.
  194. echo Presiona cualquier tecla para batear.
  195. pause>nul
  196. set swingtime=%time:~2%
  197. echo Y%SN%-%swingtime% >>rat-game-info_%username%.dat
  198. set /a totalmil= %totalmil% + %reactionmil%
  199. if not defined fastestreaction (set fastestreaction=%reactionmil%)
  200. if /i %fastestreaction% gtr %reactionmil% (
  201. set fastestreaction=%reactionmil%
  202. )
  203. goto result
  204. :Gotresult
  205. if %sn% equ 0 (
  206. echo Lo siento, No le diste a ninguna rata.
  207. goto moreresults
  208. )
  209. if %sn% equ 1 (
  210. echo Lo siento, solo conseguiste darle a una rata.
  211. goto Moreresults
  212. )
  213. if /i %sn% leq 3 (
  214. echo Lo siento, solo conseguiste %sn% ratas
  215. ) else (
  216. echo Bien Hecho!, le diste a %sn% ratas
  217. )
  218. :moreresults
  219. find /i rat-game-info_%username%.dat "LL" >nul
  220. if /i %errorlevel% equ 0 (
  221. Echo En esa ultima, te haz tardado mucho, la rata se ha ido.
  222. ) else (
  223. echo En esa ultima, bateaste mucho antes.
  224. )
  225. IF %sn%==0 goto end
  226. :processrats
  227. set /a averagetime= %totalmil% / %sn%
  228. echo Haz conseguido %sn% ratas
  229. echo Tu tiempo de reaccion promedio fue 0.%averagetime% segundos
  230. if /i %fastestreaction% leq 9 (
  231. echo Tu tiempo de reaccion fue 0.0%fastestreaction% Segundos
  232. ) else (
  233. echo Tu tiempo de reaccion fue 0.%fastestreaction% Segundos
  234. )
  235. if not exist highscore-%username%.txt goto noscorelist
  236. goto scorelistexists
  237. :noscorelist
  238. set most=1
  239. set best=1
  240. set fastest=1
  241. goto changescore
  242. :scorelistexists
  243. set most=
  244. set fastest=
  245. set best=
  246. find /i "Mas-Ratas-Golpeadas" highscore-%username%.txt >nul
  247. if /i NOT %errorlevel% equ 0 (
  248. set Most=1
  249. )
  250. find /i "Reaccion-Mas-Rapida" highscore-%username%.txt >nul
  251. if /i NOT %errorlevel% equ 0 (
  252. set Fastest=1
  253. )
  254. find /i "Mejor-Promedio-De-Reaccion" highscore-%username%.txt >nul
  255. if /i NOT %errorlevel% equ 0 (
  256. set Best=1
  257. )
  258. goto Mustcompare
  259. :Mustcompare
  260. for /f %%A in (highscore-%username%.txt) do set data=%%A & call :RHset
  261. set sorted=
  262. for /f %%A in (highscore-%username%.txt) do set data=%%A & call :BAset
  263. set sorted=
  264. for /f %%A in (highscore-%username%.txt) do set data=%%A & call :FRset
  265. set sorted=
  266. set oldRH=%oldRH:~20%
  267. set oldBA=%oldBA:~30,2%
  268. set oldFR=%oldFR:~32,2%
  269. goto comparetime
  270. :rhset
  271. set variable=OldRH
  272. set keyword=Most
  273. call :sortvariables
  274. exit /b
  275. :baset
  276. set variable=OldBA
  277. set keyword=Best
  278. call :sortvariables
  279. exit /b
  280. :frset
  281. set variable=OldFR
  282. set keyword=Fastest
  283. call :sortvariables
  284. exit /b
  285. :sortvariables
  286. if defined sorted (goto endsortvariables)
  287. set %variable%=%data%
  288. echo !%variable%! | find /i "%keyword%" >nul
  289. if NOT errorlevel 1 (
  290. set sorted=1
  291. ) else (
  292. set %variable%=
  293. )
  294. :endsortvariables
  295. exit /b
  296. :comparetime
  297. if defined fastest goto alreadyfastest
  298. if /i %fastestreaction% lss %oldfr% (
  299. set fastest=1
  300. )
  301. :alreadyfastest
  302. if defined Most goto alreadymost
  303. if /i %oldRH% lss %SN% (
  304. set Most=1
  305. )
  306. :alreadymost
  307. if defined best goto alreadybest
  308. if /i %averagetime% lss %OldBA% (
  309. set Best=1
  310. )
  311. :alreadybest
  312. if defined best goto Changescore
  313. if defined most goto Changescore
  314. if defined fastest goto Changescore
  315. goto end
  316. :changescore
  317. echo.
  318. Echo Nuevo Puntaje Alto!
  319. echo ---------------
  320. echo Nueva puntuacion En:
  321. echo.
  322. if defined most (
  323. echo Mas Ratas Golpeadas
  324. )
  325. if defined best (
  326. echo Mejor Tiempo Promedio
  327. )
  328. if defined fastest (
  329. echo Reaccion Individual Mas Rapida
  330. )
  331. echo.
  332. set initials=
  333. echo Porfavor Introduce Tus Iniciales (Maximo 3 Caracteres)
  334. echo.
  335. set /p initials=""
  336. IF NOT defined initials (
  337. cls
  338. goto changescore
  339. )
  340. if "%initials:~1%"=="" (
  341. set initials=%initials%--
  342. )
  343. if "%initials:~2%"=="" (
  344. set initials=%initials%-
  345. )
  346. set initials=%initials:~0,3%
  347. if defined most goto editmost
  348. goto checkeditbest
  349. :editmost
  350. if /i %fastestreaction% leq 9 (
  351. set fastestreaction=0%fastestreaction%
  352. )
  353. if exist highscore-%username%.txt (
  354. type highscore-%username%.txt | find /i /v "Mas-Ratas-Golpeadas" >Highscore
  355. attrib highscore-%username%.txt -s -h -r
  356. type highscore >highscore-%username%.txt
  357. attrib highscore-%username%.txt +s +h +r
  358. del highscore
  359. attrib highscore-%username%.txt -s -h -r
  360. echo %initials%---Mas-Ratas-Golpeadas=%sn% >>highscore-%username%.txt
  361. attrib highscore-%username%.txt +s +h +r
  362. ) else (
  363. echo %initials%---Mas-Ratas-Golpeadas=%sn% >>highscore-%username%.txt
  364. attrib highscore-%username%.txt +s +h +r
  365. )
  366. :checkeditbest
  367. if defined best goto editbest
  368. goto checkeditfastest
  369. :editbest
  370. if exist highscore-%username%.txt (
  371. type highscore-%username%.txt | find /i /v "Mejor-Promedio-De-Reaccion" >Highscore
  372. attrib highscore-%username%.txt -s -h -r
  373. type highscore >highscore-%username%.txt
  374. attrib highscore-%username%.txt +s +h +r
  375. del highscore
  376. attrib highscore-%username%.txt -s -h -r
  377. echo %initials%---Mejor-Promedio-De-Reaccion=0.%averagetime% >>highscore-%username%.txt
  378. attrib highscore-%username%.txt +s +h +r
  379. ) else (
  380. echo %initials%---Mejor-Promedio-De-Reaccion=0.%averagetime% >>highscore-%username%.txt
  381. attrib highscore-%username%.txt +s +h +r
  382. )
  383. :checkeditfastest
  384. if defined fastest goto editfastest
  385. goto scoresedited
  386. :editfastest
  387. if exist highscore-%username%.txt (
  388. type highscore-%username%.txt | find /i /v "Reaccion-Mas-Rapida" >Highscore
  389. attrib highscore-%username%.txt -s -h -r
  390. type highscore >highscore-%username%.txt
  391. attrib highscore-%username%.txt +s +h +r
  392. del highscore
  393. attrib highscore-%username%.txt -s -h -r
  394. echo %initials%---Reaccion-Mas-Rapida=0.%fastestreaction% >>highscore-%username%.txt
  395. attrib highscore-%username%.txt +s +h +r
  396. ) else (
  397. echo %initials%---Reaccion-Mas-Rapida=0.%fastestreaction% >>highscore-%username%.txt
  398. attrib highscore-%username%.txt +s +h +r
  399. )
  400. :Scoresedited
  401. echo Puntajes Guardados
  402. echo.
  403. goto end
  404. :end
  405. del rat-game-info_%username%.dat
  406. ping localhost -n 1 >nul
  407. echo.
  408. :playagain
  409. echo Volver al Menu? (S/N)
  410. :playagain1
  411. set choice=
  412. set /p choice=""
  413. if /i "%choice:~0,1%"=="S" (
  414. goto menu
  415. )
  416. if /i "%choice:~0,1%"=="N" (
  417. exit
  418. )
  419. goto playagain
  420. ::###################################################################
  421. :COUNTERMODE
  422. @echo off
  423. mode con cols=60 lines=25
  424. color f0
  425. title Rat Window -Hecho Por DarkSight
  426. setlocal enabledelayedexpansion
  427. echo Mueve esta ventana de manera que puedas ver
  428. echo ambas ventanillas.
  429. echo Clickea la ventana titulada 'Golpea La Rata'.
  430. :waittostart
  431. type rat-game-info_%username%.dat | find /i "start" >nul
  432. if %errorlevel%==0 (goto TimeTostart) else (goto waittostart)
  433. :TimeToStart
  434. set timestart=%time:~2%
  435. echo X%timestart% >rat-game-info_%username%.dat
  436. set SN=-1
  437. set w=0
  438. cls
  439. goto timesetup
  440. :1
  441. find rat-game-info_%username%.dat "Y%sn%" >nul
  442. if %errorlevel%==0 goto stop
  443. if /i %time:~6,2% equ %timechange% goto ShowRat
  444. goto noRats
  445. :ShowRat
  446. set ztime%sn%=Z%sn%-%time:~2%
  447. cls
  448. call :showrat
  449. set w=1
  450. set timechange=CHANGE_DONE
  451. echo !ztime%sn%! >>rat-game-info_%username%.dat
  452. :noRats
  453. if /i %time:~6,2% equ %timeback% (
  454. cls
  455. call :norat
  456. echo.
  457. echo Haz perdido la rata!
  458. echo Batea para terminar el juego
  459. set w=0
  460. set timeback=CHANGE_DONE
  461. set L=L
  462. )
  463. goto 1
  464. :STOP
  465. if /i %w%==1 (
  466. echo W%sn% >>rat-game-info_%username%.dat
  467. ) else (
  468. echo L%L% >>rat-game-info_%username%.dat
  469. exit /b
  470. )
  471. :Timesetup
  472. cls
  473. call :norat
  474. set w=0
  475. set /a sn= %sn% + 1
  476. set timestart=%time:~2%
  477. set timechange=%timestart:~4,2%
  478. if /i %timechange% equ 08 (set timechange=8)
  479. if /i %timechange% equ 09 (set timechange=9)
  480. set /a timechange= %timechange% + 2 + %random:~1,1%
  481. if %timechange% geq 60 (
  482. set /a timechange= %timechange% - 60
  483. )
  484. set /a timeback= %timechange% + 1
  485. if %timeback% geq 60 (
  486. set /a timeback=%timeback% - 60
  487. )
  488. if /i %timechange% equ 8 (
  489. set timechange=08
  490. )
  491. if /i %timechange% equ 9 (
  492. set timechange=09
  493. )
  494. if /i %timeback% equ 8 (
  495. set timeback=08
  496. )
  497. if /i %timeback% equ 9 (
  498. set timeback=09
  499. )
  500. goto 1
  501. :NORAT
  502. echo __ __ __ __ __ __ __ __ __
  503. echo [__][__][__][__][__][__][__][__][__]
  504. echo _][__][__][__][__][__][__][__][__][_
  505. echo [__][__][__][__][__][__][__][__][__]
  506. echo _][__][__][__][__][__][__][__][__][_
  507. echo [__][__][__][__][__][__][__][__][__]
  508. echo _][__][__][__][__][__][__][__][__][_
  509. echo [__][__][__][__][__][__][__][__][__]
  510. echo ____________________________________
  511. exit /b
  512. :showrat
  513. echo __ __ __ __ __ __ __ __ __
  514. echo [__][__][__][__][__][__][__][__][__]
  515. echo _][__][__][__][__][__][__][__][__][_
  516. echo [__][__][__] __ __ _][__][__][__]
  517. echo _][__][__] (_.)__(._) __][__][__][_
  518. echo [__][__][__] (- -) _][__][__][__]
  519. echo _][__][__][ --{()}-- [__][__][__][_
  520. echo [__][__][__] (____) _][__][__][__]
  521. echo ______________''__''________________
  522. exit /b
  523. :close
  524. exit
Advertisement
Add Comment
Please, Sign In to add comment