Skip to content

Commit

Permalink
Initial commit for the battle features
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff591 committed Nov 25, 2021
1 parent 511431d commit dda7f03
Show file tree
Hide file tree
Showing 12 changed files with 568 additions and 95 deletions.
12 changes: 8 additions & 4 deletions Armor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class Armor : public Item
int defense;
public:
Armor(){}
~Armor()
{
delete this;
}
int get_sell_price(){return sell_price;}
string get_armor_name(){return name;}
string get_armor_description(){return description;}
Expand Down Expand Up @@ -43,7 +47,7 @@ class KiloArmor : public Armor
description = "Armor made of a kilobyte of code. This weighs a kilo! You'll definitely gain strength carrying this!";
defense = 10;
}

};

class MegaArmor : public Armor
Expand All @@ -56,7 +60,7 @@ class MegaArmor : public Armor
description = "Armor made of a megabyte of code. Being able to shoot and change weapons like MegaMan not included";
defense = 15;
}

};

class GigaArmor : public Armor
Expand All @@ -69,7 +73,7 @@ class GigaArmor : public Armor
description = "Armor made of a gigabyte of code. Might give giga defense physically, but it'll be a giga dent on your money";
defense = 20;
}

};

class TeraArmor : public Armor
Expand All @@ -82,7 +86,7 @@ class TeraArmor : public Armor
description = "Legendary armor made of a terabyte of code. The best of the best armor around the interface, but as it is the best, only a few exist due to the immense work for its creation.";
defense = 25;
}

};

#endif
4 changes: 4 additions & 0 deletions Potion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class Potion : public Item
string type;
public:
Potion(){}
~Potion()
{
delete this;
}
int get_sell_price(){return sell_price;}
string get_potion_name(){return name;}
string get_potion_description(){return description;}
Expand Down
11 changes: 6 additions & 5 deletions Weapon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class Weapon : public Item
int attack;
public:
Weapon(){}
~Weapon()
{
delete this;
}
int get_sell_price(){return sell_price;}
string get_weapon_name(){return name;}
string get_weapon_description(){return description;}
Expand Down Expand Up @@ -55,8 +59,7 @@ class MegaWeapon : public Weapon
name = "MegaWeapon";
description = "Weapon made of a megabyte of code. It has a mega personality to go along with its mega size";
attack = 15;
}

}
};

class GigaWeapon : public Weapon
Expand All @@ -68,8 +71,7 @@ class GigaWeapon : public Weapon
name = "GigaWeapon";
description = "Weapon made of a gigabyte of code. This giga-hurts, well for the victim on the sharp side anyways.";
attack = 20;
}

}
};

class TeraWeapon : public Weapon
Expand All @@ -82,7 +84,6 @@ class TeraWeapon : public Weapon
description = "Legendary weapon infused with a terabyte of code. The pinnacle of weapons that code can make. Trust me we tried to make a better weapon, but we don't have the storage for it...";
attack = 25;
}

};

#endif
14 changes: 11 additions & 3 deletions character.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
#ifndef CHARACTER_HPP
#define CHARACTER_HPP

#include <string>
using namespace std;

class Character
{
protected:
int health;
int power;
int defense;
int speed;
string name;
public:

virtual void attack(Character* opponent) = 0;
Character(){};
virtual ~Character(){};
virtual int attack(Character* opponent) = 0;
int get_health()
{
return health;
Expand All @@ -27,6 +32,9 @@ class Character
{
return speed;
}

string get_name()
{
return this->name;
}
};
#endif
11 changes: 3 additions & 8 deletions dungeon.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
#include "dungeon.h"

Dungeon::Dungeon(std::vector<Enemy*> enemies) {
this->encounters = enemies;
}

Dungeon::~Dungeon() {
for(unsigned i = 0; i < this->encounters.size(); i++) {
delete this->encounters.at(i);
}
delete this;
}

std::vector<Enemy*> Dungeon::get_enemies() {
return this->encounters;
}
std::vector<Enemy*>* Dungeon::get_enemies() {
return &encounters;
}
75 changes: 72 additions & 3 deletions dungeon.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,81 @@
#include "enemy.h"

class Dungeon : public Enemy {
private:
protected:
std::vector<Enemy*> encounters;
int reward;
public:
Dungeon(std::vector<Enemy*> enemies);
Dungeon(){};
~Dungeon();
std::vector<Enemy*> get_enemies();
std::vector<Enemy*>* get_enemies();
int get_reward()
{
return reward;
}
};

class Dungeon1 : public Dungeon
{
public:
Dungeon1()
{
encounters.push_back(new Bug());
encounters.push_back(new Worm());
encounters.push_back(new Bug());
reward = 20;
}

};

class Dungeon2 : public Dungeon
{
public:
Dungeon2()
{
encounters.push_back(new PopUpAd());
encounters.push_back(new Worm());
encounters.push_back(new Spyware());
reward = 50;
}

};

class Dungeon3 : public Dungeon
{
public:
Dungeon3()
{
encounters.push_back(new Spyware());
encounters.push_back(new Virus());
encounters.push_back(new PopUpAd());
reward = 80;
}

};

class Dungeon4 : public Dungeon
{
public:
Dungeon4()
{
encounters.push_back(new Virus());
encounters.push_back(new Spyware());
encounters.push_back(new TrojanHorse());
reward = 150;
}
};

class Dungeon5 : public Dungeon
{
public:
Dungeon5()
{
encounters.push_back(new TrojanHorse());
encounters.push_back(new TrojanHorse());
encounters.push_back(new CorruptedMotherboard());
reward = 9999999;
}

};

#endif
24 changes: 11 additions & 13 deletions enemy.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#include "enemy.h"

Enemy::Enemy(int h, int p, int s) {
this->health = h;
this->power = p;
this->defense = 0;
this->speed = s;
}

int Enemy::attack(Character* opponent) {
int damageDealt = this->get_power() - opponent->get_defense();
Player* player = static_cast<Player*>(opponent);
int damageDealt;
if(player->get_current_armor() == nullptr)
{
damageDealt = this->get_power() - player->get_defense();
}
else
{
damageDealt = this->get_power() - player->get_defense() - player->get_current_armor()->get_defense();
}

if(damageDealt < 0) {
damageDealt = 0;
Expand All @@ -17,10 +19,6 @@ int Enemy::attack(Character* opponent) {
return damageDealt;
}

std::string Enemy::get_name() {
return this->name;
}

void Enemy::set_health(int damage) {
this->health -= damage;
}
}
Loading

0 comments on commit dda7f03

Please sign in to comment.