finished the bulk of game

This commit is contained in:
2024-07-14 21:32:41 -04:00
parent b3475b7530
commit af8bc4112c
110 changed files with 1876 additions and 1481 deletions

41
src/enemies/halfling.cc Normal file
View 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. "};
}