Is this possible

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#31 Post by explosivedolphin » 12 Sep 2016 11:01

how does what you have added to the code add the ability to choose a difficulty or add a cap to the number of times you can guess also If we could get it so you are timed and the timer resets when you get it right like 60 seconds that would be great
you should be able to choose difficulty's easy 20 try resets when you get it right medium 10 trys resets when you get it right and hard you only get 10 but when you get it right it doesn't reset it just gives you plus 5 trys
? is this possible also it should save the difficultly you choose in the highscore and it should save the total time you spent playing also you should get 3 lives maybe different lives with different difficultly and also the different difficulty should have a multiplier to the score I want to add some sort of scoring system with possible bonuses for the time completed in or the amount of guess it took or to how many you got right before you ran out of lives time or tries and have the time update in the title of the prompt also with tries I believe this would be easier than have it keep clearing the screen Is this possible before you attempt to make this please reply what is possible out of this and if you can make it then go ahead and attempt it I know I'm asking alot but these would be great improvements thanks to anyone that can do any of these things I ask.
EDIT

Code: Select all

start cmdbkg 123.bmp 10  includeBorders

We could also use the tool cmdbkg to change the background if you get closer or farther from the number
http://www.dostips.com/forum/viewtopic.php?f=3&t=7407
BUGS

    =======================
      The title is messed up and keeps adding letters like h Im assuming is for higher and l Im assuming for lower until it says not enough storage to process command
        The goto commands were not working had to fix them up
        ============================
HERE IS THE CODE SO FAR
=======================
FIXED A FEW BUGS
=======================

Code: Select all

@echo off
color 0F
cls
echo Type your name to save your highscore.
set /p "name= "
CLS
Set "title1=Guessing Game Edited By AlternateAlt (and some other people)"
title %title1%
Set "LoadColor=7"
Set "LoadLimit=27"
Set "LoadColors=0123456789ABCDEF"
set "variable1=surf33"
for /f %%a in ('show 30') do set "up=%%a"
for /f %%a in ('show 31') do set "down=%%a"
:StartNewGame
Set "LoadCtr=0"
set "guessnum=0"

:PickAnswer
echo ///Loading///
echo ///Loading///
echo ///Loading///
echo ///Loading///

SetLocal EnableDelayedExpansion
set /A "RandomColor=%random%*16/32768"
Set "LoadColor=!LoadColors:~%RandomColor%,1!"
color 0%LoadColor%
EndLocal
ping  -w 10 -n 2 -1 3 127.0.0.1>NUL
Set /A "LoadCtr+=1"
CLS
set /a answer=%RANDOM%
if %answer% gtr 100 (
    if "%LoadCtr%" EQU "%LoadLimit%" (set /A "answer=(%random%*100)/32768+1" & goto :ChoseAnswer)
    goto PickAnswer
)
:ChoseAnswer
::  Reduce countdown with experience and add progress status to title
Set /A "LoadLimit=1+LoadLimit/3"
color 07
::I want to add these
set /a extremely_close_low=%anwser%-2
set /a extremely_close_high=%anwser%+2
::I want to add these
set /a super_close_high=%answer%+3
set /a super_close_low=%answer%-3
::I want to add these
set /a pretty_close_low=%anwser%-15
set /a pretty_close_high=%anwser%+15
::I want to add these
set /a kinda_close_high=%answer%+20
set /a kinda_close_low=%answer%-20
set /a not_that_close_high=%answer%+35
set /a not_that_close_low=%answer%-35
set /a not_even_close_high=%answer%+40
set /a not_even_close_low=%answer%-40
:top_Welcome
Set "title2=----+----1----+----2----+----3----+----4----+----5"
Set "title2=%title2%----+----6----+----7----+----8----+----9----+----"
title %title1% %title3%
echo "---------------------------------"
colorshow /0B 32 " Welcome," /0F " %name%" /0B ", to the Guessing Game!" 13 10
colorshow 196*49 13 10
colorshow /0B 32 " Try and Guess my Number!: from  1 to 100 ." 13 10
echo "---------------------------------"
ColorBox /0f 0 0 48 4
colorshow /0F 16 32
:top_Guess
set /p "guess="
if "%guess%"=="%variable1%" (ECHO Found the backdoor hey? The answer is: %answer% && goto top_Guess)
if %guess% GTR 100 goto error1
if %guess% lss %not_even_close_low% Set ColorHint=07
if %guess% gtr %not_even_close_high% Set ColorHint=07
if %guess% gtr %not_even_close_low% if %guess% lss %not_that_close_high% Set ColorHint=04
if %guess% lss %not_even_close_high% if %guess% gtr %not_that_close_low% Set ColorHint=04
if %guess% gtr %not_that_close_low% if %guess% lss %kinda_close_high% Set ColorHint=0C
if %guess% lss %not_that_close_high% if %guess% gtr %kinda_close_low% Set ColorHint=0C
if %guess% gtr %kinda_close_low% if %guess% lss %super_close_high% Set ColorHint=0A
if %guess% lss %kinda_close_high% if %guess% gtr %super_close_low% Set ColorHint=0A
if %guess% gtr %super_close_low% if %guess% lss %super_close_high% Set ColorHint=02
SetLocal EnableDelayedExpansion
    Set /A "ProgPos=%guess%-1
    Set "Progress1=!Title2:~0,%ProgPos%!"
    Set "Progress2=!Title2:~%guess%!"
