added item base class for gold and potions
This commit is contained in:
11
src/potion.h
11
src/potion.h
@ -5,6 +5,7 @@
|
||||
#include <memory>
|
||||
#include "fraction.h"
|
||||
#include "output.h"
|
||||
#include "item.h"
|
||||
|
||||
enum potion_type : int;
|
||||
enum race : int;
|
||||
@ -12,7 +13,7 @@ enum race : int;
|
||||
// IMPORTANT: pop all potions of duration == 0, and when entering a
|
||||
// new level, pop all potions of duration == -1
|
||||
|
||||
class potion {
|
||||
class potion : public item {
|
||||
protected:
|
||||
// Use -1 to denote that the effect will last until leaving the level
|
||||
// Otherwise, use a positive number
|
||||
@ -22,10 +23,6 @@ protected:
|
||||
position pos;
|
||||
constexpr static const float DROW_POTION_MUL = 1.5f;
|
||||
public:
|
||||
potion(const potion &p);
|
||||
potion(potion &&p);
|
||||
potion &operator=(const potion &p);
|
||||
potion &operator=(potion &&p);
|
||||
potion(const potion_type type, const int duration, const position &pos);
|
||||
// apply decrements remaining_duration if it's positive, and
|
||||
// won't do anything if it's non-negative
|
||||
@ -34,11 +31,9 @@ public:
|
||||
virtual int get_priority() const = 0;
|
||||
potion_type get_type() const;
|
||||
int get_duration() const;
|
||||
position get_pos() const;
|
||||
void set_pos(const position &npos);
|
||||
virtual const char *get_name() const = 0;
|
||||
|
||||
virtual void print(output *out);
|
||||
void print(output *out) const override;
|
||||
};
|
||||
|
||||
typedef std::vector<potion *> potion_list;
|
||||
|
Reference in New Issue
Block a user