work in progress

This commit is contained in:
2024-07-13 16:12:09 -04:00
parent db354d232a
commit 8fad4d262f
7 changed files with 66 additions and 72 deletions

View File

@ -5,11 +5,11 @@
const int BOOST_ATK = 5;
const int BOOST_ATK_DROW = 7;
boost_atk::boost_atk():
potion{potion_type::boost_atk, -1} {}
boost_atk::boost_atk(const position &pos):
potion{potion_type::boost_atk, -1, pos} {}
void boost_atk::apply(enum race &race, int &HP, int &ATK, int &DEF,
float &base_hit_rate) {
void boost_atk::apply(const enum race &race, int &HP, int &ATK, int &DEF,
fraction &base_hit_rate) {
if (remaining_duration > 0) {
if (race == rdrow)
ATK += BOOST_ATK_DROW;

View File

@ -5,9 +5,9 @@
class boost_atk final: public potion {
public:
boost_atk();
void apply(enum race &race, int &HP, int &ATK, int &DEF,
float &base_hit_rate) override;
boost_atk(const position &pos);
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
fraction &base_hit_rate) override;
int get_priority() const override;
};

View File

@ -2,14 +2,15 @@
#include <algorithm>
// TODO: move into class def as static constants
const int BOOST_DEF = 5;
const int BOOST_DEF_DROW = 7;
boost_def::boost_def():
potion{potion_type::boost_def, -1} {}
boost_def::boost_def(const position &pos):
potion{potion_type::boost_def, -1, pos} {}
void boost_def::apply(enum race &race, int &HP, int &ATK, int &DEF,
float &base_hit_rate) {
void boost_def::apply(const enum race &race, int &HP, int &ATK, int &DEF,
fraction &base_hit_rate) {
if (remaining_duration > 0) {
if (race == rdrow)
DEF += BOOST_DEF_DROW;

View File

@ -5,9 +5,9 @@
class boost_def final: public potion {
public:
boost_def();
void apply(enum race &race, int &HP, int &ATK, int &DEF,
float &base_hit_rate) override;
boost_def(const position &pos);
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
fraction &base_hit_rate) override;
int get_priority() const override;
};

View File

@ -2,9 +2,8 @@
#include <algorithm>
#include <math.h>
drow::drow(RNG &rng, const position_list &available_positions):
character{rng, race::rdrow} {
pos = available_positions[rng.rand_under(available_positions.size())];
drow::drow(RNG *rng, const position &pos):
character{rng, race::rdrow, pos} {
gold = 0;
hostile = true;
}
@ -13,16 +12,16 @@ result drow::attack(const direction dir, character_list &chlist) {
position tmp{pos + MOVE[dir]};
for (auto &ch : chlist)
if (tmp == ch.get_position()) {
return ch.get_hit(race, ATK, base_hit_rate);
if (tmp == ch->get_position()) {
return ch->get_hit(race, ATK, base_hit_rate);
}
return result::fine;
}
result drow::get_hit(const enum race &race, const int atk,
const float hitrate) {
if (rng.rand_num() <= hitrate * (float)RAND_MAX)
const fraction hitrate) {
if (rng->trial(hitrate))
HP = std::max(HP - calc_dmg(atk, DEF), 0);
if (HP == 0)

View File

@ -4,12 +4,12 @@
class drow final: public character {
public:
drow(RNG &rng,
const position_list &available_positions);
drow(RNG *rng,
const position &pos);
virtual result attack(const direction dir,
character_list &chlist) override;
virtual result get_hit(const enum race &race, const int atk,
const float hit_rate) override;
const fraction hit_rate) override;
};
#endif

View File

@ -26,15 +26,9 @@ result goblin::attack(const direction dir, character_list &chlist) {
}
result goblin::get_hit(const enum race &race, const int atk,
<<<<<<< HEAD
const float hitrate) {
if (rng.rand_num() <= hitrate * (float)RAND_MAX)
HP = std::max(HP - calc_dmg(atk, DEF), 0);
=======
const fraction hitrate) {
if (rng->trial(hitrate))
HP = std::max(HP - calc_dmg(atk, DEF), 0);
>>>>>>> paul
if (HP == 0)
return result::died;