if %guess% GTR %answer% (
    Set "Hint=Lower"
    Colorshow /%ColorHint% "!Hint!" 13 10 /0C "%down%" 32
    Set "Title2=%progress1%L%Progress2%"
)
if %guess% LSS %answer% (
    Set "Hint=Higher"
    Colorshow /%ColorHint% "!Hint!" 13 10 /0B "%up%" 32
    Set "Title2=%progress1%H%Progress2%"
)
title Guessing HINTS___+0%title2%100+___%Hint%
if "%guess%"=="%answer%" (
    set /a guessnum=%guessnum% +1
    set /a right=%right%+1
    colorshow /0C 32 03 32 /0E"SUCCESS!" 13 10
    Set "Hint=Exact"
    Set "title3=[Guesses - !Guessnum!] - [Times Right - !right!]
    Set "Title2=%progress1%#%Progress2%"
    title Guessing HINTS___+0!title2!100+___!Hint!
    goto :hello11
)
(EndLocal & rem.Save values for reruns
    Set "right=%right%"
    Set "Title2=%Title2%"
    Set "Title3=%Title3%"
)
set /a guessnum=%guessnum% +1
goto :top_Guess

if "%guess%"=="%answer%" (
    set /a guessnum=%guessnum% +1
    set /a right=%right%+1
    colorshow /0C 32 03 32 /0E"SUCCESS!" 13 10
    Set "Hint=Exact"
    Set "title3=[Guesses - !Guessnum!] - [Times Right - !right!]
    Set "Title2=%progress1%#%Progress2%"
    title Guessing HINTS___+0!title2!100+___!Hint!
    goto :hello11
)
(EndLocal & rem.Save values for reruns
    Set "right=%right%"
    Set "Title2=%Title2%"
    Set "Title3=%Title3%"
)
set /a guessnum=%guessnum% +1
goto :top_Guess


:hello11
CLS
color 0C
echo Congratulations, you guessed correctly!!!
echo It took you %guessnum% guesses to find %guess%.
echo You guessed the number correctly this many times: %right%
echo ------------------------------
echo Press 1 To Save Score
echo ------------------------------
echo Press 2 To Keep Playing.
echo ------------------------------
echo Press 3 To Check Highscores.
echo ------------------------------
echo Press 4 To Exit.
echo ------------------------------
CHOICE /C 1234 /N /M [1,2,3,4]?
Set "save=%ErrorLevel%"
if %save%==1 (call :save "%name%" %right% %Guessnum% & Goto :hello11)
if %save%==2 goto :StartNewGame
if %save%==3 (call :open & Goto :hello11)
if %save%==4 (title %title1% & Exit /B)

:save
(
   echo ====================
   echo Player=%~1
   echo Date=%date%
   echo Times Many Guessed Correctly=%2
   echo Number Of Guesses=%3
   echo ====================
) >>highscore.txt
Exit /B


:wrong
echo Unknown Number. Press Any Key To Return.
pause>nul
goto top_guess

:open
notepad highscore.txt
CLS
goto Hello11
:error1
echo Please Pick A Number Between 1 and 100.
goto top_guess

=======================

thefeduke
Posts: 211
Joined: 05 Apr 2015 13:06
Location: MA South Shore, USA

Re: Is this possible

#32 Post by thefeduke » 15 Sep 2016 13:04

explosivedolphin wrote: if you can make it then go ahead and attempt it
I got some of it into the following code, but, sorry, it took a bit longer than I wished. Here it is with remaining bugs intact. I shall follow with some comments on how you appear to be avoiding the use of CALL leading to hard to manage code with GOTO. I also want to show you what I was trying with START vs. NOTEPAD.

Code: Select all

