OSDN Git Service

[Refactor] #3230 PlayerType::update に関わる処理を、RedrawingFlagsUpdaterに集約した
[hengbandforosx/hengbandosx.git] / src / specific-object / bloody-moon.cpp
1 #include "specific-object/bloody-moon.h"
2 #include "artifact/fixed-art-types.h"
3 #include "core/player-update-types.h"
4 #include "object-enchant/object-boost.h"
5 #include "object-enchant/tr-types.h"
6 #include "player-base/player-race.h"
7 #include "racial/racial-android.h"
8 #include "system/artifact-type-definition.h"
9 #include "system/item-entity.h"
10 #include "system/player-type-definition.h"
11 #include "system/redrawing-flags-updater.h"
12 #include "util/bit-flags-calculator.h"
13 #include "view/display-messages.h"
14
15 /*!
16  * @brief 固定アーティファクト『ブラッディムーン』の特性を変更する。
17  * @details スレイ2d2種、及びone_resistance()による耐性1d2種、pval2種を得る。
18  * @param o_ptr 対象のオブジェクト構造体 (ブラッディムーン)のポインタ
19  */
20 void get_bloody_moon_flags(ItemEntity *o_ptr)
21 {
22     o_ptr->art_flags = ArtifactsInfo::get_instance().get_artifact(FixedArtifactId::BLOOD).flags;
23
24     int dummy = randint1(2) + randint1(2);
25     for (int i = 0; i < dummy; i++) {
26         int flag = randint0(26);
27         if (flag >= 20) {
28             o_ptr->art_flags.set(TR_KILL_UNDEAD + flag - 20);
29         } else if (flag == 19) {
30             o_ptr->art_flags.set(TR_KILL_ANIMAL);
31         } else if (flag == 18) {
32             o_ptr->art_flags.set(TR_SLAY_HUMAN);
33         } else {
34             o_ptr->art_flags.set(TR_CHAOTIC + flag);
35         }
36     }
37
38     dummy = randint1(2);
39     for (int i = 0; i < dummy; i++) {
40         one_resistance(o_ptr);
41     }
42
43     for (int i = 0; i < 2; i++) {
44         int tmp = randint0(11);
45         if (tmp < A_MAX) {
46             o_ptr->art_flags.set(TR_STR + tmp);
47         } else {
48             o_ptr->art_flags.set(TR_STEALTH + tmp - 6);
49         }
50     }
51 }
52
53 /*!
54  * @brief Let's dance a RONDO!!
55  * @param player_ptr プレイヤーへの参照ポインタ
56  * @param o_ptr ブラッディ・ムーンへの参照ポインタ
57  * @return オブジェクト情報に異常がない限りTRUE
58  */
59 bool activate_bloody_moon(PlayerType *player_ptr, ItemEntity *o_ptr)
60 {
61     if (!o_ptr->is_specific_artifact(FixedArtifactId::BLOOD)) {
62         return false;
63     }
64
65     msg_print(_("鎌が明るく輝いた...", "Your scythe glows brightly!"));
66     get_bloody_moon_flags(o_ptr);
67     if (PlayerRace(player_ptr).equals(PlayerRaceType::ANDROID)) {
68         calc_android_exp(player_ptr);
69     }
70
71     const auto flags = {
72         StatusRedrawingFlag::BONUS,
73         StatusRedrawingFlag::HP,
74     };
75     RedrawingFlagsUpdater::get_instance().set_flags(flags);
76     return true;
77 }