finished the bulk of game
This commit is contained in:
36
src/troll.cc
36
src/troll.cc
@ -1,36 +0,0 @@
|
||||
#include "troll.h"
|
||||
|
||||
troll::troll(RNG *rng, const position &pos):
|
||||
character{rng, race::rtroll, pos} {
|
||||
gold = 0;
|
||||
hostile = true;
|
||||
}
|
||||
|
||||
result troll::attack(const direction dir, character_list &chlist) {
|
||||
position tmp{pos + MOVE[dir]};
|
||||
|
||||
if (HP + REGAIN_HP > HP_CAP) {
|
||||
HP = HP_CAP;
|
||||
} else {
|
||||
HP += REGAIN_HP;
|
||||
}
|
||||
|
||||
for (auto &ch : chlist)
|
||||
if (tmp == ch->get_position()) {
|
||||
auto res = ch->get_hit(race, ATK, base_hit_rate);
|
||||
return res;
|
||||
}
|
||||
|
||||
return result::fine;
|
||||
}
|
||||
|
||||
result troll::get_hit(const enum race &race, const int atk,
|
||||
const fraction hitrate) {
|
||||
if (rng->trial(hitrate))
|
||||
HP = std::max(HP - calc_dmg(atk, DEF), 0);
|
||||
|
||||
if (HP == 0)
|
||||
return result::died;
|
||||
|
||||
return result::hit;
|
||||
}
|
Reference in New Issue
Block a user