Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include "monster.h"
int Monster::takeDamage(int damage)
{
hp = hp - damage;
if(hp <= 0){
hp = 0;
}
mvprintw(LINES/2 + 1,(COLS-strlen(("Enemy hp left: " + to_string(hp)).c_str()))/2,"%s", ("Enemy hp left: " + to_string(hp)).c_str());
refresh();
}
array<int, 3> Monster::giveInfo()
{
array<int, 3> info = {lvl, atk, hp};
return info;
}
float Monster::giveDef()
{
return def;
}
Monster createWolf(){
Monster wolf;
srand ( time(NULL) );
wolf.lvl = (rand() % 6) + 1;
wolf.atk = wolf.lvl * 2;
wolf.hp = wolf.lvl * 4;
wolf.def = 1 - (wolf.lvl * 0.05);
wolf.expGiven = 8;
return wolf;
}
Monster createOrc(){
Monster orc;
srand ( time(NULL) );
orc.lvl = (rand() % 6) + 15;
orc.atk = orc.lvl * 1.5;
orc.hp = orc.lvl * 7;
orc.def = 1 - (orc.lvl * 0.05);
orc.expGiven = 20;
return orc;
}