#include "continuous_restoration.h"

#include <algorithm>
#include "constants.h"

continuous_restoration::continuous_restoration(const position &pos):
        potion{potion_type::CONTINUOUS_RESTORATION, DURATION, pos} {}

void continuous_restoration::apply(const enum race &race, int &HP, int &ATK,
                                   int &DEF, fraction &base_hit_rate) {
        if (remaining_duration != 0) {
                if (HP >= MAX_HP[race]) {
                        --remaining_duration;
                        return;
                }

                int tmp = GAIN_HEALTH;

                if (race == DROW)
                        tmp *= DROW_POTION_MUL;

                HP = std::min(HP + tmp, MAX_HP[race]);
                --remaining_duration;
        }
}

int continuous_restoration::get_priority() const {
        return CALC_BASE;
}

const char *continuous_restoration::get_name() const {
        return "CR";
}
