2 * @brief 盾に耐性等の追加効果を付与する処理
5 * @details ドラゴンシールドは必ず付与する. それ以外は確率的に付与する.
8 #include "object-enchant/apply-magic-shield.h"
9 #include "artifact/random-art-generator.h"
10 #include "inventory/inventory-slot-types.h"
11 #include "object-enchant/object-boost.h"
12 #include "object-enchant/object-ego.h"
13 #include "sv-definition/sv-protector-types.h"
14 #include "system/object-type-definition.h"
18 * @param player_ptr プレイヤーへの参照ポインタ
19 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
23 ShieldEnchanter::ShieldEnchanter(player_type *player_ptr, object_type *o_ptr, DEPTH level, int power)
24 : AbstractProtectorEnchanter{ o_ptr, level, power }
25 , player_ptr(player_ptr)
30 * @details power > 2はデバッグ専用.
32 void ShieldEnchanter::apply_magic()
34 if (this->o_ptr->sval == SV_DRAGON_SHIELD) {
35 dragon_resist(this->o_ptr);
41 if (this->power <= 1) {
45 if (one_in_(20) || (this->power > 2)) {
46 become_random_artifact(this->player_ptr, this->o_ptr, false);
50 this->give_ego_index();
54 * @details 金属製の盾は魔法を受け付けない.
55 * @todo ミラー・シールドはエゴの付与確率が低い. この仕様で良いか要確認.
57 void ShieldEnchanter::give_ego_index()
60 this->o_ptr->name2 = get_random_ego(INVEN_SUB_HAND, true);
61 auto is_metal = this->o_ptr->sval == SV_SMALL_METAL_SHIELD;
62 is_metal |= this->o_ptr->sval == SV_LARGE_METAL_SHIELD;
63 if (!is_metal && (this->o_ptr->name2 == EGO_S_DWARVEN)) {
70 switch (this->o_ptr->name2) {
72 if (this->o_ptr->sval == SV_MIRROR_SHIELD) {
73 this->o_ptr->name2 = 0;