OSDN Git Service

Merge pull request #3569 from sikabane-works/release/3.0.0.88-alpha
[hengbandforosx/hengbandosx.git] / src / object-enchant / weapon / apply-magic-arrow.cpp
1 /*!
2  * @brief 矢類のアイテムを強化する処理
3  * @date 2022/03/11
4  * @author Hourier
5  */
6
7 #include "object-enchant/weapon/apply-magic-arrow.h"
8 #include "artifact/random-art-generator.h"
9 #include "floor/floor-base-definitions.h"
10 #include "inventory/inventory-slot-types.h"
11 #include "system/item-entity.h"
12 #include "system/player-type-definition.h"
13
14 /*!
15  * @brief 矢類強化クラスのコンストラクタ
16  * @param player_ptr プレイヤーへの参照ポインタ
17  * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
18  * @param level 生成基準階
19  * @param power 生成ランク
20  */
21 ArrowEnchanter::ArrowEnchanter(PlayerType *player_ptr, ItemEntity *o_ptr, DEPTH level, int power)
22     : AbstractWeaponEnchanter(o_ptr, level, power)
23     , player_ptr(player_ptr)
24 {
25 }
26
27 /*!
28  * @brief 矢類に生成ランクごとの強化を与えるサブルーチン
29  * @details power > 2はデバッグ専用.
30  */
31 void ArrowEnchanter::apply_magic()
32 {
33     this->decide_skip();
34     if (this->should_skip) {
35         return;
36     }
37
38     this->give_killing_bonus();
39     if (this->power > 1) {
40         if (this->power > 2) {
41             become_random_artifact(this->player_ptr, this->o_ptr, false);
42             return;
43         }
44
45         this->o_ptr->ego_idx = get_random_ego(INVEN_AMMO, true);
46         while (one_in_(10 * this->o_ptr->dd * this->o_ptr->ds)) {
47             this->o_ptr->dd++;
48         }
49
50         if (this->o_ptr->dd > 9) {
51             this->o_ptr->dd = 9;
52         }
53
54         return;
55     }
56
57     if (this->power < -1) {
58         if (randint0(MAX_DEPTH) < this->level) {
59             this->o_ptr->ego_idx = get_random_ego(INVEN_AMMO, false);
60         }
61     }
62 }