NOTE: OUTPUT HAS TO LOOK SPECIFIED WAY BELOW. MAKE SURE FIREBALL AND POTION WORK
ID: 3847099 • Letter: N
Question
NOTE: OUTPUT HAS TO LOOK SPECIFIED WAY BELOW. MAKE SURE FIREBALL AND POTION WORK.
Introduction
Focuses on combat between a player and series of monsters. Inheritance will be required to make all the monsters different without changing how battles work.
In this game a hero will encounter and fight a series of enemies.
NOTE: The description below is a bare minimum requirement specification. As your final assignment, you have a lot of implementation freedom and hope you have fun thinking about things like pass/return by reference, const parameters/functions, data types, enumeratrion, classes, encapsilation, overloading, inheritance, dynamic memory, etc.. We want to get used to good design and implementation decisions early and often!
Part 1: The Enemy
Make an enemy class. This will be the parent class of every monster our hero has to fight. It will supply the minimum functions that are needed for a monster to exist in the game.
This is an abstract class, all your methods (with the exception of the constructor) should be virtual and set =0.
A good starting point for you enemy class is as follows:
A way to check how much health the enemy has.
A way to damage the enemy.
An attack method for the enemy to damage another enemy.
A method that prints to the console information about the enemy so the player knows who they are fighting.
The hero will also be a kind of enemy. (It is the enemy to the monsters.)
Part 2: Make Monsters
Create 5 types of monsters, each derived from your Enemy class/interface. All your monsters must meet the following requirements:
Can be defeated.
Can attack an enemy and take damage from and enemy.
Additionally, at least 1 of your monsters MUST have multiple attacks that it decides between at random.
Part 3: Make a Hero
The hero is just a kind of enemy!
Create a hero class that implements the enemy interface. You will need to get input for the user to decide what attack to do.
A hero has the following properties:
A hero has a name, chosen by the player.
A hero has health bar
A hero has 6 potions that each heals some points of damage.
A hero has 10 fireballs, each do damage. (More damage then the sword.)
A hero has a sword that does damage.
A hero has a shield. When the shield is up the hero can't attack but attacks on them only do half damage.
When it is the hero's attack method is called, print out the hero's status and ask for input on which attack to use. Then do what is requested by the player.
The player may quit the game at any time by saying their action is "exit". You will need to use an exception to break out of the code and exit the program when this happens.
Part 4: The Game
Implement a main program that plays the game. The game should go as follows:
Ask for the Hero's name
Ask the user for how many Enemies there will be (you may assume they will enter a positive integer)
Create the number of enemies requested in (2) whose types are randomly selected from your pool of 5 potential enemy types.
For each enemy (you will fight them one at a time)
Print out what monster is attacking
Fight until the enemy or hero is dead
If the monster died, print that out.
Either declare the hero victorious or dead.
A single round of combat should go as follows:
Hero attacks
If the monster is alive, it attacks
Reminder: The player can type exit at any time to throw an exception. If this happens, you should tell the player "Thanks for Playing" and exit the program.
Here is an example of how the game could look with 2 monsters.
Welcome to Adventure Battle!
What is the name of your hero?
Cloud
How many enemies do you want Cloud to battle?
2
You have encountered a Bat!
Cloud: 100/100 health Remaining: 10 Fireballs, 6 Potions
Enter Command: sword shield fireball potion exit
shield
Hide Behind Shield!
Bat bites you!
Cloud: 98/100 health Remaining: 10 Fireballs, 6 Potions
Enter Command: sword shield fireball potion exit
sword
Sword Slash Attack!
Bat bites you!
Cloud: 93/100 health Remaining: 10 Fireballs, 6 Potions
Enter Command: sword shield fireball potion exit
sword Sword Slash Attack!
Enemy is defeated!
You have encountered a Wolf!
Cloud: 93/100 health Remaining: 10 Fireballs, 6 Potions
Enter Command: sword shield fireball potion exit
potion
You drank a potion.
Wolf scratches you!
Cloud: 85/100 health Remaining: 10 Fireballs, 5 Potions
Enter Command: sword shield fireball potion exit
fireball
Fireball Attack Successful!
Wolf scratches you!
Cloud: 70/100 health Remaining: 9 Fireballs, 5 Potions
Enter Command: sword shield fireball potion exit
fireball
Fireball Attack Successful!
Enemy is defeated!
You have defeated all enemies and saved the world. Good Job.
Finishing Up
All five of your monsters (h and cpp files) with at least 1 monster that has random attacks.
The hero header and cpp file.
The main file used to implement the game.
Monster.h
#ifndef _BATTLE_MONSTER_
#define _BATTLE_MONSTER_
#include
using namespace std;
//This class defines a generic monster
//It doesn't actually DO anything.
//It just gives you a template for how a monster works.
//We can make any number of monsters and have them fight
//they just all need to INHERIT from this one so that work the same way
//Since this class is not intended to be used
//none of the methods do anything
//The virtual command means we want the children to override these.
//The =0 part means these function's won't even work if you tried.
//This class is impossible to use by itself.
class monster
{
public:
monster();
//Name the monster we are fighting
//The description is printed at the start to give
//additional details
virtual string getName() const=0;
virtual string getDescription() const=0;
//Basic Attack Move
//This will be the most common attack the monster makes
//You are passed a pointer to the monster you are fighting
virtual void basicAttack(monster * enemy)=0;
//Print the name of the attack used
virtual string basicName() const=0;
//Defense Move
//This move is used less frequently to
//let the monster defend itself
virtual void defenseAttack(monster * enemy)=0;
//Print out the name of the attack used
virtual string defenseName() const=0;
//Special Attack
//This move is used less frequently
//but is the most powerful move the monster has
virtual void specialAttack(monster * enemy)=0;
virtual string specialName() const=0;
//Health Management
//A monster at health <= 0 is unconscious
//This returns the current health level
virtual int getHealth() const=0;
//This function is used by the other monster to
//either do damage (positive int) or heal (negative int)
virtual void doDamage(int damage) =0;
//Reset Health for next match
virtual void resetHealth() = 0;
};
#endif
monster.cpp
#include "monster.h"
//Since we don't actually want these to be used they don't need to be useful
//Abstract Classes are another way to do this, but they will come later
monster::monster(){}
hamster.h
#ifndef _HAMSTER_
#define _HAMSTER_
#include
#include "monster.h"
using namespace std;
//This is a hamster.
//It is a very weak monster.
class hamster : public monster
{
private:
string my_name;
int my_health;
bool defense_mode;
public:
hamster(string n="No Name");
//redefine all the Methods of monster
//Note: we can make more methods if we want, but
//we need to redfine the methods of monster
//because those are the ones that will be used in the game.
string getName() const;
string getDescription() const;
void basicAttack(monster * enemy);
string basicName() const;
void defenseAttack(monster * enemy);
string defenseName() const;
void specialAttack(monster * enemy);
string specialName() const;
int getHealth() const;
void doDamage(int damage);
void resetHealth();
};
#endif
hamster.cpp
#include "hamster.h"
hamster::hamster(string n)
{
my_name = n;
my_health=20;
defense_mode=false;
}
string hamster::getName() const
{
return my_name;
}
string hamster::getDescription() const
{
return "The hamster is both fluffy and friendly.";
}
void hamster::basicAttack(monster * enemy)
{
defense_mode=false;//Can't defend and attack
enemy->doDamage(2);
}
string hamster::basicName() const
{
return "Bite";
}
void hamster::defenseAttack(monster * enemy)
{
defense_mode=true;
}
string hamster::defenseName() const
{
return "Hide";
}
void hamster::specialAttack(monster * enemy)
{
defense_mode=false;//Can't defend and attack
enemy->doDamage(3);
}
string hamster::specialName() const
{
return "Ravenous Fury";
}
int hamster::getHealth() const
{
return my_health;
}
void hamster::doDamage(int damage)
{
if(defense_mode)
{
//Defense mode cuts damage in half
my_health=my_health-(damage/2);
}else
{
my_health=my_health-damage;
}
}
void hamster::resetHealth()
{
my_health=20;
}
Explanation / Answer
main.cpp
#include <iostream>
#include <string>
#include <stdlib.h> //This is where random numbers live
#include <time.h> //To set the random number generator
#include "Hero.h"
#include "Enemy.h"
#include "Dragon_Turtle.h"
#include "Aquariuz.h"
#include "Garm.h"
#include "Wiingy.h"
#include "Shane.h"
void print_results(enemy* attacker, enemy* defender, string attack, int hchange);
int cast = 10;
int potions = 6;
enemy* battle(enemy* e1, enemy* e2)
{
//e1->resetHealth();
e2->resetHealth();
cout << "Starting Battle Between " << endl;
cout << e1->getName() << endl;
cout << e2->getName() << ": " << e2->getDescription() << endl;
enemy* attacker = NULL;
enemy* defender = NULL;
attacker = e2;
defender = e1;
cout << attacker->getName() << " goes first. " << endl;
//AI
//Using code from previous lab.
while (e1->getHealth() > 0 && e2->getHealth() > 0)
{
int move = rand() % 100 + 1;
int before_health = defender->getHealth();
if (move >= 1 && move <= 30)
{
//Attack 1
attacker->attackOne(defender);
print_results(attacker, defender, attacker->attackOneName(), before_health - defender->getHealth());
}
if (move >= 31 && move <= 50)
{
//Attack 2
attacker->attackTwo(defender);
print_results(attacker, defender, attacker->attackTwoName(), before_health - defender->getHealth());
}
if (move >= 51 && move <= 55)
{
//Attack 3
attacker->attackThree(defender);
print_results(attacker, defender, attacker->attackThreeName(), before_health - defender->getHealth());
}
if (move >= 56 && move <= 80)
{
//Attack 4
attacker->attackFour(defender);
print_results(attacker, defender, attacker->attackFourName(), before_health - defender->getHealth());
}
if (move >= 81 && move <= 100)
{
//Heal/block/defensive move
attacker->usePotion(attacker);
print_results(attacker, attacker, attacker->usePotionName(), before_health - attacker->getHealth());
}
//Player
int before_health_2 = attacker->getHealth();
int choice;
cout << "It's your turn, what do you want to do. " << endl;
cout << "Attack(1), Shield(2), Fireball(3), Potion(4), Exit(5)." << endl;
cin >> choice;
if (choice == 1)
{
//70% chance of dealing normal damage
if (move >= 1 && move <= 70)
{
defender->attackOne(attacker);
print_results(defender, attacker, defender->attackOneName(), before_health_2 - attacker->getHealth());
}
//30% chance of dealing a critical blow
if (move >= 71 && move <= 100)
{
defender->attackTwo(attacker);
print_results(defender, attacker, defender->attackTwoName(), before_health_2 - attacker->getHealth());
}
}
else if (choice == 2)
{//Shield blocks 100%
defender->attackFour(attacker);
print_results(defender, attacker, defender->attackFourName(), before_health_2 - attacker->getHealth());
}
else if (choice == 3)
{
//Fireballs
if (cast > 0)
{
cast--;
defender->attackThree(attacker);
print_results(defender, attacker, defender->attackThreeName(), before_health_2 - attacker->getHealth());
cout << cast << " remaining fireballs " << endl;
}
else
cout << "No more fireballs" << endl;
}
else if (choice == 4)
{
//40 HP potions
if (potions > 1)
{
potions--;
defender->usePotion(defender);
print_results(defender, defender, defender->usePotionName(), before_health_2 - defender->getHealth());
cout << "You used potion and healed for 40" << endl;
cout << potions << " remaining potions" << endl;
}
else
{
//bug, it will, for some reason, continue healing even after 0 potions are left when there is no code for it to run.
//not sure how to fix it.
cout << "No more potions" << endl;
}
}
else if (choice == 5)
{
cout << "Thanks for playing the game" << endl;
return 0;
}
else if (choice != 1 || choice != 2 || choice != 3 || choice != 4 || choice != 5)
{
cout << "Yea... your turn is over because of your decision." << endl;
}
cout << e1->getName() << " at " << e1->getHealth() << " health." << endl;
cout << e2->getName() << " at " << e2->getHealth() << " health." << endl;
}
if (e1->getHealth() < 1 && e2->getHealth() < 1)
{
cout << "Both the hero and the enemy died. You might have reached " << e2->getName() << " but your efforts are useless. You will never see your home again." << endl;
return NULL;
}
if (e1->getHealth() < 1)
{
cout << e2->getName() << " destroyed you. You will never see the world again" << endl;
return e2;
}
if (e2->getHealth() <1)
{
cout << "You defeated " << e2->getName() << endl;
return e1;
}
cout << "ugh, I don't know what happened" << endl;
return NULL;
}
void print_results(enemy* attacker, enemy* defender, string attack, int hchange)
{
cout << attacker->getName() << " used " << attack;
cout << " on " << defender->getName() << endl;
cout << "The attack did " << hchange << " damage." << endl;
}
int main()
{
string name;
string choice;
cout << "Welcome to our world Hero." << endl;
cout << "What's your name?" << endl;
getline(cin, name);
cout << "Wait, you aren't the chosen one." << endl;
cout << "Yes... yes... anyway, you will do " << name << " your mission is to go to the top of the mountain and kill Garm." << endl;
cout << "You can't go back to your world until you kill him because he was the one who summoned you for some reason." << endl;
cout << "Here you go, a sword, armor, the all mighty spell in a flask and potions." << endl;
cout << "Go Hero!" << endl;
cout << endl << endl;
cout << "Instructions, You have 5 choices, attack, defend, magic, heal and escape." << endl;
cout << "Press the number key besides the word to activate it. If you press something else it might cause your death." << endl;
cout << "Understood? y/n" << endl;
getline(cin, choice);
if (choice == "y")
{
enemy* first = new Hero(name);
enemy* second = new Aquariuz("Aquariuz");
enemy* Third = new Shane("Shane");
enemy* Fourth = new Garm("Garm");
enemy* Fifth = new Dragon_Turtle("Dragon_Turtle");
enemy* Final = new Wiingy("Wiingy");
enemy* FightOne = battle(first, second);
if (second->getHealth() < 1)
{
cout << first->getDescription() << endl;
cout << "You have defeated Aquariuz, like, wth was that fight." << endl;
enemy* FightTwo = battle(first, Third);
if (Third->getHealth() < 1)
{
cout << "You just killed Shane, The right hand of Garm. His heals were strong right?" << endl;
enemy* FightThird = battle(first, Fourth);
if (Fourth->getHealth() < 1)
{
cout << "Did... did he just kill himself?" << endl;
cout << "Time to go back..." << endl << endl;
cout << "What the Heck is this." << endl;
enemy* FightFourth = battle(first, Fifth);
if (Fifth->getHealth() < 1)
{
cout << "WHAT THE HECK, THIS WASN'T A MOUNTAIN, AND WHAT THE HECK JUST APPEARED?!" << endl;
enemy* FightFinal = battle(first, Final);
cout << "YOU HAVE DEFEATED THE MASTER MIND!" << endl;
}
}
}
}
}
else
{
cout << "well, I will close the game" << endl;
return 0;
}
}
Wiingy.h
#ifndef Wiingy_
#define Wiingy_
#include <string>
#include "Enemy.h"
using namespace std;
//Last boss
class Wiingy : public enemy
{
private:
string my_name;
int my_health;
bool heal;
public:
Wiingy(string n = "Wiingy");
string getName() const; //Not sure if I actually need this
string getDescription() const;
virtual void attackOne(enemy * target);
virtual void attackTwo(enemy * target);
virtual void attackThree(enemy * target);
virtual void attackFour(enemy * target);
virtual void usePotion(enemy * target);
virtual string attackOneName()const;
virtual string attackTwoName()const;
virtual string attackThreeName()const;
virtual string attackFourName()const;
virtual string usePotionName()const;
int getHealth() const;
void doDamage(int damage);
void resetHealth();
};
Wiingy::Wiingy(string n)
{
my_name = n;
my_health = 200;
heal = false;
}
string Wiingy::getName()const
{
return my_name;
}
string Wiingy::getDescription()const
{
return "After killing The Dragon Turtle, a Winged creature appears. Wiingy, the The Eternal appears. She managed to kill 9 people in less than 10 seconds.";
}
void Wiingy::attackOne(enemy* target)
{
//30% chance
heal = false;
target->doDamage(8);
for (int i = 0; i < rand() % 5; i++)
{
target->doDamage(4);
if(i>3)
my_health -= 4;
}
//idea taken from http://i.imgur.com/2jNYQp2.jpg
}
void Wiingy::attackTwo(enemy* target)
{
//20% chance
heal = false;
target->doDamage(15);
}
void Wiingy::attackThree(enemy* target)
{
//5% chance
for (int i = 0; i < 9; i++)
{
target->doDamage(rand() % 5);
}
}
void Wiingy::attackFour(enemy* target)
{
//25% chance
heal = false;
target->doDamage(3);
if (my_health <= 100)
{
my_health = my_health + (rand() % 20);
}
else
target->doDamage(17);
}
void Wiingy::usePotion(enemy* target)
{
//20%
heal = true;
}
string Wiingy::attackOneName() const
{
return "Wiingy said "No, no no no" in a high pitch";
}
string Wiingy::attackTwoName() const
{
return "Pew Pew Pew";
}
string Wiingy::attackThreeName() const
{
return "Savage";
}
string Wiingy::attackFourName() const
{
return "Salute the Sun";
}
string Wiingy::usePotionName() const
{
return "Magical Trip";
}
int Wiingy::getHealth()const
{
return my_health;
}
void Wiingy::doDamage(int damage)
{
if (heal)
{
my_health += 30;
}
else
{
my_health = my_health - damage;
}
}
void Wiingy::resetHealth()
{
my_health = 200;
}
#endif
Shane.h
#ifndef SHANE_
#define SHANE_
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "Enemy.h"
using namespace std;
//Second Boss
class Shane : public enemy
{
private:
string my_name;
int my_health;
bool heal;
public:
Shane(string n = "Shane");
string getName() const; //Not sure if I actually need this
string getDescription() const;
virtual void attackOne(enemy * target);
virtual void attackTwo(enemy * target);
virtual void attackThree(enemy * target);
virtual void attackFour(enemy * target);
virtual void usePotion(enemy * target);
virtual string attackOneName()const;
virtual string attackTwoName()const;
virtual string attackThreeName()const;
virtual string attackFourName()const;
virtual string usePotionName()const;
int getHealth() const;
void doDamage(int damage);
void resetHealth();
};
Shane::Shane(string n)
{
my_name = n;
my_health = 50;
heal = false;
}
string Shane::getName()const
{
return my_name;
}
string Shane::getDescription()const
{
return "Told by the community to be the Ameno guy";
}
void Shane::attackOne(enemy* target)
{
//30% chance
heal = false;
my_health = my_health + 20;
if (my_health > 100)
{
target->doDamage(rand()%20);
}
}
void Shane::attackTwo(enemy* target)
{
//20% chance
heal = false;
target->doDamage(15);
my_health = my_health + 5;
}
void Shane::attackThree(enemy* target)
{
//5% chance
heal = false;
if (my_health <= 20)
{
my_health += 50;
}
else
{
target->doDamage(25);
}
}
void Shane::attackFour(enemy* target)
{
//25% chance
heal = false;
target->doDamage(rand() % 10);
for (int i = 0; i < rand() % 3; i++)
{
target->doDamage(rand()%5);
}
}
void Shane::usePotion(enemy* target)
{
//20%
heal = true;
}
string Shane::attackOneName() const
{
return "Ameno";
}
string Shane::attackTwoName() const
{
return "Music Bot";
}
string Shane::attackThreeName() const
{
return "Be a MAN!";
}
string Shane::attackFourName() const
{
return "SANDSTORM";
}
string Shane::usePotionName() const
{
return "Teleport";
}
int Shane::getHealth()const
{
return my_health;
}
void Shane::doDamage(int damage)
{
if (heal)
{
my_health = my_health;
}
else
{
my_health = my_health - damage;
}
}
void Shane::resetHealth()
{
my_health = 50;
}
#endif
Hero.h
#ifndef HERO_
#define HERO_
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "Enemy.h"
using namespace std;
//Easy Monster, first encounter
class Hero : public enemy
{
private:
string my_name;
int my_health;
bool heal;
bool shield;
public:
Hero(string n = "Hero");
string getName() const; //Not sure if I actually need this
string getDescription() const;
virtual void attackOne(enemy * target);
virtual void attackTwo(enemy * target);
virtual void attackThree(enemy * target);
virtual void attackFour(enemy * target);
virtual void usePotion(enemy * target);
virtual string attackOneName()const;
virtual string attackTwoName()const;
virtual string attackThreeName()const;
virtual string attackFourName()const;
virtual string usePotionName()const;
int getHealth() const;
void doDamage(int damage);
void resetHealth();
};
Hero::Hero(string n)
{
my_name = n;
my_health = 200;
heal = false;
}
string Hero::getName()const
{
return my_name;
}
string Hero::getDescription()const
{
return "Oh great Hero from another dimension. Your objective is to reach the top of the mountain and defeat Garm, the autistic villain. Oh, you will see this a lot.";
}
void Hero::attackOne(enemy* target)
{
//Sword - 70%
heal = false;
shield = false;
target->doDamage(10);
//no one said anything about magical swords
if (my_health <= 100)
{
target->doDamage((rand()%15)+10);
}
}
void Hero::attackTwo(enemy* target)
{
//Critical Sword - 30%
heal = false;
shield = false;
target->doDamage((rand()%10)+20);
}
void Hero::attackThree(enemy* target)
{
//Fireball
heal = false;
shield = false;
target->doDamage((rand()%30)+20);
}
void Hero::attackFour(enemy* target)
{
//Shield
heal = false;
shield = true;
}
void Hero::usePotion(enemy* target)
{
heal = true;
shield = false;
}
string Hero::attackOneName() const
{
return "Sword Slice!";
}
string Hero::attackTwoName() const
{
return "Sword Slash";
}
string Hero::attackThreeName() const
{
return "Fireball!";
}
string Hero::attackFourName() const
{
return "Block!";
}
string Hero::usePotionName() const
{
return "Potion";
}
int Hero::getHealth()const
{
return my_health;
}
void Hero::doDamage(int damage)
{
if (heal)
{
my_health += 40;
}
else if (shield)
{
my_health = my_health-(damage/2);
}
else
{
my_health = my_health - damage;
}
}
void Hero::resetHealth()
{
my_health = 200;
}
#endif
Garm.h
#ifndef GARM_
#define GARM_
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "Enemy.h"
using namespace std;
//Third boss
class Garm : public enemy
{
private:
string my_name;
int my_health;
bool heal;
public:
Garm(string n = "Garm");
string getName() const; //Not sure if I actually need this
string getDescription() const;
virtual void attackOne(enemy * target);
virtual void attackTwo(enemy * target);
virtual void attackThree(enemy * target);
virtual void attackFour(enemy * target);
virtual void usePotion(enemy * target);
virtual string attackOneName()const;
virtual string attackTwoName()const;
virtual string attackThreeName()const;
virtual string attackFourName()const;
virtual string usePotionName()const;
int getHealth() const;
void doDamage(int damage);
void resetHealth();
};
Garm::Garm(string n)
{
my_name = n;
my_health = 500;
heal = false;
}
string Garm::getName()const
{
return my_name;
}
string Garm::getDescription()const
{
return "Someone with special needs and will scream "Aloha Snackbar" ";
}
void Garm::attackOne(enemy* target)
{
//30% chance
heal = false;
target->doDamage(10);
my_health -= 10;
if (my_health <= 250)
{
target->doDamage(15);
my_health -= 15;
}
}
void Garm::attackTwo(enemy* target)
{
//20% chance
heal = false;
target->doDamage(8);
my_health -= 8;
for (int i = 0; i < rand() % 3; i++)
{
target->doDamage(8);
my_health -= 8;
}
}
void Garm::attackThree(enemy* target)
{
//5% chance
heal = false;
if (my_health <= 250)
{
target->doDamage((rand() % 80)+30);
my_health -= my_health;
}
}
void Garm::attackFour(enemy* target)
{
//25% chance
heal = false;
target->doDamage(10);
my_health += 5;
}
void Garm::usePotion(enemy* target)
{
//20% chance
heal = true;
}
string Garm::attackOneName() const
{
return "Spit";
}
string Garm::attackTwoName() const
{
return "Sloth Swipe";
}
string Garm::attackThreeName() const
{
if (my_health <= 250)
return "ALOHA SNACKBAR!";
else
return "You guys are crazy";
}
string Garm::attackFourName() const
{
return "You've been kick out from the server";
}
string Garm::usePotionName() const
{
return "WHAT IS THIS?!";
}
int Garm::getHealth()const
{
return my_health;
}
void Garm::doDamage(int damage)
{
if (heal)
{
my_health -= 50;
}
else if(my_health <= 250 )
{
my_health = my_health - damage;
}
else
{
my_health = my_health - (damage * 2);
}
}
void Garm::resetHealth()
{
my_health = 500;
}
#endif
Enemy.h
#pragma once
#ifndef MONSTER_
#define MONSTER_
#include <string>
using namespace std;
class enemy
{
public:
enemy();
virtual string getName() const = 0;
virtual string getDescription() const = 0;
virtual void attackOne(enemy * target) = 0;
virtual void attackTwo(enemy * target) = 0;
virtual void attackThree(enemy * target) = 0;
virtual void attackFour(enemy * target) = 0;
virtual void usePotion(enemy * target) = 0;
virtual string attackOneName() const = 0;
virtual string attackTwoName() const = 0;
virtual string attackThreeName() const = 0;
virtual string attackFourName() const = 0;
virtual string usePotionName() const = 0;
virtual int getHealth() const = 0;
virtual void doDamage(int damage) = 0;
virtual void resetHealth() = 0;
};
enemy::enemy()
{
}
#endif
Dragon_Turtle.h
#pragma once
#ifndef DRAGON_TURTLE_
#define DRAGON_TURTLE_
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "Enemy.h"
using namespace std;
//Almost Last Boss
class Dragon_Turtle : public enemy
{
private:
string my_name;
int my_health;
bool heal;
public:
Dragon_Turtle(string n = "Dragon Turtle");
string getName() const; //Not sure if I actually need this
string getDescription() const;
virtual void attackOne(enemy * target);
virtual void attackTwo(enemy * target);
virtual void attackThree(enemy * target);
virtual void attackFour(enemy * target);
virtual void usePotion(enemy * target);
virtual string attackOneName()const;
virtual string attackTwoName()const;
virtual string attackThreeName()const;
virtual string attackFourName()const;
virtual string usePotionName()const;
int getHealth() const;
void doDamage(int damage);
void resetHealth();
};
Dragon_Turtle::Dragon_Turtle(string n)
{
my_name = n;
my_health = 300;
heal = false;
}
string Dragon_Turtle::getName()const
{
return my_name;
}
string Dragon_Turtle::getDescription()const
{
return "You have been walking on top of him this entire time and didn't notice?! He likes money and seem to have curative powers.";
}
void Dragon_Turtle::attackOne(enemy* target)
{
//30% chance
heal = false;
target->doDamage(rand() % 20);
}
void Dragon_Turtle::attackTwo(enemy* target)
{
//20% Chance
heal = false;
target->doDamage(0);
}
void Dragon_Turtle::attackThree(enemy* target)
{
//5% chance
heal = false;
target->doDamage(60);
}
void Dragon_Turtle::attackFour(enemy* target)
{
//25% chance
heal = false;
target->doDamage(10);
}
void Dragon_Turtle::usePotion(enemy* target)
{
//20% chance
heal = true;
}
string Dragon_Turtle::attackOneName() const
{
return "Windbore Gust";
}
string Dragon_Turtle::attackTwoName() const
{
return "Glare";
}
string Dragon_Turtle::attackThreeName() const
{
return "World Shake";
}
string Dragon_Turtle::attackFourName() const
{
return "Roar";
}
string Dragon_Turtle::usePotionName() const
{
return "Guard";
}
int Dragon_Turtle::getHealth()const
{
return my_health;
}
void Dragon_Turtle::doDamage(int damage)
{
if (heal)
{
my_health = my_health -(damage/2);
}
else
{
my_health = my_health - damage;
}
}
void Dragon_Turtle::resetHealth()
{
my_health = 300;
}
#endif
Aquariuz.h
#pragma once
#ifndef Aquariuz_
#define Aquariuz_
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "Enemy.h"
using namespace std;
//Easy Monster, first encounter
class Aquariuz : public enemy
{
private:
string my_name;
int my_health;
bool heal;
public:
Aquariuz(string n = "Aquariuz");
string getName() const; //Not sure if I actually need this
string getDescription() const;
virtual void attackOne(enemy * target);
virtual void attackTwo(enemy * target);
virtual void attackThree(enemy * target);
virtual void attackFour(enemy * target);
virtual void usePotion(enemy * target);
virtual string attackOneName()const;
virtual string attackTwoName()const;
virtual string attackThreeName()const;
virtual string attackFourName()const;
virtual string usePotionName()const;
int getHealth() const;
void doDamage(int damage);
void resetHealth();
};
Aquariuz::Aquariuz(string n)
{
my_name = n;
my_health = 100;
heal = false;
}
string Aquariuz::getName()const
{
return my_name;
}
string Aquariuz::getDescription()const
{
return "Legends say that the mythical creature called Aquariuz was fighting the all mighty Gorseval when suddenly he reached for a Lightning Hammer and never to be seen again.";
}
void Aquariuz::attackOne(enemy* target)
{
//30% chance
heal = false;
target->doDamage(rand()%10);
}
void Aquariuz::attackTwo(enemy* target)
{
//20% chance
heal = false;
target->doDamage(rand() % 20);
}
void Aquariuz::attackThree(enemy* target)
{
//5% chance
heal = false;
target->doDamage(30);
}
void Aquariuz::attackFour(enemy* target)
{
//25% chance
heal = false;
target->doDamage(10);
my_health -= 5;
}
void Aquariuz::usePotion(enemy* target)
{
//20% chance
heal = true;
}
string Aquariuz::attackOneName() const
{
return "Lightning Swipe";
}
string Aquariuz::attackTwoName() const
{
return "Lightning Storm";
}
string Aquariuz::attackThreeName() const
{
return "Thunderclap";
}
string Aquariuz::attackFourName() const
{
return "Overload!";
}
string Aquariuz::usePotionName() const
{
return "Charge";
}
int Aquariuz::getHealth()const
{
return my_health;
}
void Aquariuz::doDamage(int damage)
{
if (heal)
{
my_health += 20;
}
else
{
my_health = my_health - damage;
}
}
void Aquariuz::resetHealth()
{
my_health = 100;
}
#endif
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.