#include "Monster.h"
#include "random.h"

Monster::Monster(const int FPLvl, const int FPSkill) {
	lvl = random((FPLvl / 2) + 1, FPLvl + (FPLvl / 2));
	skill = (FPSkill * random(5,15)) / 10; //between 0,5 and 1,5 times player skill
	health = random(65 * lvl, 75 * lvl);
	gold = random(5, random(10,100)) * lvl;
}	

const int Monster::recvAttack(const int FPLvl, const int FPSkill) {
	const int avg = (FPLvl * FPSkill) - (lvl * skill);
	int hit = random(avg - (lvl * 10), avg + (lvl * 10));
	if (hit < 0) {
		hit = 0;
	} else {
		health -= hit;
		if (health < 0) {
			health = 0;
		}
	}
	return hit;
}

const int Monster::sendAttack(const int FPLvl, const int FPSkill) {
	const int avg = (lvl * skill) - (FPLvl * FPSkill);
	int hit = random(avg - (FPLvl * 10), avg + (FPLvl * 10));
	if (hit < 0) {
		hit = 0;
	}
	return hit;
}

const int Monster::getLvl() {
	return lvl;
}

const int Monster::getHealth() {
	return health;
}

const int Monster::getSkill() {
	return skill;
}

const int Monster::getGold() {
	return gold;
}

