From b750081a1be1d4af67efbb2c09be40e680a51c0c Mon Sep 17 00:00:00 2001 From: Peisong Xiao Date: Thu, 18 Jul 2024 19:10:58 -0400 Subject: [PATCH] reworked potion priority (5 -> 3) (5 is too much) --- src/constants.h | 8 +++----- src/potions/boost_atk.cc | 7 +++++-- src/potions/boost_def.cc | 9 ++++++--- src/potions/poison_health.cc | 9 ++++++--- src/potions/restore_health.cc | 7 +++++-- src/potions/wound_atk.cc | 10 +++++----- src/potions/wound_def.cc | 8 +++++--- 7 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/constants.h b/src/constants.h index d98f396..0edc8ba 100644 --- a/src/constants.h +++ b/src/constants.h @@ -97,11 +97,9 @@ enum potion_type : int {restore_health = 0, boost_atk, boost_def, }; // Calculation priorities -static const int CALC_ADD_BASE = 0; -static const int CALC_MUL_BASE = 1; -static const int CALC_ADD_LATER = 2; -static const int CALC_MUL_LATER = 3; -static const int CALC_ADD_FIXED = 4; +static const int CALC_BASE = 0; +static const int CALC_MID = 1; +static const int CALC_LAST = 2; static const int DIRECTION_CNT = 8; diff --git a/src/potions/boost_atk.cc b/src/potions/boost_atk.cc index a8dc37b..83a1596 100644 --- a/src/potions/boost_atk.cc +++ b/src/potions/boost_atk.cc @@ -12,14 +12,17 @@ void boost_atk::apply(const enum race &race, int &HP, int &ATK, int &DEF, fraction &base_hit_rate) { if (remaining_duration != 0) { int tmp = BOOST_ATK; - if (race == rdrow) tmp *= DROW_POTION_MUL; + + if (race == rdrow) + tmp *= DROW_POTION_MUL; + ATK += tmp; --remaining_duration; } } int boost_atk::get_priority() const { - return CALC_ADD_BASE; + return CALC_BASE; } const char *boost_atk::get_name() const { diff --git a/src/potions/boost_def.cc b/src/potions/boost_def.cc index 14aed11..7425a25 100644 --- a/src/potions/boost_def.cc +++ b/src/potions/boost_def.cc @@ -11,14 +11,17 @@ void boost_def::apply(const enum race &race, int &HP, int &ATK, int &DEF, fraction &base_hit_rate) { if (remaining_duration != 0) { int tmp = BOOST_DEF; - if (race == rdrow) tmp *= DROW_POTION_MUL; - DEF += tmp; + + if (race == rdrow) + tmp *= DROW_POTION_MUL; + + DEF += tmp; --remaining_duration; } } int boost_def::get_priority() const { - return CALC_ADD_BASE; + return CALC_BASE; } const char *boost_def::get_name() const { diff --git a/src/potions/poison_health.cc b/src/potions/poison_health.cc index bfa5569..102f011 100644 --- a/src/potions/poison_health.cc +++ b/src/potions/poison_health.cc @@ -10,14 +10,17 @@ void poison_health::apply(const enum race &race, int &HP, int &ATK, int &DEF, fraction &base_hit_rate) { if (remaining_duration != 0) { int tmp = LOSE_HEALTH; - if (race == rdrow) tmp *= DROW_POTION_MUL; - HP = std::max(HP - tmp, 0); + + if (race == rdrow) + tmp *= DROW_POTION_MUL; + + HP = std::max(HP - tmp, 0); --remaining_duration; } } int poison_health::get_priority() const { - return CALC_ADD_BASE; + return CALC_BASE; } const char *poison_health::get_name() const { diff --git a/src/potions/restore_health.cc b/src/potions/restore_health.cc index 6dd36e9..e3be45a 100644 --- a/src/potions/restore_health.cc +++ b/src/potions/restore_health.cc @@ -10,14 +10,17 @@ void restore_health::apply(const enum race &race, int &HP, int &ATK, int &DEF, fraction &base_hit_rate) { if (remaining_duration != 0) { int tmp = GAIN_HEALTH; - if (race == rdrow) tmp *= DROW_POTION_MUL; + + if (race == rdrow) + tmp *= DROW_POTION_MUL; + HP = std::min(HP + tmp, MAX_HP[race]); --remaining_duration; } } int restore_health::get_priority() const { - return CALC_ADD_BASE; + return CALC_BASE; } const char *restore_health::get_name() const { diff --git a/src/potions/wound_atk.cc b/src/potions/wound_atk.cc index bd76d30..cf4c186 100644 --- a/src/potions/wound_atk.cc +++ b/src/potions/wound_atk.cc @@ -3,9 +3,6 @@ #include #include "../constants.h" -const int WOUND_ATK = 5; -const int WOUND_ATK_DROW = 7; - wound_atk::wound_atk(const position &pos): potion{potion_type::wound_atk, -1, pos} {} @@ -13,14 +10,17 @@ void wound_atk::apply(const enum race &race, int &HP, int &ATK, int &DEF, fraction &base_hit_rate) { if (remaining_duration != 0) { int tmp = WOUND_ATK; - if (race == rdrow) tmp *= DROW_POTION_MUL; + + if (race == rdrow) + tmp *= DROW_POTION_MUL; + ATK = std::max(ATK - tmp, 0); --remaining_duration; } } int wound_atk::get_priority() const { - return CALC_ADD_BASE; + return CALC_BASE; } const char *wound_atk::get_name() const { diff --git a/src/potions/wound_def.cc b/src/potions/wound_def.cc index aa2517b..db705fc 100644 --- a/src/potions/wound_def.cc +++ b/src/potions/wound_def.cc @@ -3,7 +3,6 @@ #include #include "../constants.h" - wound_def::wound_def(const position &pos): potion{potion_type::wound_def, -1, pos} {} @@ -11,14 +10,17 @@ void wound_def::apply(const enum race &race, int &HP, int &ATK, int &DEF, fraction &base_hit_rate) { if (remaining_duration != 0) { int tmp = WOUND_DEF; - if (race == rdrow) tmp *= DROW_POTION_MUL; + + if (race == rdrow) + tmp *= DROW_POTION_MUL; + DEF = std::max(DEF - tmp, 0); --remaining_duration; } } int wound_def::get_priority() const { - return CALC_ADD_BASE; + return CALC_BASE; } const char *wound_def::get_name() const {