Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Batch Game] Rock, Paper, Scissor by Hack0pz
#1
I made this game a few days ago.

Source

Code:
@echo off
title RPS by Hackopz
color a
MODE CON COLS=400 LINES=90

echo %time%
echo   .                                                              
echo                                                            MMM.      MMM      
echo           MM                                               MMM.     MMMM      
echo          MMMD-MMM                                          MMMM .   MMM8      
echo          MMMD-MMM                                          ,MMM     MMM.      
echo      MMMZMMMD-MMM                                          .MMM8   NMMM        
echo      MMMZMMMD-MMM.MMM                                       MMMM   MMMM.      
echo      MMMZMMMD-MMM-MMM                  .                    OMMM. .MMM7        
echo      MMMZMMMD-MMM-MM$                 ..MMM  $..             .MMMM.,MMM.        
echo      MMMZMMMD-MMM-MMM               MMM.MMM.MMM.              MMMM.MMMM .      
echo      MMMZMMMD-MMM~MMM               MMM.MMM.MMM.MM .         OMMM.MM~M:MMM 7D  
echo .MMM.MMMZMMMD-MMM-MMM          -MMM.MMM.MMM.MMM.MMM         .MM:.-MMMMMMM7MMM.
echo  MMM.MMMMMMMD-NMM-MMM          MMMMiMMMiMMM.MMM.MMM          NMMMMMMMMMMMMMMM.
echo  MMMM.MMMMMMMNMMMMMMMM       .DMMMMiMMM.MMM.MMM.MMM        ..MMMNMMM7 MMMMMMMM.
echo  MMMM.MMMMMMNMMMMMMMMM        MMMMiiMMM.MMM.MMM.MMM.        .MMMMM7 MM MMMD MM .
echo  MMMM.MMMMNMMMMMMMMMMM       .MMMMii.MMM~MM8.MMZ8MOM.       .MMMMM.MMNMNDMM MMMI.
echo  MMMM:MMMNMMMMMMMMMMMM        MMMMMZZN.MMM.MMMMMMMMM         MMMMMM.MMMMMMMMMMMI
echo  DMMMMMNMMMMMMMMMMMMMM        .MMMMMMMMM..MMMMMMMMMM         MMMMMMM.MMMNMMMMMMI
echo  MMMMMMMMMMMMMMMMMMMM         MMMMMMMM.MMM:MMMMMMMM          MMMMMMM.MMMMMMMMMI
echo  .MZMMMMMMMMMMMMMMMMM          MMMMMMMMMMMIMMMMMMMM         .MMMMMMMMMMMMMNMMMI
echo  .-MMMMMMMMMMMMMMMMMM         ..MMMMMMMMMMMMMMMMMM          .MMMMMMMMMMMMMMMM  
echo   ..MMMMMMMMMMMMMMMM:            MMMMMMMMMMMMMMMM..        ...MMMMMMMMMMMMMMN.
echo    .MMMMMMMMMMMMMMM             ..MMMMMMMMMMMMM              .MMMMMMMMMMMMM.  
echo       _DMMMMMMMM_                   DMMMMMMMZ .               ..ZMMMMMMMO. .  
echo .
ping -n 3 localhost > nul                                            
echo .
echo .
echo             .
echo      _  _  _  _     _  _  _  _      _  _  _  _    
echo     (_)(_)(_)(_) _ (_)(_)(_)(_)_  _(_)(_)(_)(_)_  
echo     (_)         (_)(_)        (_)(_)          (_)  
echo     (_) _  _  _ (_)(_) _  _  _(_)(_)_  _  _  _    
echo     (_)(_)(_)(_)   (_)(_)(_)(_)    (_)(_)(_)(_)_  
echo     (_)   (_) _    (_)            _           (_)  
echo     (_)      (_) _ (_)           (_)_  _  _  _(_)  
echo     (_)         (_)(_)             (_)(_)(_)(_)    
echo  .    
ping -n 3 localhost > nul                                            
echo                                                       ________              
echo                                                      `MMMMMMMb.            
echo                                                       MM    `Mb            
echo                                                       MM     MM ____    ___
echo                                                       MM    .M9 `MM(    )M'
echo                                                       MMMMMMM(   `Mb    d'  
echo                                                       MM    `Mb   YM.  ,P  
echo                                                       MM     MM    MM  M    
echo                                                       MM     MM    `Mbd'    
echo                                                       MM    .M9     YMP    
echo                                                      _MMMMMMM9'      M      
echo                                                                      d'      
echo                                                                  (8),P      
echo                                                                    YMM
ping -n 3 localhost > nul                                                  
echo ____    ____                  ___                                  
echo `MM'    `MM'                  `MM                                  
echo  MM      MM                    MM                                  
echo  MM      MM    ___     ____    MM   __   _____  __ ____   _________
echo  MM      MM  6MMMMb   6MMMMb.  MM   d'  6MMMMMb `M6MMMMb  MMMMMMMMP
echo  MMMMMMMMMM 8M'  `Mb 6M'   Mb  MM  d'  6M'   `Mb MM'  `Mb /    dMP  
echo  MM      MM     ,oMM MM        MM d'   MM     MM MM    MM     dMP  
echo  MM      MM ,6MM9'MM MM        MMdM.   MM     MM MM    MM    dMP    
echo  MM      MM MM'   MM MM        MMPYM.  MM     MM MM    MM   dMP    
echo  MM      MM MM.  ,MM YM.   d9  MM  YM. YM.   ,M9 MM.  ,M9  dMP    /
echo _MM_    _MM_`YMMM9'Yb.YMMMM9  _MM_  YM._YMMMMM9  MMYMMM9  dMMMMMMMM
echo                                                  MM                
echo                                                  MM                
echo                                                 _MM_                
pause
cls

set loc="C:\Users\%username%\Documents\Hackopz\save.bat"
set loca="C:\Users\%username%\Documents\Hackopz\"
if exist %loca% goto intro
CD "C:\Users\%username%\Documents\Hackopz\"

:intro
cls
echo               _  _  _  _     _  _  _  _      _  _  _  _    
echo              (_)(_)(_)(_) _ (_)(_)(_)(_)_  _(_)(_)(_)(_)_  
echo              (_)         (_)(_)        (_)(_)          (_)  
echo              (_) _  _  _ (_)(_) _  _  _(_)(_)_  _  _  _    
echo              (_)(_)(_)(_)   (_)(_)(_)(_)    (_)(_)(_)(_)_  
echo              (_)   (_) _    (_)            _           (_)  
echo              (_)      (_) _ (_)           (_)_  _  _  _(_)  
echo              (_)         (_)(_)             (_)(_)(_)(_)    
echo        +----------------------------------------------------------+
echo        +---------------------- BY HACKOPZ ------------------------+

if exist %loc% echo Type 1 to continue from the last time.
echo Type 2 to start new.
echo ----------+-------------------------

set /p do=
if %do%==1 goto save
if %do%==2 goto begin
Echo Invelid Input!
goto intro

:save

call %loc%
goto begin

:begin
cls
echo set w=%w%>%loc%
echo set l=%l%>>%loc%
echo set t=%t%>>%loc%
:cont
echo               _  _  _  _     _  _  _  _      _  _  _  _    
echo              (_)(_)(_)(_) _ (_)(_)(_)(_)_  _(_)(_)(_)(_)_  
echo              (_)         (_)(_)        (_)(_)          (_)  
echo              (_) _  _  _ (_)(_) _  _  _(_)(_)_  _  _  _    
echo              (_)(_)(_)(_)   (_)(_)(_)(_)    (_)(_)(_)(_)_  
echo              (_)   (_) _    (_)            _           (_)  
echo              (_)      (_) _ (_)           (_)_  _  _  _(_)  
echo              (_)         (_)(_)             (_)(_)(_)(_)    
echo        +----------------------------------------------------------+
echo        +---------------------- BY HACKOPZ ------------------------+
echo        +----------------------------------------------------------+
echo ++++++++                                                          +
echo ++++++++                                                          +
echo + wins=%w%
echo + Loose=%l%                                                      
echo + ties=%t%                                                        
echo +  
echo +++++++-= Press "r" to chose rock
echo +++++++== Press "p" to chose Paper
echo +++++++=- Press "s" to chose Scissor
echo +++++
echo +++
echo +
echo Please select you choise:
set /p chose=
if /i %chose%==r (
echo You have chosen Rock..
ping -n 2 localhost > nul
goto :rock)

if /i %chose%==p (
echo You have chosen Paper..
ping -n 2 localhost > nul
goto paper)

if /i %chose%==s (
echo You have chosen Scissor..
ping -n 2 localhost > nul
goto Scissor)

echo Invelid code!
goto :begin


:rock
cls
echo You have chosen Rock..
ping -n 2 localhost > nul
echo                     +777777$
echo                  7IIIII77777Z
echo                $7IIII7$$Z8$$7$$:
echo              +7III7I7ZOD8Z88O$$ZZ,
echo Z$Z$$$ZZZZ$7IIIIII77$ZZZZZ$777$$$
echo :II77777777777777I77$OONO88Z$$$$$7
echo :77777I7777I777777$$ZOM$O$$ZZ$$$@
echo :7777IIII77I777777$$OOMD8$$77$77$,
echo :777777I7777777777ZZZ$$Z$ZO$777I.
echo :7777777II777777$$$77ZO$77I7I77,
echo :77777777777777777777Z$OZ77777$
echo :-~::~~+77I77I77777778$$II77$
echo                    IIO$77I
echo .
echo                                                 .
echo .
echo ..
echo ...
echo Computer chosing...
ping -n 2 localhost > nul

set /a com=%random% %% 9 + 1

if %com%==3 (
echo Computer choses Scissor,
ping -n 3 localhost>nul
goto :win)

if %com%==6 (
echo Computer choses Scissor,
ping -n 3 localhost>nul
goto :win)

if %com%==9 (
echo Computer choses Scissor,
ping -n 3 localhost>nul
goto :win)

if %com%==1 (
echo Computer choses Rock,
ping -n 3 localhost>nul
goto :tie )

if %com%==4 (
echo Computer choses Rock,
ping -n 3 localhost>nul
goto :tie )

if %com%==7 (
echo Computer choses Rock,
ping -n 3 localhost>nul
goto :tie )

if %com%==5 (
Echo Computer choses paper,
ping -n 3 localhost>nul
goto :lose )

if %com%==2 (
Echo Computer choses paper,
ping -n 3 localhost>nul
goto :lose )

if %com%==8 (
Echo Computer choses paper,
ping -n 3 localhost>nul
goto :lose )

:paper
cls
echo You have chosen Paper..
ping =n 2 localhost > nul
echo                         =$
echo                         $ZZ
echo                       7$$ZZ
echo                      $$$$Z+
echo                    $77$ZZ,
echo                 ~77I77$$
echo               -7II777$+
echo              $IIII7$ZI
echo             $7III77$77Z$$7$777
echo $-~::III7777j8777II777777I$7777777+7777
echo 77777777$$$7II77777$$7777777I7777777$$777$I77
echo 777777777777I77777$$$777777777777777$$77$77777II777
echo 77777I777777777777$$77777777777$OZZZZZ$$$$$$7$7777I77
echo 777I77777777777$$$$$77777I77777777777777$$ZZ$$$77I77777
echo 7777I7I777$$7777$$77II77777I7777$7777$7$$$Z$7777777777
echo 77777777I7I777777IIIII7IIIII777Z$$$ZO8OZ7ZOOZ777777
echo 777777I77777777IIIIIIIIIIII7777777777777$$777I777
echo          I7I7777II7II7IIIII78$77-ZZO8OI77777
echo            +7I7III7IIIII777I7II7II77777777
echo                ~7III7IIIIIIIIIIIIII-77
echo .
echo ..
echo ...
echo Computer chosing...
ping -n 2 localhost > nul

set /a com=%random% %% 9 + 1

if %com%==2 ( echo Computer Choses Paper.
ping -n 3 localhost>nul
Goto :tie)

if %com%==5 ( echo Computer Choses Paper.
ping -n 3 localhost>nul
Goto :tie)

if %com%==8 ( echo Computer Choses Paper.
ping -n 3 localhost>nul
Goto :tie)

if %com%==1 ( echo Computer Choses Rock.
ping -n 3 localhost>nul
goto :win)

if %com%==4 ( echo Computer Choses Rock.
ping -n 3 localhost>nul
goto :win)

if %com%==7 ( echo Computer Choses Rock.
ping -n 3 localhost>nul
goto :win)

if %com%==3 ( echo Computer Choses Scissor.
ping -n 3 localhost>nul
goto :lose )

if %com%==6 ( echo Computer Choses Scissor.
ping -n 3 localhost>nul
goto :lose )

if %com%==9 ( echo Computer Choses Scissor.
ping -n 3 localhost>nul
goto :lose )

:scissor
cls
echo You have chosen Scissor..
ping -n 2 localhost > nul
echo                    7$7777$$$$
echo                 :7I7I777I7777ZOO$$$$$777777$7$7I7                                
echo ~,,:,,,....,~777II7I7$$$$$7$8Z777$$Z$$$Z$$$777I                                
echo I$$$$$$$$$$77IIIIIII7$8888Z$7$$O$$$$I-              
echo 777777777777$IIIIII777$O7ZNO8Z$$$                  
echo 7777777I77II777777777$ZZ8OZ$Z$7$ZZ$$~              
echo 777I77IIIIII7777777$$ZZZO7$IIIIIIIII777I7777I~      
echo 777II77I777777777777ZZ87$ZZII7$$7II7777777777$77                                
echo 77777777777$777$$$777Z$Z$IIIIII7                                        
echo I777777I7777777777777Z$OZ7777777                                                                                                
echo                7II77O$7777777,                                                
echo                                                                                                                               .
echo .
echo ..
echo ...
echo Computer chosing...
ping -n 2 localhost > nul

set /a com = %random% %% 9+1
set scissor=3

if %com%==2 ( echo Computer Choses Paper.
ping -n 3 localhost>nul
goto :win )

if %com%==5 ( echo Computer Choses Paper.
ping -n 3 localhost>nul
goto :win )

if %com%==8 ( echo Computer Choses Paper.
ping -n 3 localhost>nul
goto :win )

if %com%==1 ( echo Computer Choses Rock.
ping -n 3 localhost>nul
goto :lose )

if %com%==4 ( echo Computer Choses Rock.
ping -n 3 localhost>nul
goto :lose )

if %com%==7 ( echo Computer Choses Rock.
ping -n 3 localhost>nul
goto :lose )

if %com%==3 ( echo Computer Choses Scissor.
ping -n 3 localhost>nul
goto :tie )

if %com%==6 ( echo Computer Choses Scissor.
ping -n 3 localhost>nul
goto :tie )

if %com%==9 ( echo Computer Choses Scissor.
ping -n 3 localhost>nul
goto :tie )

:win
cls
set /a w+=1
echo ...                          .   . ..
echo  .. .                   ...  .  .  
echo    .....                   . .......  
echo   .7877-.....  ...   ...  ...~::~,.    
echo  .7I:..8..-777I-I78-~::::,...I...::..  
echo ..8I..7~7I77777-I7-~~::::::~~.:..~,..  
echo   .78.7.7I7777I8I7-~8::::::~,.8,-8...  
echo   .7IIII7I7777II$7-~8:::::~~:887$:...  
echo    .I$7..77777I7$7-~~:::::~-..87:..    
echo   ...77..77777II778-~:::::~-..:~,.    
echo    ..II..$777IIII78-~:::::~~..-,..    
echo     ..I$.,7777II778--~::::-..I:...    
echo      ..7~.I777777888--~:::-.7~        
echo        .7$.77777778----~~-:I~..        
echo         ..$7I777888---8-7O~....        
echo         ..$.7777888----8:-8....        
echo         .....I7788----8~. ..          
echo         ......77877--8,... .          
echo              ..IOO$--...              
echo              ...I8-8,...              
echo              ..88~~,~...              
echo               .88:-:::..              
echo            ...8787:,:~..              
echo            ..878--:,::-.              
echo         ....I888--~,,::~~..            
echo         ...77888~-~,,:::8~.            
echo         ..-I7888--8,,:,:88..          
echo         ...777777788----8..      
echo -------------------------------------------------------        
Echo You win!
pause
goto save

:lose
cls
color c
set /a l+=1
echo .
echo           .7MMDZNMM..                
echo        . .M777777777777lN .            
echo       .M77777777777777777~0,.          
echo     ..0777777777777777777770M..        
echo     N~777777777777777777777770.        
echo   .$7770MM~7777777777MMN777777l        
echo    077M0000M77777770l0000~77777M.      
echo   M77Z000000~777770000000M777770I.    
echo  .0770000000l7777700000000777770M.    
echo  .07777M08M777777777D~7N7777777ll.    
echo   M7777777777777777777777:777:70l:.    
echo  .l,77777777777777777777777~77:0M..    
echo  .M777777777777777777777777:777lM.    
echo   .l77777777MMMMMl77777777777700.      
echo   .Ml7777777MMMMMMMM~77777777l07      
echo    .Ml777777MMMMMMMMM777777700M.      
echo     .M0777770MMMMMMMMM77777ll:.        
echo      ..$07777MMMMMMMMM~7700M..        
echo        . D000~7777777000lM.            
echo           ..MIl00000l8N..      
Echo You lose!
pause
goto save

:tie
cls
color b
set /a t+=1
echo .
echo                 MMMMN.                
echo                  MMM.                  
echo                  ,M..                  
echo                  MMM:                  
echo                 MMMM$                  
echo                 MMMMM                  
echo                 MMMMM                  
echo                 MMMMM                  
echo                 MMMMM                  
echo                .MMMMM                  
echo                .MMMMM                  
echo                ,MMMMM                  
echo                lMMMMM                  
echo                7MMMMM                  
echo                DMMMMM                  
echo                MMMMMM.                
echo                MMMMMM                  
echo               ,MMMMMM                  
echo               .MMMMMM.                
echo               .MMMMMM.                
echo               .MMMMMM.                
echo               .MMMMMM.                
echo                MMMMMM.                
echo                .MMM:.                  
echo                  M
echo ..
echo Game tied!
ping -n 3 localhost>nul
goto save

:save
color a
cls
echo @echo off >%loc%
echo set w=%w% >>%loc%
echo set l=%l% >>%loc%
echo set t=%t% >>%loc%
goto cont

Pastebin: http://pastebin.com/PyWE0NcZ


Download(direct, so that you can have a quick download, play & give a feedback! Victoire ) : http://199.91.153.81/6edqocbdedvg/8w0mo2...oi/RPS.bat
Reply
#2
First thing:
Code:
set loc="C:\Users\%username%\Documents\Hackopz\save.bat"
set loca="C:\Users\%username%\Documents\Hackopz\"
if exist %loca% goto intro
CD "C:\Users\%username%\Documents\Hackopz\"

How do you expect those directories or that file to exist when you don't make a check and create any directory like that?

Also hardcoding "C:\" into the script is always a bad idea.

Code:
if %do%==2 goto begin

This is also a string input so you should be using double quotes around them. Otherwise you've got way too many choices in here in if statements that don't need to exist, and it's calling to a location that will probably never exist on someone else's computer anyway.
Reply
#3
(01-20-2012, 03:17 PM)AceInfinity Wrote: First thing:
Code:
set loc="C:\Users\%username%\Documents\Hackopz\save.bat"
set loca="C:\Users\%username%\Documents\Hackopz\"
if exist %loca% goto intro
CD "C:\Users\%username%\Documents\Hackopz\"

How do you expect those directories or that file to exist when you don't make a check and create any directory like that?

So, Should I use it like this?

Code:
set loc="%userprofile%\Documents\Hackopz\save.bat"
set loca="%userprofile%\Documents\Hackopz\"
if exist %loca% goto intro
CD "%userprofile%\Documents\Hackopz\"

" %userprofile% " will always exist. right? Unsure

And thanks, I'll remember what you said. Oui
Reply
#4
Yes UserProfile is a special variable, and everything is good, except for your STILL USING "Hackopz" as a directory which will probably never ever exist on another person's computer, and also, up until here:
Code:
if exist %loca% goto intro
CD "%userprofile%\Documents\Hackopz\"

%loca% holds the value of "%userprofile%\Documents\Hackopz\" does it not? so if it doesn't exist, it will go past that if statement and try to navigate using CD to that location that doesn't exist, which is wrong. %UserProfile%\Documents might not always exist either, which is also bad, and there's about a 99% chance that the user "Hackopz" will not exist on someone else's machine either, so that shouldn't even be used.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pass Generator Batch script AceInfinity 0 903 09-30-2012, 10:17 PM
Last Post: AceInfinity
  Batch tutorial goes here? fanta 3 1,521 05-22-2012, 09:25 PM
Last Post: AceInfinity
  [Batch] Trick - View Environment Variables AceInfinity 0 976 05-05-2012, 07:01 PM
Last Post: AceInfinity
  [Batch] Quick Drive Information Script (Created by AceInfinity) AceInfinity 17 7,248 02-09-2012, 08:10 AM
Last Post: AceInfinity
  [Batch Script] File Binary Data Compare - (Drag & Drop / Command Line Args) AceInfinity 5 3,157 01-14-2012, 05:59 AM
Last Post: ISO

Forum Jump:


Users browsing this thread: 2 Guest(s)