OSDN Git Service

aa5db7652844e12b27e3b7bd035b19131454771e
[hengbandforosx/hengbandosx.git] / src / object-enchant / weapon / apply-magic-hafted.cpp
1 /*!
2  * @brief 鈍器に耐性等の追加効果を付与する処理
3  * @date 2022/03/22
4  * @author Hourier
5  */
6
7 #include "object-enchant/weapon/apply-magic-hafted.h"
8 #include "floor/floor-base-definitions.h"
9 #include "inventory/inventory-slot-types.h"
10 #include "object-enchant/object-boost.h"
11 #include "sv-definition/sv-weapon-types.h"
12 #include "system/object-type-definition.h"
13
14 /*!
15  * @brief 鈍器強化クラスのコンストラクタ
16  * @param player_ptr プレイヤーへの参照ポインタ
17  * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
18  * @param level 生成基準階
19  * @param power 生成ランク
20  */
21 HaftedEnchanter::HaftedEnchanter(PlayerType *player_ptr, ObjectType *o_ptr, DEPTH level, int power)
22     : MeleeWeaponEnchanter(player_ptr, o_ptr, level, power)
23 {
24 }
25
26 void HaftedEnchanter::apply_magic()
27 {
28     this->decide_skip();
29     this->give_killing_bonus();
30     MeleeWeaponEnchanter::apply_magic();
31 }
32
33 void HaftedEnchanter::give_ego_index()
34 {
35     while (true) {
36         this->o_ptr->ego_idx = get_random_ego(INVEN_MAIN_HAND, true);
37         if (this->o_ptr->ego_idx == EgoType::SHARPNESS) {
38             continue;
39         }
40
41         break;
42     }
43
44     switch (this->o_ptr->ego_idx) {
45     case EgoType::EARTHQUAKES:
46         if (one_in_(3) && (this->level > 60)) {
47             this->o_ptr->art_flags.set(TR_BLOWS);
48         } else {
49             this->o_ptr->pval = static_cast<short>(m_bonus(3, this->level));
50         }
51
52         break;
53     default:
54         break;
55     }
56 }
57
58 void HaftedEnchanter::give_cursed()
59 {
60     if (randint0(MAX_DEPTH) >= this->level) {
61         return;
62     }
63
64     while (true) {
65         this->o_ptr->ego_idx = get_random_ego(INVEN_MAIN_HAND, false);
66         if (this->o_ptr->ego_idx == EgoType::WEIRD) {
67             continue;
68         }
69
70         return;
71     }
72 }