@echo off & SetLocal
color 0F
cls
echo Type your name to save your highscore.
set /p "name="
:ChooseDifficulty
For /F "tokens=5-17* delims=: " %%A IN ('findstr /I /c:"Name:%Name%" GuessScores.txt') DO (
    Set "%%A=%%B"
    Set "%%C=%%D"
    Set "%%E=%%F"
    Set "%%G=%%H"
    Set "%%I=%%J"
    Set "%%K=%%L"
    Set "Found=%%N
)
echo ------------------------------
If Defined Found (
    Echo.Press 1 to continue at the %Difficulty% Level with same Lives and Right counts.
) Else Echo.Press 1 to Start "%Name%" at the Easy Level.
echo ------------------------------
echo Press E To choose the Easy Level.
echo ------------------------------
echo Press M To choose the Medium Level.
echo ------------------------------
echo Press H To choose the Hard Level.
echo ------------------------------
echo Press X To eXit.
echo ------------------------------
:ChooseLevel
CHOICE /C 1EMHX /N /M [1,E,M,H,X]?
Set "level=%ErrorLevel%"
if %level%==1 (
    If Defined Found (
        Echo.Continuing at the %Difficulty% Level.
    ) Else Set "level=2"
)
if %level%==2 (Set "Difficulty=Easy" & Set "MaxGuesses=20"&Set "MaxSecs=300"&Set "MaxLives=3")
if %level%==3 (Set "Difficulty=Medium"&Set "MaxGuesses=10"&Set "MaxSecs=150"&Set "MaxLives=3")
if %level%==4 (Set "Difficulty=Hard" & Set "MaxGuesses=6" &Set "MaxSecs=90" &Set "MaxLives=3")
if %level%==5 Exit /B
Set "title1=Guessing Game Edited By AlternateAlt (and some other people)"
title %title1%
Set "title1=Guessing Game - "
Set "LoadColor=7"
Set "LoadLimit=27"
Set "LoadColors=0123456789ABCDEF"
set "variable1=surf33"
If "%level%" NEQ "1" Set "right=0"
If "%level%" NEQ "1" Set "Lives=0"
for /f %%a in ('show 30') do set "up=%%a"
for /f %%a in ('show 31') do set "down=%%a"
for /f %%a in ('show 03') do set "heart=%%a"
Set "title2=----+----1----+----2----+----3----+----4----+----5"
Set "title2=%title2%----+----6----+----7----+----8----+----9----+----"
Set "Stitle2=----+----2----+----4----+----6----+----8----+----"

:StartNewGame
Set "LoadCtr=0"
set "Guesses=0"

:PickAnswer
echo ///Loading///
echo ///Loading///
echo ///Loading///
echo ///Loading///

SetLocal EnableDelayedExpansion
set /A "RandomColor=%random%*16/32768"
Set "LoadColor=!LoadColors:~%RandomColor%,1!"
color 0%LoadColor%
EndLocal
ping  -w 10 -n 2 -1 3 127.0.0.1>NUL
Set /A "LoadCtr+=1"
CLS
set /a answer=%RANDOM%
if %answer% gtr 100 (
    if "%LoadCtr%" EQU "%LoadLimit%" (set /A "answer=(%random%*100)/32768+1" & goto :ChoseAnswer)
    goto PickAnswer
)

:ChoseAnswer
::  Reduce countdown with experience and add progress status to title
Set /A "LoadLimit=1+LoadLimit/3"
color 07
::I want to add these
set /a extremely_close_low=%anwser%-2
set /a extremely_close_high=%anwser%+2
::I want to add these
set /a super_close_high=%answer%+3
set /a super_close_low=%answer%-3
::I want to add these
set /a pretty_close_low=%anwser%-15
set /a pretty_close_high=%anwser%+15
::I want to add these
set /a kinda_close_high=%answer%+20
set /a kinda_close_low=%answer%-20
set /a not_that_close_high=%answer%+35
set /a not_that_close_low=%answer%-35
set /a not_even_close_high=%answer%+40
set /a not_even_close_low=%answer%-40

