Download the BattleSystem.zip for a starting codebase.
Prepare the two teams for battle.
You are provided with 3 classes:
A base class named "Character"- Holds an integer for "Strength" and an integer for "HP". Strength is how much damage a unit inflicts when it hits. HP is short for hit points which is how much damage it can take before it is defeated has a virtual get team color function for easy overloading in children
"Enemy" - inherits from "Character", overloads the get team color function to return ConsoleColor.DarkRed or replace it with one that you prefer.
"Player" - Inherits from "Character", overloads the get team color function to return ConsoleColor.DarkBlue or replace it with one that you prefer, needs to be different than the other black is unacceptable.
Create two "Character" arrays:
A "Rivals" array that holds three Enemy objects. This is the computer controlled team.
A "Player" array that holds three Player objects. This is the user's team.
Create the two teams (fill out the arrays):
For the Rival team, randomly generate a "Strength" number from 3 to 5, and an "HP" number from 8 to 12 for each unit.
For the Player's team, take input from the user for a Name, Strength, and HP value for each unit. Keep data validation in mind - how do we keep a user from entering a string instead of a number for HP?
Gameplay
The two teams battle until only one remains.
Track the current turn from inside the game loop.
You should have a variable in your core game loop that is capable of holding whether it's the players turn or the computers turn.
Think carefully about how arrays are indexed! If you have an array of three players, remember they are index 0, 1, and 2. (that 1st element is index 0)
Each turn, there should be an attack.
The user can decide which unit will do the attacking, then who to attack on the enemy team.
The enemy will decide randomly who will attack and which player unit to attack.
Take the attacker's "Strength" value and subtract it from the defender's "HP" value.
After each turn, the screen should display the current status of all the units.
Conclusion
Display the results.
When all of one side's units are at 0 "HP" or below, the side is defeated and the core loop ends.
Display the results - who won? The player or the enemy?
Additional Goals
1. Stat Check - Allow the player to input what values their characters have, validate data entry from the player so they can't cheat on their "Strength" and "HP" totals. Limit them to the same conditions the enemy has: 8->12 for HP and 3->5 for Strength.
2. Magic Attack - Create an option for the player where they can cast a magic spell. There should be two options. One is an offensive spell that uses the "Strength" stat and attacks everyone in the enemy party. The other is a healing spell that heals a party member of your choosing for 3 "HP".
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.
Kindly complete the form.
Please provide a valid email address and we will get back to you within 24 hours.
Payment is through PayPal, Buy me a Coffee
or Cryptocurrency.
We are a nonprofit organization however we need funds to keep this organization operating
and to be able to complete our research and development projects.