From c942f4295c810d8d36910c996d3c321f37419cd6 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Mon, 12 Feb 2018 22:09:40 +0100 Subject: Add inventory and item types headers --- src/main/headers/Actor.hpp | 9 ++++++++- src/main/headers/Item.hpp | 29 +++++++++++++++++++++++++++++ src/main/headers/MeleeWeapon.hpp | 21 +++++++++++++++++++++ src/main/headers/RangedWeapon.hpp | 13 +++++++++++++ src/main/headers/Stick.hpp | 11 +++++++++++ src/main/headers/Weapon.hpp | 14 ++++++++++++++ 6 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 src/main/headers/Item.hpp create mode 100644 src/main/headers/MeleeWeapon.hpp create mode 100644 src/main/headers/RangedWeapon.hpp create mode 100644 src/main/headers/Stick.hpp create mode 100644 src/main/headers/Weapon.hpp (limited to 'src/main') diff --git a/src/main/headers/Actor.hpp b/src/main/headers/Actor.hpp index 0e74ee0..24b7c72 100644 --- a/src/main/headers/Actor.hpp +++ b/src/main/headers/Actor.hpp @@ -1,9 +1,10 @@ #ifndef ACTOR_HPP #define ACTOR_HPP -#include +#include #include +#include "Item.hpp" class Actor { @@ -17,6 +18,9 @@ public: void damage(int amt); void heal(int amt); + void store(Item &item); + Item& drop(); + /* accessors */ bool alive() { return _alive; } unsigned hp() { return _hp; } @@ -29,6 +33,9 @@ protected: unsigned _hp; int _x, _y; + unsigned _inventorySize; + std::list _inventory; + Actor(std::string _name, unsigned _maxHp); }; diff --git a/src/main/headers/Item.hpp b/src/main/headers/Item.hpp new file mode 100644 index 0000000..3664a0e --- /dev/null +++ b/src/main/headers/Item.hpp @@ -0,0 +1,29 @@ +#ifndef ITEM_HPP +#define ITEM_HPP + +#include + +class Actor; + +/* + * TODO description + */ +class Item +{ +public: + Item() = delete; + virtual ~Item() {} + + virtual bool use(Actor &actor) = 0; + virtual bool use(Item &item) = 0; + + bool stackable() { return _maxAmount == 1; } + +protected: + const unsigned _maxAmount; + const unsigned _amount; // stackable + + std::string _name; +}; + +#endif diff --git a/src/main/headers/MeleeWeapon.hpp b/src/main/headers/MeleeWeapon.hpp new file mode 100644 index 0000000..e031333 --- /dev/null +++ b/src/main/headers/MeleeWeapon.hpp @@ -0,0 +1,21 @@ +#ifndef MELEEWEAPON_HPP +#define MELEEWEAPON_HPP + +#include "Weapon.hpp" +#include "Actor.hpp" + + +class MeleeWeapon : public Weapon +{ +public: + enum Type { + SWORD, AXE, LANCE + }; + + virtual bool use(Actor &actor); + +protected: + bool _throwable; +}; + +#endif diff --git a/src/main/headers/RangedWeapon.hpp b/src/main/headers/RangedWeapon.hpp new file mode 100644 index 0000000..57b6ea4 --- /dev/null +++ b/src/main/headers/RangedWeapon.hpp @@ -0,0 +1,13 @@ +#ifndef RANGEDWEAPON_HPP +#define RANGEDWEAPON_HPP + +#include + +class RangedWeapon : public Weapon +{ +protected: + bool _charged; + unsigned _range; +}; + +#endif diff --git a/src/main/headers/Stick.hpp b/src/main/headers/Stick.hpp new file mode 100644 index 0000000..4ed2b45 --- /dev/null +++ b/src/main/headers/Stick.hpp @@ -0,0 +1,11 @@ +#ifndef STICK_HPP +#define STICK_HPP + +#include "Item.hpp" + +class Stick : public Item +{ + +}; + +#endif diff --git a/src/main/headers/Weapon.hpp b/src/main/headers/Weapon.hpp new file mode 100644 index 0000000..ef9d3d5 --- /dev/null +++ b/src/main/headers/Weapon.hpp @@ -0,0 +1,14 @@ +#ifndef WEAPON_HPP +#define WEAPON_HPP + +#include "Item.hpp" +#include "Actor.hpp" + +class Weapon : public Item +{ +protected: + unsigned _damage; + unsigned _requiredLevel; +}; + +#endif -- cgit v1.2.1