diff --git a/Enemy.cpp b/Enemy.cpp index 6e179de..db4f42a 100644 --- a/Enemy.cpp +++ b/Enemy.cpp @@ -1,5 +1,45 @@ #include "Enemy.h" Enemy::Enemy() + : name("Mr. No-name!"), + hitPoints(1), + gold(1), + weapon(Weapon()) { } + +Enemy::Enemy(std::string setName, + int setHitPoints, + int setGold, + const Weapon &setWeapon) + : name(setName), + hitPoints(setHitPoints), + gold(setGold), + weapon(setWeapon) +{ +} + +bool Enemy::Alive() const +{ + return (hitPoints > 0); +} + +std::string Enemy::getName() const +{ + return name; +} + +int Enemy::getHitPoints() const +{ + return hitPoints; +} + +int Enemy::getGold() const +{ + return gold; +} + +Weapon Enemy::getWeapon() const +{ + return weapon; +} diff --git a/Enemy.h b/Enemy.h index 7bce069..17ac20e 100644 --- a/Enemy.h +++ b/Enemy.h @@ -1,11 +1,30 @@ #ifndef ENEMY_H #define ENEMY_H +#include "Weapon.h" + +#include + class Enemy { public: Enemy(); - bool Alive() const { return false; } + Enemy(std::string setName, + int setHitPoints, + int setGold, + const Weapon &setWeapon); + + bool Alive() const; + std::string getName() const; + int getHitPoints() const; + int getGold() const; + Weapon getWeapon() const; + +private: + std::string name; + int hitPoints; + int gold; + Weapon weapon; }; #endif diff --git a/Location.cpp b/Location.cpp new file mode 100644 index 0000000..197eacd --- /dev/null +++ b/Location.cpp @@ -0,0 +1,31 @@ +#include "Location.h" + +#include + +Location::Location() + : name("Nowhere"), + descriptions({"This is undefined, bruh.", "This doesn't exist, bruh."}) +{ + static bool initialized = false; + if(!initialized) + { + initialized = true; + srand(time(nullptr)); + } +} + +Location::Location(std::string setName, + std::vector setDescriptions) + : name(setName), + descriptions(setDescriptions) +{ +} + +const std::string& Location::getName() const +{ + return name; +} +const std::string& Location::getDescription() const +{ + return descriptions[rand() % descriptions.size()]; +} diff --git a/Location.h b/Location.h new file mode 100644 index 0000000..25ce06e --- /dev/null +++ b/Location.h @@ -0,0 +1,27 @@ +#ifndef LOCATION_H +#define LOCATION_H + +#include "Enemy.h" + +#include +#include + +class Location +{ +public: + Location(); + Location(std::string setName, + std::vector setDescriptions); + + const std::string& getName() const; + const std::string& getDescription() const; // random + // const std::string& getEnemy() const; + +private: + std::string name; + std::vector descriptions; + // Enemy enemy; + //bool currentLocation; +}; + +#endif diff --git a/Makefile b/Makefile index a3778f3..3d7d631 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,2 @@ -a.out: main.cpp - clang++ main.cpp Player.cpp Enemy.cpp -g -O0 +a.out: main.cpp Player.cpp Enemy.cpp Location.cpp Weapon.cpp + clang++ main.cpp Player.cpp Enemy.cpp Location.cpp Weapon.cpp -g -O0 diff --git a/Weapon.cpp b/Weapon.cpp new file mode 100644 index 0000000..3e21d9d --- /dev/null +++ b/Weapon.cpp @@ -0,0 +1,45 @@ +#include "Weapon.h" + +Weapon::Weapon() + : name("Stick"), + damageType("pokes"), + twoHanded(false), + damage(2) +{ +} + +Weapon::Weapon(std::string setName, + std::string setDamageType, + bool setTwoHanded, + int setDamage) + : name(setName), + damageType(setDamageType), + twoHanded(setTwoHanded), + damage(setDamage) +{ +} + +const std::string& Weapon::getName() const +{ + return name; +} +const std::string& Weapon::getDamageType() const +{ + return damageType; +} +bool Weapon::getTwoHanded() const +{ + return twoHanded; +} +int Weapon::getLevel() const +{ + return level; +} +void Weapon::levelUp() +{ + damage += 3 + level++; +} +int Weapon::getDamage() const +{ + return damage; +} diff --git a/Weapon.h b/Weapon.h new file mode 100644 index 0000000..cfbf6b4 --- /dev/null +++ b/Weapon.h @@ -0,0 +1,30 @@ +#ifndef WEAPON_H +#define WEAPON_H + +#include + +class Weapon +{ +public: + Weapon(); + Weapon(std::string setName, + std::string setDamageType, + bool setTwoHanded, + int setDamage); + + const std::string& getName() const; + const std::string& getDamageType() const; + bool getTwoHanded() const; + int getLevel() const; + void levelUp(); + int getDamage() const; + +private: + std::string name; + std::string damageType; + bool twoHanded; + int damage; + int level; +}; + +#endif diff --git a/main.cpp b/main.cpp index 97fd43d..57faaef 100644 --- a/main.cpp +++ b/main.cpp @@ -7,9 +7,7 @@ // Generic text outputs: const std::string text_welcome = "\nWelcome\n\n" - "It is a period of civil wars in the galaxy. A brave alliance of underground\n" - "freedom fighters has challenged the tyranny and oppression of the awesome\n" - "GALACTIC EMPIRE.\n\n"; + "Story goes here.\n\n"; void OutputCharacters(const std::string &str, int delay_ms = 50000) { for(const char &c : str) @@ -112,7 +110,7 @@ void AfterBattle(Player &player, Enemy &enemy) void EndGame(Player &player) { - const std::string end_of_story_text = "THE END"; + const std::string end_of_story_text = "THE END\n\n"; OutputCharacters(end_of_story_text); // end-game stuff w/ king // determine he was happy with your results (i.e. if you won)