#ifndef __POTION_H__
#define __POTION_H__

#include <vector>
#include <memory>
#include "fraction.h"
#include "output.h"
#include "item.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 : public item {
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;
        inline static const float DROW_POTION_MUL = 1.5f;
public:
        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;
        virtual const char *get_name() const = 0;

        void print(output *out) const override;
};

typedef std::vector<potion *> potion_list;
typedef std::vector<std::unique_ptr<potion> > potion_own_list;

size_t get_potion_at(const position &pos, const potion_list &plist);

#endif
