Question
I need help with this one please. Need the tournament .hpp and .cpp, the HarryPotter .hpp and .cpp, the Medusa .hpp and .cpp. The other
I need help with this one please. Need the "tournament" .hpp and .cpp, the "HarryPotter" .hpp and .cpp, the "Medusa" .hpp and .cpp. The other codes and criteria are below.
In this C++ project, you will create a simple class hierarchy as the basis for a fantasy combat game. Your universe contains Vampires, Barbarians, Blue Men, Medusa and Harry Potter. Each has characteristics for attack, defense, armor, and strength points as follows.
Type | Attack | Defense | Armor | Strength Points |
Vampire1 | 1d12 | 1d6* Charm | 1 | 18 |
Barbarian2 | 2d6 | 2d6 | 0 | 12 |
Blue Men3 | 2d10 | 3d6 | 3 | 12 *Mob |
Medusa4 | 2d6* Glare | 1d6 | 3 | 8 |
Harry Potter5 | 2d6 | 2d6 | 0 | 10/20*Hogwarts |
Suave, debonair, but vicious and surprisingly resilient!
Think Conan or Hercules from the movies. Big sword, big muscles, bare torso.
They are small (6 tall), fast and tough. So they are hard to hit and can take some damage. As for the attack value, you can do a LOT of damage when you can crawl inside the armor or clothing of your opponent.
Scrawny lady with snakes for hair. They help with fighting. Just dont look at her!
Why are you reading this? How can you not know who Harry Potter is?
3d6 is rolling three 6-sided dice, 2d10 is rolling two 10-sided dice, etc.
*Charm: Vampires can charm an opponent into not attacking. For a given attack there is a 50% chance that their opponent does not actually attack them.
*Glare: If a Medusa rolls a 12 in attack, then the target has looked her in the eyes and is turned to stone. The Medusa wins! If Medusa uses Glare on Harry Potter on his first life, then Harry Potter get back to life. If the Vampire's Charm ability activates versus Medusa's Glare, the Vampire's Charm trump the Glare.
*Mob: The Blue Men are actually a swarm of small individuals. For every 4 points of damage (round down), they lose one defense die. For example, when they reach strength of 8 they only have 2d6 for defense.
*Hogwarts: If Harry dies (i.e. strength <=0), he immediately recovers and his total strength becomes 20. If he were to die again, then hes dead.
//--------------------------------------------------------------------
Goals
Use linked structures to hold and manipulate data
Modify an existing parent abstract class
Project
In this project, you will write a program to run a tournament. Start with your project 3 program for creatures. If you had issues with project 3 and need to begin fresh, reference the creature descriptions from project 3 to build your fighters.
This is a one-user-two-players game. A user will enter the number of fighters both players will use. (You can limit the number of fighters in each team, but set it a little bit larger, like 10, or 20 to allow the enough testing.) The user should also enter the type of creatures and fighter names. You can give fighters different names. So player As first fighter could by Harry Potter and he could name the Harry Potter Creature "Larry Snotter" or just Harry Potter No.1. One team could have more than 1 of the same character (e.g. Team A has 3 members: 2 barbarians and 1 harry potter). The first player supplies a lineup of creatures in order. The second player then supplies his lineup of creatures in order. By lineup I mean something like a batting order in baseball or softball. The head of each lineup fight in the same way they fight in project 3. The winner gets put at the back of her/his teams lineup; the loser goes to the container for those who lost (there should be only one loser pile shared between both sides). The lineup order cannot be changed once the players are entered. Similarly, the loser pile should have the last loser at the top and the first loser at the bottom.
Even if a creature wins, she/he may have taken damage. You should restore some percentage of the damage when they get back in line. Make this simple as you are adding a new member function to the parent class. Some examples are: generate a random integer in some ranges, e.g., on a roll of 5 they recover 50% of the damage they lost, or some scheme of your own. If you want to use a different recovery function for each character, that is fine. Remember to use polymorphism if the recovery is different for different creatures!
After each round, you will display which type of creatures fought and which won on screen (For example, Round 1: Team A Blue man No.1 VS. Team B Harry Potter No.1, Harry Potter No.1 won!). At the end of the tournament (when one team or both run out of fighters in the lineup), your program will display final total points for each team (you can determine how to score each round of fight, for example, winner team +2, loser team -1, tie +1). You must display which team won the tournament. This is another element you must define in the analysis and design stage. You must have a method to determine the winner and you can determine it by yourself. Also provide an option at the end of the tournament to display the contents of the loser pile, i.e. print them out in order with the loser of the first round displayed last.
You should be using polymorphism and all creatures will inherit from the Creature class. Each object should be instantiated and put into their lineup. You will only use pointers to creatures in your program. A creature pointer can then be used to indicate an object of a subclass and polymorphism will ensure the correct function is called. Ask your TA if you are uncertain what this means.
NOTE: Depending upon your implementation in Project 3, you could have ties. How does that tie change your end of match logic? What do you do if the final match is a tie? Specifically, where do you put the fighters? For this program, you should use stack-like or queue-like structures to hold the lineups and the loser pile. Which will you use for the lineup? Which will you use for the loser pile?
This is a programming assignment and not a complete game! Other than entering the lineup, the players just wait for the results. They should take no further actions. Make sure you test your program with instances of all creature types youve created. You may not be able to do an exhaustive test, but make it as extensive as you can. In the menu, please add an option that ask players if they would like to play againonce the winner has been declared (it's nice for grading since we run it multiple times).
For this project, 4 please use your own containers like queue and linked list instead of the STL containers.
//barbarian.hpp
#ifndef BARBARIAN_hpp
#define BARBARIAN_hpp
#include
#include
#include
//#include "tournament.hpp"
using namespace std;
class Barbarian:public Creature
{
private:
public:
Barbarian(int, int, string, string);
virtual int attack();
virtual void defense(int);
};
#endif
barbarian.cpp
//#include "barbarian.hpp"
Barbarian::Barbarian(int arm, int sp, string type, string name): Creature(arm, sp, type, name)
{
}
int Barbarian::attack() {
int damage = 0;
damage += rand()%6 + 1;
damage += rand()%6 + 1;
return damage;
}
void Barbarian::defense(int damage)
{
int damage_INF = 0;
int defense = 0;
defense += rand()%6 + 1;
defense += rand()%6 + 1;
damage_INF = damage - defense - armor;
if(BB)
{
cout << "Defense roll: " << defense < cout << "Armor: " << armor < cout << "Total damage_INF: " << damage_INF < } if(damage_INF > 0) { s_Point -= damage_INF; } } //bluemen.hpp #ifndef BLUEMEN_hpp #define BLUEMEN_hpp #include #include #include //#include "tournament.hpp" using namespace std; class BlueMen:public Creature { private: public: BlueMen(int, int, string, string); virtual int attack(); virtual void defense(int); int mob(int); }; #endif //bluemen.cpp //#include "bluemen.hpp" BlueMen::BlueMen(int arm, int sp, string type, string name): Creature(arm, sp, type, name) { //SETS INHERITED MEMBERS :) } int BlueMen::attack() { int damage = 0; damage += rand()%10 + 1; damage += rand()%10 + 1; return damage; } void BlueMen::defense(int damage) { int damageINF = 0; int defense = 0; defense = mob(s_Point); //mob method damage_INF = damage - defense - armor; if(BB) { cout << "Defense roll: " << defense < cout << "Armor: " << armor < cout << "Total damageINF: " << damage_INF < } if(damage_INF > 0) { s_Point -= damage_INF; } } int BlueMen::mob(int strength) { int def; if(strength > 0 && strength < 5) { if(BBB) { cout << endl << "***Only 1 mob, using 1 die***" < } def = rand()%6 + 1; //use 1 die return def; } else if(strength > 4 && strength < 9) { if(BBB) { cout << endl << "***Only 2 mobs, using 2 dice***" < } def = rand()%6 + 1; //use 2 die def += rand()%6 + 1; return def; } else { if(BB) { cout << endl << "***Mobs at full force! Using 3 dice***" < } def = rand()%6 + 1; //use 3 die def += rand()%6 + 1; def += rand()%6 + 1; return def; } } //creature.hpp #ifndef CREATURE_hpp #define CREATURE_hpp #include #include #include using namespace std; class Creature { protected: int ar; int s_Point; int gold_Point; string creature_Type; string name; int type; bool BB; int team; public: Creature(); Creature(int, int, string, string); int get_ar(); int get_s_Point(); int get_gold_Point(); string get_creature_Type(); string get_Name(); int get_Type(); bool get_BB(); int get_team(); void set_ar(int); void set_s_Point(int); void set_gold_Point(int); void set_creature_Type(string); void set_Name(string); void set_Type(int); void set_BB(bool); void set_team(int); void roll_Gold(); void restore_Points(); virtual int attack() = 0; virtual void defense(int) = 0; }; #endif //creature.cpp //#include "creature.hpp" Creature::Creature() { } Creature::Creature(int armor, int sPoints, string cType, string name) { set_Armor(armor); set_s_Point(s_Point); set_Creature_Type(c_Type); set_Name(name); gold_Points = 0; } int Creature::get_Armor() { return armor; } int Creature::get_s_Point() { return s_Point; } int Creature::get_Gold_Point() { return gold_Point; } string Creature::get_Creature_Type() { return creature_Type; } string Creature::get_Name() { return name; } int Creature::get_Type() { return type; } bool Creature::get_BB() { return BB; } int Creature::get_team() { return team; } void Creature::set_Armor(int a){ armor = a; } void Creature::set_s_Point(int s) { s_Point = s; } void Creature::set_Gold_Point(int gp) { gold_Point += gp; } void Creature::setCreatureType(string ct) { creature_Type = ct; } void Creature::setName(string c_Name) { name = cName; } void Creature::set_Type(int t) { type = t; } void Creature::set_BB(bool b) { BB = b; } void Creature::set_team(int t) { team = t; } void Creature::roll_Gold() { int gold; gold = rand()%5 + 1; set_Gold_Point(gold); } void Creature::restore_Point() { int point_Restored; point_Restored = get_s_Point() + (((rand()%5 + 1)/10)*get_s_Point()); if(point_s_Restored < 0) { point_s_Restored = point_s_Restored * -1; } set_s_Points(point_s_Restored); } //main.cpp #include #include #include //#include "tournament.hpp" using namespace std; int main() { unsigned seed; seed = time(0); srand(seed); Tournament test; test.menu(); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started