-#include "player/player-skill.h"
-#include "core/player-update-types.h"
+#include "player/player-skill.h"
#include "monster-race/monster-race.h"
#include "player-base/player-class.h"
#include "player-base/player-race.h"
#include "player-info/class-info.h"
#include "player/player-realm.h"
+#include "realm/realm-names-table.h"
#include "sv-definition/sv-weapon-types.h"
#include "system/floor-type-definition.h"
-#include "system/monster-race-definition.h"
-#include "system/monster-type-definition.h"
-#include "system/object-type-definition.h"
+#include "system/item-entity.h"
+#include "system/monster-entity.h"
+#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
+#include "system/redrawing-flags-updater.h"
#include "util/bit-flags-calculator.h"
/* Proficiency of weapons and misc. skills (except riding) */
}
exp += static_cast<short>(gain_amount);
- set_bits(player_ptr->update, PU_BONUS);
+ RedrawingFlagsUpdater::get_instance().set_flag(StatusRecalculatingFlag::BONUS);
}
void gain_spell_skill_exp_aux(PlayerType *player_ptr, short &exp, const GainAmountList &gain_amount_list, int spell_level)
}
exp += static_cast<short>(gain_amount);
- set_bits(player_ptr->update, PU_BONUS);
+ RedrawingFlagsUpdater::get_instance().set_flag(StatusRecalculatingFlag::BONUS);
}
}
{
const GainAmountList gain_amount_list{ { 80, 10, 1, (one_in_(2) ? 1 : 0) } };
constexpr GainAmountList others_gain_amount_list{ { 8, 1, 0, 0 } };
-
- for (auto sval = 0U; sval < this->player_ptr->weapon_exp[o_ptr->tval].size(); ++sval) {
- auto &now_exp = this->player_ptr->weapon_exp[o_ptr->tval][sval];
- if (now_exp < this->player_ptr->weapon_exp_max[o_ptr->tval][sval]) {
+ const auto tval = o_ptr->bi_key.tval();
+ for (auto sval = 0U; sval < this->player_ptr->weapon_exp[tval].size(); ++sval) {
+ auto &now_exp = this->player_ptr->weapon_exp[tval][sval];
+ if (now_exp < this->player_ptr->weapon_exp_max[tval][sval]) {
gain_attack_skill_exp(this->player_ptr, now_exp,
- (static_cast<int>(sval) == o_ptr->sval) ? gain_amount_list : others_gain_amount_list);
+ (static_cast<int>(sval) == o_ptr->bi_key.sval()) ? gain_amount_list : others_gain_amount_list);
}
}
}
{
constexpr GainAmountList gain_amount_list{ { 80, 25, 10, 2 } };
constexpr GainAmountList others_gain_amount_list{ { 8, 2, 0, 0 } };
-
- for (auto sval = 0U; sval < this->player_ptr->weapon_exp[o_ptr->tval].size(); ++sval) {
- auto &now_exp = this->player_ptr->weapon_exp[o_ptr->tval][sval];
- if (now_exp < this->player_ptr->weapon_exp_max[o_ptr->tval][sval]) {
+ const auto tval = o_ptr->bi_key.tval();
+ for (auto sval = 0U; sval < this->player_ptr->weapon_exp[tval].size(); ++sval) {
+ auto &now_exp = this->player_ptr->weapon_exp[tval][sval];
+ if (now_exp < this->player_ptr->weapon_exp_max[tval][sval]) {
gain_attack_skill_exp(this->player_ptr, now_exp,
- (static_cast<int>(sval) == o_ptr->sval) ? gain_amount_list : others_gain_amount_list);
+ (static_cast<int>(sval) == o_ptr->bi_key.sval()) ? gain_amount_list : others_gain_amount_list);
}
}
}
}
this->player_ptr->skill_exp[PlayerSkillKindType::RIDING] = std::min<SUB_EXP>(max_exp, now_exp + inc);
- set_bits(this->player_ptr->update, PU_BONUS);
+ RedrawingFlagsUpdater::get_instance().set_flag(StatusRecalculatingFlag::BONUS);
}
void PlayerSkill::gain_riding_skill_exp_on_range_attack()
return;
}
- if (((this->player_ptr->skill_exp[PlayerSkillKindType::RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < monraces_info[this->player_ptr->current_floor_ptr->m_list[this->player_ptr->riding].r_idx].level) && one_in_(2)) {
+ const auto *floor_ptr = this->player_ptr->current_floor_ptr;
+ const auto &monster = floor_ptr->m_list[this->player_ptr->riding];
+ const auto &monrace = monraces_info[monster.r_idx];
+ if (((this->player_ptr->skill_exp[PlayerSkillKindType::RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < monrace.level) && one_in_(2)) {
this->player_ptr->skill_exp[PlayerSkillKindType::RIDING] += 1;
- set_bits(this->player_ptr->update, PU_BONUS);
+ RedrawingFlagsUpdater::get_instance().set_flag(StatusRecalculatingFlag::BONUS);
}
}
}
this->player_ptr->skill_exp[PlayerSkillKindType::RIDING] = std::min<SUB_EXP>(max_exp, now_exp + inc);
- set_bits(this->player_ptr->update, PU_BONUS);
+ RedrawingFlagsUpdater::get_instance().set_flag(StatusRecalculatingFlag::BONUS);
}
void PlayerSkill::gain_spell_skill_exp(int realm, int spell_idx)
{
- if ((realm < 1) || ((static_cast<int>(std::size(mp_ptr->info)) < realm) && (realm != REALM_MUSIC) && (realm != REALM_HEX))) {
- return;
- }
+ auto is_valid_realm = is_magic(realm) ||
+ (realm == REALM_MUSIC) || (realm == REALM_HEX);
+ is_valid_realm &= (realm == this->player_ptr->realm1) || (realm == this->player_ptr->realm2);
+ const auto is_valid_spell_idx = (0 <= spell_idx) && (spell_idx < 32);
- if (((spell_idx < 0) || (32 <= spell_idx)) ||
- ((realm != this->player_ptr->realm1) && (realm != this->player_ptr->realm2))) {
+ if (!is_valid_realm || !is_valid_spell_idx) {
return;
}
constexpr GainAmountList gain_amount_list_second{ { 60, 8, 2, 0 } };
const auto is_first_realm = (realm == this->player_ptr->realm1);
- const auto *s_ptr = &mp_ptr->info[realm - 1][spell_idx];
+ const auto *s_ptr = is_magic(realm) ? &mp_ptr->info[realm - 1][spell_idx] : &technic_info[realm - MIN_TECHNIC][spell_idx];
gain_spell_skill_exp_aux(this->player_ptr, this->player_ptr->spell_exp[spell_idx + (is_first_realm ? 0 : 32)],
(is_first_realm ? gain_amount_list_first : gain_amount_list_second), s_ptr->slevel);
exp = SPELL_EXP_BEGINNER + exp / 3;
}
- set_bits(this->player_ptr->update, PU_BONUS);
-
+ RedrawingFlagsUpdater::get_instance().set_flag(StatusRecalculatingFlag::BONUS);
return PlayerSkill::spell_skill_rank(exp);
}