:top_Welcome
Set "title3=Guesses:%Guesses% Right:%right% Lives:%Lives% Difficulty:%Difficulty% MaxGuesses:%MaxGuesses% MaxSecs:%MaxSecs% MaxLives:%MaxLives%"
title %title1% %title3%
echo "---------------------------------"
colorshow /0B 32 " Welcome," /0F " %name%" /0B ", to the Guessing Game!" 13 10
colorshow 196*49 13 10
colorshow /0B 32 " Try and Guess my Number!: from  1 to 100 ." 13 10
echo "---------------------------------"
ColorBox /0f 0 0 48 4
echo "---------------------------------"
echo " %Title3%
echo "---------------------------------"
for /f "tokens=1-4 delims=:.," %%a in ("%time: =0%") do set /a "time1=(((1%%a*60)+1%%b)*60+1%%c)*100+1%%d-36610100"
Set "Date1=%date%"
colorshow /0F "Your first guess" 32 /0B 16 32
:top_Guess
set /p "guess="
for /f "tokens=1-4 delims=:.," %%a in ("%time: =0%") do set /a "time2=(((1%%a*60)+1%%b)*60+1%%c)*100+1%%d-36610100"
Set "Date2=%date%"
If "%date1%" NEQ "%date2%" Set /A "time2=time2+8640000"
Set /A "CurSecs=(time2-time1)/100"
if "%guess%"=="%variable1%" (ECHO Found the backdoor hey? The answer is: %answer% && goto top_Guess)
if %guess% GTR 100 goto error1
if %guess% lss %not_even_close_low% Set ColorHint=07
if %guess% gtr %not_even_close_high% Set ColorHint=07
if %guess% gtr %not_even_close_low% if %guess% lss %not_that_close_high% Set ColorHint=04
if %guess% lss %not_even_close_high% if %guess% gtr %not_that_close_low% Set ColorHint=04
if %guess% gtr %not_that_close_low% if %guess% lss %kinda_close_high% Set ColorHint=0C
if %guess% lss %not_that_close_high% if %guess% gtr %kinda_close_low% Set ColorHint=0C
if %guess% gtr %kinda_close_low% if %guess% lss %super_close_high% Set ColorHint=0A
if %guess% lss %kinda_close_high% if %guess% gtr %super_close_low% Set ColorHint=0A
if %guess% gtr %super_close_low% if %guess% lss %super_close_high% Set ColorHint=02
SetLocal EnableDelayedExpansion
    Set /A "ProgPos=%guess%-1
    Set "Progress1=!Title2:~0,%ProgPos%!"
    Set "Progress2=!Title2:~%guess%!"
if %guess% GTR %answer% (
    Set "Hint=Lower after %CurSecs% secs."
    Colorshow /%ColorHint% "!Hint!" 13 10 /0C "%down%" 32
    Set "Title2=%progress1%L%Progress2%"
)
if %guess% LSS %answer% (
    Set "Hint=Higher after %CurSecs% secs."
    Colorshow /%ColorHint% "!Hint!" 13 10 /0B "%up%" 32
    Set "Title2=%progress1%H%Progress2%"
)
title Guessing HINTS___+0%title2%100+___%Hint%
if "%guess%"=="%answer%" (
    set /a Guesses=%Guesses% +1
    set /a right=%right%+1
    Echo.
    Set "Hint=Exact after %CurSecs% secs."
    colorshow /0C 13 10 32 "%heart%" 32 /0F "SUCCESS^!" 32 /07 "!Hint!" 32 /0E 16 32
    Set "title3=Guesses:!Guesses! Right:!right! Lives:!Lives! Difficulty:!Difficulty! MaxGuesses:!MaxGuesses! MaxSecs:!MaxSecs! MaxLives:!MaxLives!"
    Set "Title2=%progress1%#%Progress2%"
    title Guessing HINTS___+0!title2!100+___!Hint!
    >nul Pause
)
(EndLocal & rem.Save values for reruns
    Set "right=%right%"
    Set "Title2=%Title2%"
    Set "Title3=%Title3%"
)
set /a Guesses=%Guesses%+1
IF "%Guesses%" EQU "%MaxGuesses%" Set /A "Lives+=1"
IF "%Guesses%" EQU "%MaxGuesses%" (
    Echo.You reached the guess limit of %maxguesses% for the %Difficulty% Difficulty Level.
    Set "title3=Guesses:%Guesses% Right:%right% Lives:%Lives% Difficulty:%Difficulty% MaxGuesses:%MaxGuesses% MaxSecs:%MaxSecs% MaxLives:%MaxLives%"
    goto :GotItWrong
)
IF %CurSecs% GEQ %MaxSecs% Set /A "Lives+=1"
IF %CurSecs% GEQ %MaxSecs% (
    Echo.You reached the time limit of %maxSecs% seconds for the %Difficulty% Difficulty Level.
    Set "title3=Guesses:%Guesses% Right:%right% Lives:%Lives% Difficulty:%Difficulty% MaxGuesses:%MaxGuesses% MaxSecs:%MaxSecs% MaxLives:%MaxLives%"
    goto :GotItWrong
)
if Not "%guess%"=="%answer%" goto :top_Guess


:GotItRight
CLS
color 0C
echo Congratulations, you guessed correctly!!!
echo It took you %Guesses% guesses to find %guess%.
echo You guessed the number correctly this many times: %right%
:GotItWrong
:: This may be a good place to handle running out of lives
title %title1% %title3%
cALL :unique TStamp
Set "TimeStamp=%TStamp:~-8%"
SetLocal EnableDelayedExpansion
Set "TStamp=!TStamp:%TimeStamp%=!"
(Echo.%TStamp%-%date:~4% %TimeStamp:~0,4% %title3% name:%name%
) >>GuessScores.txt
EndLocal
echo ------------------------------
echo Press 1 To Save Score
echo ------------------------------
echo Press 2 To Keep Playing.
echo ------------------------------
echo Press 3 To Check Highscores.
echo ------------------------------
echo Press 4 To Change Difficulty.
echo ------------------------------
echo Press 5 To Exit.
echo ------------------------------
:ChooseMenuItem
CHOICE /C 12345 /N /M [1,2,3,4,5]?
Set "save=%ErrorLevel%"

