finished the bulk of game
This commit is contained in:
41
src/enemies/halfling.cc
Normal file
41
src/enemies/halfling.cc
Normal file
@ -0,0 +1,41 @@
|
||||
#include "halfling.h"
|
||||
|
||||
#include "../constants.h"
|
||||
|
||||
fraction halfling::HIT_RATE_MUL = {1, 2};
|
||||
|
||||
halfling::halfling(RNG *rng, const feature enabled_features,
|
||||
const position &pos,
|
||||
const int gen_room_num):
|
||||
enemy_base{rng, enabled_features, rhalfling, pos, gen_room_num, "L"} {}
|
||||
|
||||
void halfling::print(display *out) {
|
||||
out->print_char(pos, 'L', COLOR_PAIR(COLOR_RED));
|
||||
}
|
||||
|
||||
const char *halfling::get_race_name() const {
|
||||
return "Halfling";
|
||||
}
|
||||
|
||||
long_result halfling::get_hit(character *ch, const int tATK,
|
||||
const fraction &hit_rate) {
|
||||
auto nhit_rate = HIT_RATE_MUL * hit_rate;
|
||||
|
||||
if (rng->trial(nhit_rate)) {
|
||||
int tmp = calc_dmg(tATK, DEF);
|
||||
tmp = tmp > HP ? HP : tmp;
|
||||
HP -= tmp;
|
||||
|
||||
if (HP == 0)
|
||||
return {result::hit,
|
||||
"PC deals " + std::to_string(tmp) +
|
||||
" damage to " + abbrev + ". " + abbrev +
|
||||
" is slain by PC. "};
|
||||
|
||||
return {result::hit, "PC deals " +
|
||||
std::to_string(tmp) + " damage to " + abbrev};
|
||||
}
|
||||
|
||||
return {miss, "PC tried to hit " + abbrev +
|
||||
" but missed. The halfling laughed. "};
|
||||
}
|
Reference in New Issue
Block a user