Batch Terminal Strategy Game

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
1k1lljoy
Posts: 1
Joined: 21 Jan 2016 14:49

Batch Terminal Strategy Game

#1 Post by 1k1lljoy » 21 Jan 2016 15:34

I am making a strategy terminal game for a project. This is going to be a turned based game but I have no idea where to start on a specific function I am thinking of. The function is that you have many different troops to attack with in your army, however you can only attack with 2 kinds of troops per turn. Also, when you have attacked with a troop once, I want it to have a cool down for a specific amount of turns, again depending on what kind of troop it is. The question is: how do I make such a complicated function? Is it even possible in batch? I wanted to make it in batch before progressing to python but I guess this is my first problem. Thanks in advance. Here is my code:

Code: Select all

@echo off
color a
:menu
echo  *************************************
echo *                                     *
echo *        Welcome to SUD!              *
echo * 1. Start                            *
echo * 2. Color Options                    *
echo * 3. Lore                             *
echo * 4. Quit                             *
echo *                                     *
echo *                                     *
echo  *************************************
set /p input:
if %input% == 1 goto start
if %input% == 2 goto CO
if %input% == 3 goto Lore
if %input% == 4 goto quit

:CO
echo  *************************************
echo *                                     *
echo *           Colour Options            *
echo *                                     *
echo * 1. Black and Red                    *
echo * 2. Black and Green                  *
echo * 3. Black and White                  *
echo * 4. Apply                            *
echo *                                     *
echo  *************************************
set /p input:
if %input% == 1 color 0c
if %input% == 2 color 0a
if %input% == 3 color 00
if %input% == 4 goto menu
if %input% == 1 co=1
if %input% == 2 co=2
if %input% == 3 co=3

:Lore
echo A great evil has descended from the world, and you
echo are powerless to stop it. For now. Rise up and
echo and claim your rightful place as the rightful ruler of
echo the kingdom of your ancestors. Challenge yourself
echo through these trying times, and use your skills and
echo tactics to defeat the monstrous evil that threatens
echo to swallow the lands.
pause
goto menu

:quit
echo Are you sure you want to quit? 1. Yes 2. No
set /p input:
if %input% == 1 exit
if %input% == 2 goto menu

:start
set soldiers = 5
set archers = 3
set cavalry = 1
set veterans = 0
set taskforce = 0
set swordmasters = 0
set siege = 0
set gold = 20
set food = 100
set water = 100
set oil = 25
set oils=100
set

