Merge branch 'AL/add-feat'

This commit is contained in:
2024-07-17 22:15:26 -04:00
13 changed files with 26 additions and 37 deletions

View File

@ -20,6 +20,7 @@ protected:
potion_type type;
int remaining_duration;
position pos;
constexpr static const float DROW_POTION_MUL = 1.5f;
public:
potion(const potion &p);
potion(potion &&p);

View File

@ -3,8 +3,7 @@
#include <algorithm>
#include "../constants.h"
const int BOOST_ATK = 5;
const int BOOST_ATK_DROW = 7;
boost_atk::boost_atk(const position &pos):
potion{potion_type::boost_atk, -1, pos} {}
@ -12,11 +11,9 @@ boost_atk::boost_atk(const position &pos):
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;
else
ATK += BOOST_ATK;
int tmp = BOOST_ATK;
if (race == rdrow) tmp *= DROW_POTION_MUL;
ATK += tmp;
--remaining_duration;
}
}

View File

@ -4,6 +4,7 @@
#include "../potion.h"
class boost_atk final: public potion {
static const int BOOST_ATK = 5;
public:
boost_atk(const position &pos);
void apply(const enum race &race, int &HP, int &ATK, int &DEF,

View File

@ -3,9 +3,6 @@
#include <algorithm>
#include "../constants.h"
// TODO: move into class def as static constants
const int BOOST_DEF = 5;
const int BOOST_DEF_DROW = 7;
boost_def::boost_def(const position &pos):
potion{potion_type::boost_def, -1, pos} {}
@ -13,11 +10,9 @@ boost_def::boost_def(const position &pos):
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;
else
DEF += BOOST_DEF;
int tmp = BOOST_DEF;
if (race == rdrow) tmp *= DROW_POTION_MUL;
DEF += tmp;
--remaining_duration;
}
}

View File

@ -4,6 +4,7 @@
#include "../potion.h"
class boost_def final: public potion {
static const int BOOST_DEF = 5;
public:
boost_def(const position &pos);
void apply(const enum race &race, int &HP, int &ATK, int &DEF,

View File

@ -9,11 +9,9 @@ poison_health::poison_health(const position &pos):
void poison_health::apply(const enum race &race, int &HP, int &ATK, int &DEF,
fraction &base_hit_rate) {
if (remaining_duration != 0) {
if (race == rdrow)
HP = std::max(HP - 7, 0);
else
HP = std::max(HP - 5, 0);
int tmp = LOSE_HEALTH;
if (race == rdrow) tmp *= DROW_POTION_MUL;
HP = std::max(HP - tmp, 0);
--remaining_duration;
}
}

View File

@ -4,6 +4,7 @@
#include "../potion.h"
class poison_health final: public potion {
static const int LOSE_HEALTH = 5;
public:
poison_health(const position &pos);
void apply(const enum race &race, int &HP, int &ATK, int &DEF,

View File

@ -9,11 +9,9 @@ restore_health::restore_health(const position &pos):
void restore_health::apply(const enum race &race, int &HP, int &ATK, int &DEF,
fraction &base_hit_rate) {
if (remaining_duration != 0) {
if (race == rdrow)
HP = std::min(HP + 7, MAX_HP[race]);
else
HP = std::min(HP + 5, MAX_HP[race]);
int tmp = GAIN_HEALTH;
if (race == rdrow) tmp *= DROW_POTION_MUL;
HP = std::min(HP + tmp, MAX_HP[race]);
--remaining_duration;
}
}

View File

@ -4,6 +4,7 @@
#include "../potion.h"
class restore_health final: public potion {
static const int GAIN_HEALTH = 5;
public:
restore_health(const position &pos);
void apply(const enum race &race, int &HP, int &ATK, int &DEF,

View File

@ -12,11 +12,9 @@ wound_atk::wound_atk(const position &pos):
void wound_atk::apply(const enum race &race, int &HP, int &ATK, int &DEF,
fraction &base_hit_rate) {
if (remaining_duration != 0) {
if (race == rdrow)
ATK = std::max(ATK - WOUND_ATK_DROW, 0);
else
ATK = std::max(ATK - WOUND_ATK, 0);
int tmp = WOUND_ATK;
if (race == rdrow) tmp *= DROW_POTION_MUL;
ATK = std::max(ATK - tmp, 0);
--remaining_duration;
}
}

View File

@ -4,6 +4,7 @@
#include "../potion.h"
class wound_atk final: public potion {
static const int WOUND_ATK = 5;
public:
wound_atk(const position &pos);
void apply(const enum race &race, int &HP, int &ATK, int &DEF,

View File

@ -3,8 +3,6 @@
#include <algorithm>
#include "../constants.h"
const int WOUND_DEF = 5;
const int WOUND_DEF_DROW = 7;
wound_def::wound_def(const position &pos):
potion{potion_type::wound_def, -1, pos} {}
@ -12,11 +10,9 @@ wound_def::wound_def(const position &pos):
void wound_def::apply(const enum race &race, int &HP, int &ATK, int &DEF,
fraction &base_hit_rate) {
if (remaining_duration != 0) {
if (race == rdrow)
DEF = std::max(DEF - WOUND_DEF_DROW, 0);
else
DEF = std::max(DEF - WOUND_DEF, 0);
int tmp = WOUND_DEF;
if (race == rdrow) tmp *= DROW_POTION_MUL;
DEF = std::max(DEF - tmp, 0);
--remaining_duration;
}
}

View File

@ -4,6 +4,7 @@
#include "../potion.h"
class wound_def final: public potion {
static const int WOUND_DEF = 5;
public:
wound_def(const position &pos);
void apply(const enum race &race, int &HP, int &ATK, int &DEF,