:: This demonstrates a compound CALL to save: and GOTO on the IF
:: 'goto :ChooseMenuItem' is done after the return from the CALL within the IF
if %save%==1 (call :save "%name%" %right% %Guesses% & Goto :ChooseMenuItem)

if %save%==2 goto :StartNewGame

:: This demonstrates a GOTO transfer of control on the IF
:: the 'goto :ChooseMenuItem' is done by the code after :open
if %save%==3 GoTo :open

if %save%==4 (color 0F&CLS&GoTo :ChooseDifficulty)
if %save%==5 (title %title1% & Exit /B)

:: This example command will not execute because of 'GOTO :open' above
if %save%==3 (call :open & Goto :GotItRight)

:save
(
   echo ====================
   echo Player=%~1
   echo Date=%date%
   echo Times Many Guessed Correctly=%2
   echo Number Of Guesses=%3
   echo ====================
) >>highscore.txt
Echo.Saved. Choose another Menu Option
Exit /B

:open
rem.Start "" /Wait highscore.txt
notepad highscore.txt
Echo.Done. Choose another Menu Option
goto :ChooseMenuItem

:error1
echo Please Pick A Number Between 1 and 100.
goto top_guess

:Unique - returns a unique string based on a date-time-stamp, YYYYMMDDhhmmsscc
:Description:   call:Unique ret
:Unique ret -- returns a unique string based on a date-time-stamp, YYYYMMDDhhmmsscc
::          -- ret    [out,opt] - unique string
:$created 20060101 :$changed 20080219 :$categories StringOperation,DateAndTime
:$source http://www.dostips.com
SETLOCAL
for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('"echo.|date"') do (
    for /f "tokens=1-3 delims=/.- " %%A in ("%date:* =%") do (
        set %%a=%%A&set %%b=%%B&set %%c=%%C))
rem.set /a "yy=10000%yy% %%10000,mm=100%mm% %% 100,dd=100%dd% %% 100"
for /f "tokens=1-4 delims=:. " %%A in ("%time: =0%") do @set UNIQUE=%yy%%mm%%dd%%%A%%B%%C%%D
ENDLOCAL & IF "%~1" NEQ "" (SET %~1=%UNIQUE%) ELSE echo.%UNIQUE%
EXIT /b

John A

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#33 Post by explosivedolphin » 20 Sep 2016 07:30

[/quote]would you mind marking parts in the code with :: and say what those parts do because this is beyond my understanding[quote]
so Im just gonna test for bugs

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#34 Post by explosivedolphin » 22 Sep 2016 12:38

A few changes I would like to see
Fix up the formatting of the difficultly because it doesn't show all the variables on screen
https://drive.google.com/file/d/0Bzy1wu4WrDmhZXZmYVZQR3VHRlk/view?usp=sharing
maybe change the size of the command prompt but make it look nicer at least
===============
also for every difficultly make the number guessable higher by maybe 25 for medium and 50 for hard
===============
change colors up make it look nice pretty it up
===============
change second maybe 100 for easy and 60 for medium 30 for hard
===============
make sure guesses reset for easy and medium but for hard dont make it reset make it only add 5 to the guesses when you get it right
===============
add some sort of scoring system that the difficulty multiplies the score plus make it so the time it takes to get it right and the number of guesses change the score and it adds up
==============
all for now thanks

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Is this possible

#35 Post by foxidrive » 23 Sep 2016 00:32

explosivedolphin wrote:A few changes I would like to see
maybe change the size of the command prompt but make it look nicer at least


The mode command is useful there.
type mode /? for the help screen.

The display mode is the line to pay attention to.

thefeduke
Posts: 211
Joined: 05 Apr 2015 13:06
Location: MA South Shore, USA

Re: Is this possible

#36 Post by thefeduke » 25 Sep 2016 12:41

foxidrive wrote:
explosivedolphin wrote:A few changes I would like to see
maybe change the size of the command prompt but make it look nicer at least


The mode command is useful there.
type mode /? for the help screen.

The display mode is the line to pay attention to.
Good advice. I had a buffer line of 120. Look around the properties of your command prompt as well. I have set up, but not implemented a half size title line, but if you add

Code: Select all

