#include "FighterInterface.h"
#include "cleric.h"

cleric::cleric(string name, int max_hp, int strength, int speed, int magic) :
    fighter(name, max_hp, strength, speed, magic), mana(5*magic) {}

int cleric::getDamage() {
    return magic;
}

void cleric::reset() {
    hp = max_hp;
    mana = 5 * magic;
}

void cleric::regenerate() {
    fighter::regenerate();

    int increase = magic / 5;

    if(increase < 0) {
        increase = 0;
    }
	else if(increase == 0) {
		increase = 1;
	}
    if(mana + increase < magic * 5) {
        mana += increase;
    }
    else {
        mana = 5 * magic;
    }
}

bool cleric::useAbility() {
    // a.k.a. Healing light
    if(mana - CLERIC_ABILITY_COST >= 0) {
        int increase = magic / 3;
        if(increase < 0) {
            increase = 0;
        }
		else if(increase == 0) {
			increase = 1;
		}
        if(hp + increase < max_hp) {
            hp += increase;
        }
        else {
           hp = max_hp;
        }
        mana -= CLERIC_ABILITY_COST;
        return true;
    }
    return false;
}

int cleric::get_mana() {
    return mana;
}
