format
This commit is contained in:
@ -3,36 +3,36 @@
|
||||
#include <math.h>
|
||||
|
||||
vampire::vampire(RNG &rng, const position_list &available_positions):
|
||||
character{rng, race::rvampire} {
|
||||
pos = available_positions[rng.rand_under(available_positions.size())];
|
||||
gold = 0;
|
||||
hostile = true;
|
||||
character{rng, race::rvampire} {
|
||||
pos = available_positions[rng.rand_under(available_positions.size())];
|
||||
gold = 0;
|
||||
hostile = true;
|
||||
}
|
||||
|
||||
result vampire::attack(const direction dir, character_list &chlist) {
|
||||
position tmp{pos + MOVE[dir]};
|
||||
position tmp{pos + MOVE[dir]};
|
||||
|
||||
for (auto &ch : chlist)
|
||||
if (tmp == ch.get_position()) {
|
||||
auto res = ch.get_hit(race, ATK, base_hit_rate);
|
||||
for (auto &ch : chlist)
|
||||
if (tmp == ch.get_position()) {
|
||||
auto res = ch.get_hit(race, ATK, base_hit_rate);
|
||||
|
||||
if (res != result::miss) {
|
||||
HP += GAIN_HP;
|
||||
}
|
||||
if (res != result::miss) {
|
||||
HP += GAIN_HP;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
return result::fine;
|
||||
return result::fine;
|
||||
}
|
||||
|
||||
result vampire::get_hit(const enum race &race, const int atk,
|
||||
const float hitrate) {
|
||||
if (rng.rand_num() <= hitrate * (float)RAND_MAX)
|
||||
HP = std::max(HP - calc_dmg(atk, DEF), 0);
|
||||
if (rng.rand_num() <= hitrate * (float)RAND_MAX)
|
||||
HP = std::max(HP - calc_dmg(atk, DEF), 0);
|
||||
|
||||
if (HP == 0)
|
||||
return result::died;
|
||||
if (HP == 0)
|
||||
return result::died;
|
||||
|
||||
return result::hit;
|
||||
return result::hit;
|
||||
}
|
||||
|
Reference in New Issue
Block a user