For /F "tokens=1-2 skip=4" %%C in ('Mode con') do if not defined Mycols set Mycols=%%D
If %Mycols% LSS 105 Mode con cols=105
before the first CLS, the title will no longer be cut off by the column width of the prompt, based on the default character size for the title.

John A.

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#37 Post by explosivedolphin » 26 Sep 2016 11:42

Code: Select all

::I want to add these
set /a extremely_close_low=%anwser%-2
set /a extremely_close_high=%anwser%+2
::I want to add these
set /a super_close_high=%answer%+3
set /a super_close_low=%answer%-3
::I want to add these
set /a pretty_close_low=%anwser%-15
set /a pretty_close_high=%anwser%+15
::I want to add these
set /a kinda_close_high=%answer%+20
set /a kinda_close_low=%answer%-20
set /a not_that_close_high=%answer%+35
set /a not_that_close_low=%answer%-35
set /a not_even_close_high=%answer%+40
set /a not_even_close_low=%answer%-40


I want to add the ones that say :: I want to add these

also want to add the scoring system that I wanted
===============
add some sort of scoring system that the difficulty multiplies the score plus make it so the time it takes to get it right and the number of guesses change the score and it adds up
==============


also we need to have a color when its like more or less than 99 or 50 away instead of leaving it default color

finally if we could add pictures when you get closer or farther or maybe when you get it right we can use this please send me a
zip with the pictures
http://www.dostips.com/forum/viewtopic.php?f=3&t=7407

this would be the code for it

Code: Select all

start cmdbkg 123.bmp 10  includeBorders



code so far

Code: Select all

@echo off & SetLocal
color 0F
For /F "tokens=1-2 skip=4" %%C in ('Mode con') do if not defined Mycols set Mycols=%%D
If %Mycols% LSS 105 Mode con cols=105
cls
echo Type your name to save your highscore.
set /p "name="
:ChooseDifficulty
For /F "tokens=5-17* delims=: " %%A IN ('findstr /I /c:"Name:%Name%" GuessScores.txt') DO (
    Set "%%A=%%B"
    Set "%%C=%%D"
    Set "%%E=%%F"
    Set "%%G=%%H"
    Set "%%I=%%J"
    Set "%%K=%%L"
    Set "Found=%%N"
)
echo ------------------------------
If Defined Found (
    Echo.Press 1 to continue at the %Difficulty% Level with same Lives and Right counts.
) Else Echo.Press 1 to Start "%Name%" at the Easy Level.
echo ------------------------------
echo Press E To choose the Easy Level.
echo ------------------------------
echo Press M To choose the Medium Level.
echo ------------------------------
echo Press H To choose the Hard Level.
echo ------------------------------
echo Press X To Exit.
echo ------------------------------
:ChooseLevel
CHOICE /C 1EMHX /N /M [1,E,M,H,X]?
Set "level=%ErrorLevel%"
if %level%==1 (
    If Defined Found (
        Echo.Continuing at the %Difficulty% Level.
    ) Else Set "level=2"
)
if %level%==2 (Set "Difficulty=Easy" & Set "MaxGuesses=20"&Set "MaxSecs=150"&Set "MaxLives=3")
if %level%==3 (Set "Difficulty=Medium"&Set "MaxGuesses=10"&Set "MaxSecs=100"&Set "MaxLives=3")
if %level%==4 (Set "Difficulty=Hard" & Set "MaxGuesses=6" &Set "MaxSecs=30" &Set "MaxLives=3")
if %level%==5 Exit /B
Set "title1=Guessing Game Edited By AlternateAlt (and some other people)"
title %title1%
Set "title1=Guessing Game - "
Set "LoadColor=7"
Set "LoadLimit=27"
Set "LoadColors=0123456789ABCDEF"
set "variable1=surf33"
If "%level%" NEQ "1" Set "right=0"
If "%level%" NEQ "1" Set "Lives=0"
for /f %%a in ('show 30') do set "up=%%a"
for /f %%a in ('show 31') do set "down=%%a"
for /f %%a in ('show 03') do set "heart=%%a"
Set "title2=----+----1----+----2----+----3----+----4----+----5"
Set "title2=%title2%----+----6----+----7----+----8----+----9----+----"
Set "Stitle2=----+----2----+----4----+----6----+----8----+----"

:StartNewGame
Set "LoadCtr=0"
set "Guesses=0"

:PickAnswer
echo ///Loading///
echo ///Loading///
echo ///Loading///
echo ///Loading///

SetLocal EnableDelayedExpansion
set /A "RandomColor=%random%*16/32768"
Set "LoadColor=!LoadColors:~%RandomColor%,1!"
color 0%LoadColor%
EndLocal
ping  -w 10 -n 2 -1 3 127.0.0.1>NUL
Set /A "LoadCtr+=1"
CLS
set /a answer=%RANDOM%
if %answer% gtr 100 (
    if "%LoadCtr%" EQU "%LoadLimit%" (set /A "answer=(%random%*100)/32768+1" & goto :ChoseAnswer)
    goto PickAnswer
)

