OSDN Git Service

[Refactor] enum classの型名変更 MUTA -> PlayerMutationType
[hengbandforosx/hengbandosx.git] / src / player-ability / player-constitution.cpp
1 #include "player-ability/player-constitution.h"
2 #include "mutation/mutation-flag-types.h"
3 #include "object/object-flags.h"
4 #include "player-base/player-class.h"
5 #include "player-base/player-race.h"
6 #include "player-info/class-info.h"
7 #include "player-info/monk-data-type.h"
8 #include "player-info/samurai-data-type.h"
9 #include "player/player-personality.h"
10 #include "player/race-info-table.h"
11 #include "player/special-defense-types.h"
12 #include "realm/realm-hex-numbers.h"
13 #include "spell-realm/spells-hex.h"
14 #include "system/player-type-definition.h"
15 #include "util/bit-flags-calculator.h"
16
17 PlayerConstitution::PlayerConstitution(player_type *player_ptr)
18     : PlayerBasicStatistics(player_ptr)
19 {
20 }
21
22 void PlayerConstitution::set_locals()
23 {
24     this->max_value = +99;
25     this->min_value = -99;
26     this->ability_type = A_CON;
27     this->tr_flag = TR_CON;
28     this->tr_bad_flag = TR_CON;
29 }
30
31 /*!
32  * @brief 耐久力補正計算 - 種族
33  * @return 耐久力補正値
34  */
35 int16_t PlayerConstitution::race_value()
36 {
37     int16_t result = PlayerBasicStatistics::race_value();
38
39     result += PlayerRace(this->player_ptr).additional_constitution();
40
41     return result;
42 }
43
44 /*!
45  * @brief 耐久力補正計算 - 一時効果
46  * @return 耐久力補正値
47  * @details
48  * * 一時効果による耐久力修正値
49  * * 呪術の肉体強化で加算(+4)
50  */
51 int16_t PlayerConstitution::time_effect_value()
52 {
53     int16_t result = 0;
54
55     if (this->player_ptr->realm1 == REALM_HEX) {
56         if (SpellHex(this->player_ptr).is_spelling_specific(HEX_BUILDING)) {
57             result += 4;
58         }
59     }
60
61     return result;
62 }
63
64 /*!
65  * @brief 耐久力補正計算 - 型
66  * @return 耐久力補正値
67  * @details
68  * * 型による耐久力修正値
69  * * 降鬼陣で加算(+5)
70  * * 白虎の構えで減算(-3)
71  * * 玄武の構えで加算(+3)
72  * * 朱雀の構えで減算(-2)
73  * * ネオ・つよしスペシャル中で加算(+4)
74  */
75 int16_t PlayerConstitution::stance_value()
76 {
77     int16_t result = 0;
78
79     PlayerClass pc(player_ptr);
80     if (pc.samurai_stance_is(SamuraiStance::KOUKIJIN)) {
81         result += 5;
82     }
83
84     if (pc.monk_stance_is(MonkStance::BYAKKO)) {
85         result -= 3;
86     } else if (pc.monk_stance_is(MonkStance::GENBU)) {
87         result += 3;
88     } else if (pc.monk_stance_is(MonkStance::SUZAKU)) {
89         result -= 2;
90     }
91     if (this->player_ptr->tsuyoshi) {
92         result += 4;
93     }
94
95     return result;
96 }
97
98 /*!
99  * @brief 耐久力補正計算 - 変異
100  * @return 耐久力補正値
101  * @details
102  * * 変異による耐久力修正値
103  * * 変異MUT3_RESILIENTで加算(+4)
104  * * 変異MUT3_ALBINOで減算(-4)
105  * * 変異MUT3_XTRA_FATで加算(+2)
106  * * 変異MUT3_FLESH_ROTで減算(-2)
107  */
108 int16_t PlayerConstitution::mutation_value()
109 {
110     int16_t result = 0;
111
112     if (this->player_ptr->muta.any()) {
113         if (this->player_ptr->muta.has(PlayerMutationType::RESILIENT)) {
114             result += 4;
115         }
116
117         if (this->player_ptr->muta.has(PlayerMutationType::ALBINO)) {
118             result -= 4;
119         }
120
121         if (this->player_ptr->muta.has(PlayerMutationType::XTRA_FAT)) {
122             result += 2;
123         }
124
125         if (this->player_ptr->muta.has(PlayerMutationType::FLESH_ROT)) {
126             result -= 2;
127         }
128     }
129
130     return result;
131 }