echo ===============================================================================
echo Footsoldiers:%Soldiers% Archers:%archers% Veterans:%veterans%
echo Cavalry:%cavalry% Siege Weapons:%siege% Gold:%gold% Task Force:%task force%
echo Food:%food%/100 Water:%water%/100 Oil:%oil%  Sword Masters:%swordmasters%
echo ===============================================================================
echo.
echo.
echo 1. Fight!
echo 2. Hire!
echo 3. Build!
echo 4. Quit! :(
set /p input:
if %input% == 1 goto fight
if %input% == 2 goto hire
if %input% == 3 goto build
if %input% == 4 goto quit2

:hire
echo This is where you can hire troops to expand your army.
echo 1. Foot Soldiers           5 gold per troop
echo 2. Archers                10 gold per troop
echo 3. Veterans               20 gold per troop
echo 4. Task Forces            50 gold per troop
echo 5. Sword Masters          50 gold per troop
echo 6. Siege Weapons         200 gold per troop
echo 7. Done!
echo.
set /p input:
if %input% == 1 goto buys
if %input% == 2 goto buya
if %input% == 3 goto buyv
if %input% == 4 goto buyts
if %input% == 5 goto buysm
if %input% == 6 goto buysw
if %input% == 7 goto start

:buys
echo =======================================
echo How many troops would you like to buy?
echo =======================================
echo.
set /p input:
set %money% - %input% * 5
goto hire

:buya
echo =======================================
echo How many troops would you like to buy?
echo =======================================
echo.
set/p input:
set %money% - %input% * 10
goto hire

:buyv
echo =======================================
echo How many troops would you like to buy?
echo =======================================
echo.
set/p input:
set %money% - %input% * 20
goto hire

:buyts
echo =======================================
echo How many troops would you like to buy?
echo =======================================
echo.
set/p input:
set %money% - %input% * 50
goto hire

:buysm
echo =======================================
echo How many troops would you like to buy?
echo =======================================
echo.
set/p input:
set %money% - %input% * 50
goto hire

:buysw
echo =======================================
echo How many troops would you like to buy?
echo =======================================
echo.
set/p input:
set %money% - %input% * 200
goto hire

:build
echo Here you can build resources that produce resources.
echo 1. Farm               25 gold per farm
echo 2. Well               25 gold per well
echo 3. Butcher's Shop     40 gold per shop
echo 4. Sweet Shop         50 gold per shop
echo 5. Farmer's Market    60 gold per shop
echo 6. Done!
echo.
set /p input:
if %input% == 1 goto buyf1
if %input% == 2 goto buyw1
if %input% == 3 goto buybs1
if %input% == 4 goto buyss1
if %input% == 5 goto buyfm1
if %input% == 6 goto start

:buyf1
echo =======================================
echo How many farms would you like to buy?
echo =======================================
echo.
set /p input:
set %money% - %input% * 25
goto build

:buyw1
echo =======================================
echo How many Wells would you like to buy?
echo =======================================
echo.
set /p input:
set %money% - %input% * 25
goto build

:buybs1
echo =======================================
echo How many shop would you like to buy?
echo =======================================
echo.
set /p input:
set %money% - %input% * 40
goto build

:buyss1
echo =======================================
echo How many shops would you like to buy?
echo =======================================
echo.
set /p input:
set %money% - %input% * 50
goto build

:buyfm1
echo =======================================
echo How many shops would you like to buy?
echo =======================================
echo.
set /p input:
set %money% - %input% * 60
goto build

:quit2
echo Are you sure you want to quit? 1. Yes 2. No
set /p input:
if %input% == 1 exit
if %input% == 2 goto start

:fight
if %health% GTR 100 set health=%health%
if %health% LSS 1 goto lose
cls
echo FIGHT
echo --------------------------------------------------------------------------------
echo You Hp:%health%/10,000
echo Archers:%archers%  Soliders:%soldiers% Siege Weapons:%siegew%
echo --------------------------------------------------------------------------------
echo Enemy Army
echo Hp: %enehealth%/100
echo.
echo 1) Archers
echo 2) Soldiers
echo 3) Task Forces
echo 4) Siege Weapons
echo 5) Sword Masters
echo 6) Veterans
echo.
set /p input=Enter:

if %input% == 1 goto attack
if %input% == 2 goto potion
if %input% == 3 goto spell
if %input% == 4 goto flee
goto fight

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

Re: Batch Terminal Strategy Game

#2 Post by foxidrive » 21 Jan 2016 20:41

You could have a variable that determines which troops are used - a variable can hold the name/number of 2 randomly selected troops, or to hold two troops which are manually entered.

For example you could store the numbers of two troops, and use those numbers in your code:

Code: Select all

@echo off
set attack_troops=4 8
for %%a in (%attack_troops%) do echo using troop %%a to attack with
pause

Another variable for each troop can be used, and decremented on each turn until it reaches zero, when the troop can be used again. All troop variables can be decremented at once in each turn, just include a check so it will not decrement lower than zero.

This is an example of how that counter can be decremented, just displaying how it decrements.
This line handles 30 different troop counters, and 30 can be changed of course.

Code: Select all

@echo off
set troop2_=9
set troop14_=3
set troop21_=0
set troop
pause
for /L %%a in (1,1,30) do for /f "tokens=2 delims==" %%b in ('set troop%%a_ 2^>nul') do if %%b gtr 0 set /a troop%%a_-=1
set troop
pause

Post Reply