:ChoseAnswer
::  Reduce countdown with experience and add progress status to title
Set /A "LoadLimit=1+LoadLimit/3"
color 07
::I want to add these
set /a extremely_close_low=%anwser%-2
set /a extremely_close_high=%anwser%+2
::I want to add these
set /a super_close_high=%answer%+3
set /a super_close_low=%answer%-3
::I want to add these
set /a pretty_close_low=%anwser%-15
set /a pretty_close_high=%anwser%+15
::I want to add these
set /a kinda_close_high=%answer%+20
set /a kinda_close_low=%answer%-20
set /a not_that_close_high=%answer%+35
set /a not_that_close_low=%answer%-35
set /a not_even_close_high=%answer%+40
set /a not_even_close_low=%answer%-40

:top_Welcome
Set "title3=Guesses:%Guesses% Right:%right% Lives:%Lives% Difficulty:%Difficulty% MaxGuesses:%MaxGuesses% MaxSecs:%MaxSecs% MaxLives:%MaxLives%"
title %title1% %title3%
echo "---------------------------------"
colorshow /0B 32 " Welcome," /0F " %name%" /0B ", to the Guessing Game!" 13 10
colorshow 196*49 13 10
colorshow /0B 32 " Try and Guess my Number!: from  1 to 100 ." 13 10
echo "---------------------------------"
ColorBox /0f 0 0 48 4
echo "---------------------------------"
echo " %Title3%
echo "---------------------------------"
for /f "tokens=1-4 delims=:.," %%a in ("%time: =0%") do set /a "time1=(((1%%a*60)+1%%b)*60+1%%c)*100+1%%d-36610100"
Set "Date1=%date%"
colorshow /0F "Your first guess" 32 /0B 16 32
:top_Guess
set /p "guess="
for /f "tokens=1-4 delims=:.," %%a in ("%time: =0%") do set /a "time2=(((1%%a*60)+1%%b)*60+1%%c)*100+1%%d-36610100"
Set "Date2=%date%"
If "%date1%" NEQ "%date2%" Set /A "time2=time2+8640000"
Set /A "CurSecs=(time2-time1)/100"
if "%guess%"=="%variable1%" (ECHO Found the backdoor hey? The answer is: %answer% && goto top_Guess)
if %guess% GTR 100 goto error1
if %guess% lss %not_even_close_low% Set ColorHint=07
if %guess% gtr %not_even_close_high% Set ColorHint=07
if %guess% gtr %not_even_close_low% if %guess% lss %not_that_close_high% Set ColorHint=04
if %guess% lss %not_even_close_high% if %guess% gtr %not_that_close_low% Set ColorHint=04
if %guess% gtr %not_that_close_low% if %guess% lss %kinda_close_high% Set ColorHint=0C
if %guess% lss %not_that_close_high% if %guess% gtr %kinda_close_low% Set ColorHint=0C
if %guess% gtr %kinda_close_low% if %guess% lss %super_close_high% Set ColorHint=0A
if %guess% lss %kinda_close_high% if %guess% gtr %super_close_low% Set ColorHint=0A
if %guess% gtr %super_close_low% if %guess% lss %super_close_high% Set ColorHint=02
SetLocal EnableDelayedExpansion
    Set /A "ProgPos=%guess%-1
    Set "Progress1=!Title2:~0,%ProgPos%!"
    Set "Progress2=!Title2:~%guess%!"
