OSDN Git Service

Merge branch 'macos-develop' into macos-3-0-0
[hengbandforosx/hengbandosx.git] / src / object-enchant / weapon / apply-magic-bow.cpp
1 /*!
2  * @brief 弓系のアイテムを強化する処理
3  * @date 2022/03/11
4  * @author Hourier
5  */
6
7 #include "object-enchant/weapon/apply-magic-bow.h"
8 #include "artifact/random-art-generator.h"
9 #include "inventory/inventory-slot-types.h"
10 #include "system/item-entity.h"
11
12 /*!
13  * @brief 弓強化クラスのコンストラクタ
14  * @param player_ptr プレイヤーへの参照ポインタ
15  * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
16  * @param level 生成基準階
17  * @param power 生成ランク
18  */
19 BowEnchanter::BowEnchanter(PlayerType *player_ptr, ItemEntity *o_ptr, DEPTH level, int power)
20     : AbstractWeaponEnchanter(o_ptr, level, power)
21     , player_ptr(player_ptr)
22 {
23 }
24
25 /*!
26  * @brief 弓系オブジェクトに生成ランクごとの強化を与えるサブルーチン
27  * Apply magic to an item known to be a "weapon"
28  * @details power > 2はデバッグ専用.
29  */
30 void BowEnchanter::apply_magic()
31 {
32     this->decide_skip();
33     if (this->should_skip) {
34         return;
35     }
36
37     this->give_killing_bonus();
38     if (this->power > 1) {
39         if ((this->power > 2) || one_in_(20)) {
40             become_random_artifact(this->player_ptr, this->o_ptr, false);
41             return;
42         }
43
44         this->o_ptr->ego_idx = get_random_ego(INVEN_BOW, true);
45     }
46 }