The question is below. I am also attaching 2 pictures. This is not graded and please make sure to read what I asked. I can upload a doc of the question so I have copy pasted the question. PLEASE make sure the c++ code works in visual studios Scenario: Two armies go to war. However there is a single bridge that connects both armies. Only one soldier from each army can fit on the bridge at a time. Objective: Simulate a simple battle between the two armies. Restrictions: The soldiers in each army are created with random stats The soldiers fight one at a time Process: Step 1: Create a Soldier class as outlined below. Function “takeDamage” takes an integer and reduce the soldiers hp by that amount. Step 2 : create a WarData class WarData() -> creates the two armies as linked lists (using the STL) “generateArmy1 “ creates and adds soldiers to army1 (linked list) num represents the number of soldiers to be created maxSoldierHealth represents the highest value a created soldier can have (1 is the smallest value) maxDamage represents the highest damage a soldier can do (1 is the smallest value) Each soldier in generate Army1 is created by : -generating a random number between 1 and the maxSoldierHealth for the hp -generatring a random number between 1 and the maxDamage for the damage. Once a Soldier object is created, it is added to the end (back) of the linked list “generateArmy2 “ creates and adds soldiers to army2 (linked list) in a similar fashion as above. SimulateWar() performs the Battle sequence outlined on the next page. showArmyOne() shows the hp and damage of each soldier in army 1. showArmyTwo() shows the hp and damage of each soldier in army 2. Battle sequence for simulateWar: One soldier is removed from the front of each army. These two engage based on the Combat sequence outlined below. The survivor is then added to the back of their army. If one army has no more soldier, the battle is over. Combat sequence of a fight between 2 soldiers: The fight continues until the army1 soldier or army2 soldier has HP of 0 or less. The fight is broken up into rounds (similar to our previous labs) At the start of each round: 1) A random roll out of 100 is done: If the roll is 50 -100, the army1 soldier attacks first (army1 soldier is the attacker, the army2 soldier is the defender) If the roll is 1 - 49, the army2 soldier attacks first (army2 soldier is the attacker, the army1 soldier is the defender) 2) The attacker makes a random roll out of 100. a. If the roll if 50-100, the attacker hits and does their full damage to the defender b. If the roll is 1-49, the attacker misses 3) If the defender is still alive , the defender makes a random roll out of 100. a. If the roll if 50-100, the defender hits and does their full damage to the attacker b. If the roll is 1-49, the defender misses These steps are repeated until the fight ends. The surviving soldier is added to the end of the respective army’s list. The Battle ends when one army has no more soldiers to fight.
The question is below. I am also attaching 2 pictures. This is not graded and please make sure to read what I asked. I can upload a doc of the question so I have copy pasted the question.
PLEASE make sure the c++ code works in visual studios
Scenario: Two armies go to war. However there is a single bridge that connects both armies. Only one soldier from each army can fit on the bridge at a time.
Objective: Simulate a simple battle between the two armies.
Restrictions:
The soldiers in each army are created with random stats
The soldiers fight one at a time
Process:
Step 1: Create a Soldier class as outlined below.
Function “takeDamage” takes an integer and reduce the soldiers hp by that amount.
Step 2 : create a WarData class
WarData() -> creates the two armies as linked lists (using the STL)
“generateArmy1 “ creates and adds soldiers to army1 (linked list)
num represents the number of soldiers to be created
maxSoldierHealth represents the highest value a created soldier can have (1 is the smallest value)
maxDamage represents the highest damage a soldier can do (1 is the smallest value)
Each soldier in generate Army1 is created by :
-generating a random number between 1 and the maxSoldierHealth for the hp
-generatring a random number between 1 and the maxDamage for the damage.
Once a Soldier object is created, it is added to the end (back) of the linked list
“generateArmy2 “ creates and adds soldiers to army2 (linked list) in a similar fashion as above.
SimulateWar() performs the Battle sequence outlined on the next page.
showArmyOne() shows the hp and damage of each soldier in army 1.
showArmyTwo() shows the hp and damage of each soldier in army 2.
Battle sequence for simulateWar:
One soldier is removed from the front of each army. These two engage based on the Combat sequence outlined below. The survivor is then added to the back of their army. If one army has no more soldier, the battle is over.
Combat sequence of a fight between 2 soldiers:
The fight continues until the army1 soldier or army2 soldier has HP of 0 or less.
The fight is broken up into rounds (similar to our previous labs)
At the start of each round:
1) A random roll out of 100 is done:
If the roll is 50 -100, the army1 soldier attacks first (army1 soldier is the attacker, the army2 soldier is the defender)
If the roll is 1 - 49, the army2 soldier attacks first (army2 soldier is the attacker, the army1 soldier is the defender)
2) The attacker makes a random roll out of 100.
a. If the roll if 50-100, the attacker hits and does their full damage to the defender
b. If the roll is 1-49, the attacker misses
3) If the defender is still alive , the defender makes a random roll out of 100.
a. If the roll if 50-100, the defender hits and does their full damage to the attacker
b. If the roll is 1-49, the defender misses
These steps are repeated until the fight ends.
The surviving soldier is added to the end of the respective army’s list.
The Battle ends when one army has no more soldiers to fight.
Step by step
Solved in 2 steps