Question: Hello I have this Program that I want the answer for please. I need to define these function so the program will run as following:
Hello I have this Program that I want the answer for please.
I need to define these function so the program will run as following: User will input 5 names for 5 characters, and 1 name for a boss character. They will then take turn attacking each other, and whoever run out of HP first wins.
HP should be from 300~ 500 for characters with evasion and critical chance from 5 to 15, damage from 10 to 15 and damage range from 15 to 20.
Boss HP should be 6 times that of a normal character, with no evasion or critical and 3 times a normal character damage and range.
define the functions below base on BossFight.h
void getParty();
void getBoss();
void displayFightResults(bool partyWon);
void bossAttacksArea();
int takeTurn();
int turnNum, fightsStarted, fightsWon;
If possible I would like a screenshot of the output.
Thank You.
Provided Files:
Bossfight.h :
#pragma once
#include
//Combat stats for a fighter
struct Gladiator {
std::string name;
int dmgMin, dmgRange,
evasion, critical,
maxHealth, curHealth;
};
const int PSIZE = 5;
//Allows for a fight between a team of five gladiators and a very powerful foe
class BossFight {
private:
//Holds the party of gladiators that is banded together to fight the boss
Gladiator party[PSIZE];
//Holds the powerful boss that the party is fighting
Gladiator boss;
//Variables used for record keeping
int turnNum, fightsStarted, fightsWon;
//Will fill the party with gladiators, this function can call/reuse the createGladiator function.
void getParty();
//Will generate a boss for the party to fight. Has no crit or evasion, but 3* damage min and range, and 6* health
void getBoss();
//Tells the user who won, after how many turns, and the current record for the session
void displayFightResults(bool partyWon);
//One turn occurs, where each party member attacks the boss, then the boss attacks the party.
//Returned value indicates status of fight (continue, party win, party loss)
//Boss will randomly choose between attacking a single (randomly chosen) party member for full damage, or
//attacking the full party for half damage.
int takeTurn();
//Handles dealing damage to the entire party
void bossAttacksArea();
public:
//Responsible for generating the party and the boss, should initialize the other
//private variables as well
BossFight();
//User calls this when they want to run a fight. It will ask them if they want to use
//the same party, or get a new one.
void runFight();
};
//Functions that don't need to be part of our class, but may be useful:
//Generates stats and reads input to form a gladiator
//void generateFighter(Gladiator & g)
//off attacks def, removing HP after calculating damage + modifiers
//void attack(Gladiator off, Gladiator& def)
Driver.cpp:
//Driver program for our BossFight class
#include
#include
#include
#include "BossFight.h"
using namespace std;
int main()
{
srand(time(NULL));
BossFight b;
char doAgain = 'y';
while (toupper(doAgain) == 'Y') {
b.runFight();
cout << "Go again? y/n ";
cin >> doAgain;
}
}
Using Classes
Define the functions declared in BossFight.h so that main.cpp produces results similar to when BossFight.obj is included in the project
For each turn, each member of the party will attack the boss, then the boss will attack the party: either one full damage attack on one member, or a damage attack on the entire party.
Driver.cpp contains the driver that will run the declared functions to ensure they work properly, it does not need to be altered or submitted.
BossFight.h contains the declarations and function prototypes related to the class, it does not need to be altered or submitted.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
