#ifndef __POTION_H__ #define __POTION_H__ #include #include "fraction.h" #include "display.h" enum potion_type : int; enum race : int; // IMPORTANT: pop all potions of duration == 0, and when entering a // new level, pop all potions of duration == -1 class potion { protected: // Use -1 to denote that the effect will last until leaving the level // Otherwise, use a positive number // Single use potions have a starting duration of 1 potion_type type; int remaining_duration; position pos; 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 virtual void apply(const enum race &race, int &HP, int &ATK, int &DEF, fraction &base_hit_rate) = 0; 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(display *out); }; typedef std::vector potion_list; potion *get_potion_at(const position &pos, potion_list &plist); #endif