X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fblue-magic%2Fblue-magic-checker.cpp;h=e84879439ed4f4856a139737da2a8add0c165987;hb=91d4519e2312ace0f5342efb8a5421222aa51d2d;hp=95ae8d4865b579eea3d894a65d73fe85d49b583d;hpb=3b38c65c3dc777951fc036ecfb168e735fc680b8;p=hengbandforosx%2Fhengbandosx.git diff --git a/src/blue-magic/blue-magic-checker.cpp b/src/blue-magic/blue-magic-checker.cpp index 95ae8d486..e84879439 100644 --- a/src/blue-magic/blue-magic-checker.cpp +++ b/src/blue-magic/blue-magic-checker.cpp @@ -16,67 +16,71 @@ #include "main/sound-of-music.h" #include "monster-race/race-ability-mask.h" #include "mspell/monster-power-table.h" +#include "player-base/player-class.h" +#include "player-info/bluemage-data-type.h" #include "player/attack-defense-types.h" #include "status/experience.h" #include "system/angband.h" #include "system/player-type-definition.h" +#include "timed-effect/player-stun.h" +#include "timed-effect/timed-effects.h" #include "view/display-messages.h" /*! * @brief 青魔法のラーニング判定と成功した場合のラーニング処理 * @param monspell ラーニングを試みるモンスター攻撃のID */ -void learn_spell(player_type *player_ptr, int monspell) +void learn_spell(PlayerType *player_ptr, MonsterAbilityType monspell) { if (player_ptr->action != ACTION_LEARN) return; - if (monspell < 0) + auto bluemage_data = PlayerClass(player_ptr).get_specific_data(); + if (!bluemage_data || bluemage_data->learnt_blue_magics.has(monspell)) return; - if (player_ptr->magic_num2[monspell]) - return; - if (player_ptr->confused || player_ptr->blind || player_ptr->image || player_ptr->stun || player_ptr->paralyzed) + + auto effects = player_ptr->effects(); + auto is_stunned = effects->stun()->is_stunned(); + if (player_ptr->confused || player_ptr->blind || player_ptr->hallucinated || is_stunned || player_ptr->paralyzed) return; - if (randint1(player_ptr->lev + 70) > monster_powers[monspell].level + 40) { - player_ptr->magic_num2[monspell] = 1; - msg_format(_("%sを学習した!", "You have learned %s!"), monster_powers[monspell].name); - gain_exp(player_ptr, monster_powers[monspell].level * monster_powers[monspell].smana); + const auto &monster_power = monster_powers.at(monspell); + if (randint1(player_ptr->lev + 70) > monster_power.level + 40) { + bluemage_data->learnt_blue_magics.set(monspell); + msg_format(_("%sを学習した!", "You have learned %s!"), monster_power.name); + gain_exp(player_ptr, monster_power.level * monster_power.smana); sound(SOUND_STUDY); - player_ptr->new_mane = true; + bluemage_data->new_magic_learned = true; player_ptr->redraw |= PR_STATE; } } /*! - * @brief モンスター特殊能力のフラグ配列から特定条件の魔法だけを抜き出す処理 + * @brief モンスター特殊能力のフラグ配列から特定のタイプの能力だけを抜き出す処理 * Extract monster spells mask for the given mode - * @param f4 モンスター特殊能力の4番目のフラグ配列 - * @param f5 モンスター特殊能力の5番目のフラグ配列 - * @param f6 モンスター特殊能力の6番目のフラグ配列 - * @param mode 抜き出したい条件 - * @todo f4, f5, f6を構造体にまとめ直す + * @param ability_flags モンスター特殊能力のフラグ集合 + * @param type 抜き出したいタイプ */ -void set_rf_masks(EnumClassFlagGroup &ability_flags, blue_magic_type mode) +void set_rf_masks(EnumClassFlagGroup &ability_flags, BlueMagicType type) { ability_flags.clear(); - switch (mode) { - case MONSPELL_TYPE_BOLT: - ability_flags.set(RF_ABILITY_BOLT_MASK | RF_ABILITY_BEAM_MASK).reset(RF_ABILITY::ROCKET); + switch (type) { + case BlueMagicType::BOLT: + ability_flags.set(RF_ABILITY_BOLT_MASK | RF_ABILITY_BEAM_MASK).reset(MonsterAbilityType::ROCKET); break; - case MONSPELL_TYPE_BALL: + case BlueMagicType::BALL: ability_flags.set(RF_ABILITY_BALL_MASK).reset(RF_ABILITY_BREATH_MASK); break; - case MONSPELL_TYPE_BREATH: + case BlueMagicType::BREATH: ability_flags.set(RF_ABILITY_BREATH_MASK); break; - case MONSPELL_TYPE_SUMMON: + case BlueMagicType::SUMMON: ability_flags.set(RF_ABILITY_SUMMON_MASK); break; - case MONSPELL_TYPE_OTHER: + case BlueMagicType::OTHER: ability_flags.set(RF_ABILITY_ATTACK_MASK); ability_flags.reset(RF_ABILITY_BOLT_MASK | RF_ABILITY_BEAM_MASK | RF_ABILITY_BALL_MASK | RF_ABILITY_INDIRECT_MASK); break;