if %guess% GTR %answer% (
    Set "Hint=Lower %CurSecs% secs."
    Colorshow /%ColorHint% "!Hint!" 13 10 /0C "%down%" 32
    Set "Title2=%progress1%L%Progress2%"
)
if %guess% LSS %answer% (
    Set "Hint=Higher %CurSecs% secs."
    Colorshow /%ColorHint% "!Hint!" 13 10 /0B "%up%" 32
    Set "Title2=%progress1%H%Progress2%"
)
title Guessing HINTS___+0%title2%100+___%Hint%
if "%guess%"=="%answer%" (
    set /a Guesses=%Guesses% +1
    set /a right=%right%+1
    Echo.
    Set "Hint=Exact %CurSecs% secs."
    colorshow /0C 13 10 32 "%heart%" 32 /0F "SUCCESS^!" 32 /07 "!Hint!" 32 /0E 16 32
    Set "title3=Guesses:!Guesses! Right:!right! Lives:!Lives! Difficulty:!Difficulty! MaxGuesses:!MaxGuesses! MaxSecs:!MaxSecs! MaxLives:!MaxLives!"
    Set "Title2=%progress1%#%Progress2%"
    title Guessing HINTS___+0!title2!100+___!Hint!
    >nul Pause
)
(EndLocal & rem.Save values for reruns
    Set "right=%right%"
    Set "Title2=%Title2%"
    Set "Title3=%Title3%"
)
set /a Guesses=%Guesses%+1
IF "%Guesses%" EQU "%MaxGuesses%" Set /A "Lives+=1"
IF "%Guesses%" EQU "%MaxGuesses%" (
::CHANGED
    Echo You Have Gussed The Max Number
    Echo For The %Difficulty% Difficulty Level
    Echo Which Is %maxguesses%.
    Set "title3=Guesses:%Guesses% Right:%right% Lives:%Lives% Difficulty:%Difficulty% MaxGuesses:%MaxGuesses% MaxSecs:%MaxSecs% MaxLives:%MaxLives%"
    goto :GotItWrong
)
IF %CurSecs% GEQ %MaxSecs% Set /A "Lives+=1"
IF %CurSecs% GEQ %MaxSecs% (
    Echo.You reached the time limit of %maxSecs% seconds for the %Difficulty% Difficulty Level.
    Set "title3=Guesses:%Guesses% Right:%right% Lives:%Lives% Difficulty:%Difficulty% MaxGuesses:%MaxGuesses% MaxSecs:%MaxSecs% MaxLives:%MaxLives%"
    goto :GotItWrong
)
if Not "%guess%"=="%answer%" goto :top_Guess


:GotItRight
CLS
color 0C
echo Congratulations, you guessed correctly!!!
echo It took you %Guesses% guesses to find %guess%.
echo You guessed the number correctly this many times: %right%
:GotItWrong
:: This may be a good place to handle running out of lives
title %title1% %title3%
cALL :unique TStamp
Set "TimeStamp=%TStamp:~-8%"
SetLocal EnableDelayedExpansion
Set "TStamp=!TStamp:%TimeStamp%=!"
(Echo.%TStamp%-%date:~4% %TimeStamp:~0,4% %title3% name:%name%
) >>GuessScores.txt
EndLocal
echo ------------------------------
echo Press 1 To Save Score
echo ------------------------------
echo Press 2 To Keep Playing.
echo ------------------------------
echo Press 3 To Check Highscores.
echo ------------------------------
echo Press 4 To Change Difficulty.
echo ------------------------------
echo Press 5 To Exit.
echo ------------------------------
:ChooseMenuItem
CHOICE /C 12345 /N /M [1,2,3,4,5]?
Set "save=%ErrorLevel%"

:: This demonstrates a compound CALL to save: and GOTO on the IF
:: 'goto :ChooseMenuItem' is done after the return from the CALL within the IF
if %save%==1 (call :save "%name%" %right% %Guesses% & Goto :ChooseMenuItem)

if %save%==2 goto :StartNewGame

:: This demonstrates a GOTO transfer of control on the IF
:: the 'goto :ChooseMenuItem' is done by the code after :open
if %save%==3 GoTo :open

if %save%==4 (color 0F&CLS&GoTo :ChooseDifficulty)
if %save%==5 (title %title1% & Exit /B)

:: This example command will not execute because of 'GOTO :open' above
if %save%==3 (call :open & Goto :GotItRight)

:save
(
   echo ====================
   echo Player=%~1
   echo Date=%date%
   echo Times Many Guessed Correctly=%2
   echo Number Of Guesses=%3
   echo ====================
) >>highscore.txt
Echo.Saved. Choose another Menu Option
Exit /B

:open
rem.Start "" /Wait highscore.txt
notepad highscore.txt
Echo.Done. Choose another Menu Option
goto :ChooseMenuItem

:error1
echo Please Pick A Number Between 1 and 100.
goto top_guess

:Unique - returns a unique string based on a date-time-stamp, YYYYMMDDhhmmsscc
:Description:   call:Unique ret
:Unique ret -- returns a unique string based on a date-time-stamp, YYYYMMDDhhmmsscc
::          -- ret    [out,opt] - unique string
:$created 20060101 :$changed 20080219 :$categories StringOperation,DateAndTime
:$source http://www.dostips.com
SETLOCAL
for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('"echo.|date"') do (
    for /f "tokens=1-3 delims=/.- " %%A in ("%date:* =%") do (
        set %%a=%%A&set %%b=%%B&set %%c=%%C))
rem.set /a "yy=10000%yy% %%10000,mm=100%mm% %% 100,dd=100%dd% %% 100"
for /f "tokens=1-4 delims=:. " %%A in ("%time: =0%") do @set UNIQUE=%yy
ENDLOCAL & IF "%~1" NEQ "" (SET %~1=%UNIQUE%) ELSE echo.%UNIQUE%
EXIT /b

Post Reply