OSDN Git Service

7323f54552982c448e970343b9516a60c27087e2
[hengbandforosx/hengbandosx.git] / src / player-ability / player-charisma.cpp
1 #include "player-ability/player-charisma.h"
2 #include "mutation/mutation-flag-types.h"
3 #include "object/object-flags.h"
4 #include "player-base/player-class.h"
5 #include "player-info/class-info.h"
6 #include "player-info/mimic-info-table.h"
7 #include "player-info/samurai-data-type.h"
8 #include "player/player-personality.h"
9 #include "player/race-info-table.h"
10 #include "player/special-defense-types.h"
11 #include "realm/realm-hex-numbers.h"
12 #include "spell-realm/spells-hex.h"
13 #include "system/player-type-definition.h"
14 #include "util/bit-flags-calculator.h"
15
16 PlayerCharisma::PlayerCharisma(player_type *player_ptr)
17     : PlayerBasicStatistics(player_ptr)
18 {
19 }
20
21 void PlayerCharisma::set_locals()
22 {
23     this->max_value = +99;
24     this->min_value = -99;
25     this->ability_type = A_CHR;
26     this->tr_flag = TR_CHR;
27     this->tr_bad_flag = TR_CHR;
28 }
29
30 /*!
31  * @brief 魅力補正計算 - 型
32  * @return 魅力補正値
33  * @details
34  * * 型による魅力修正値
35  * * 降鬼陣で加算(+5)
36  */
37 int16_t PlayerCharisma::battleform_value()
38 {
39     int16_t result = 0;
40
41     if (PlayerClass(player_ptr).samurai_stance_is(SamuraiStance::KOUKIJIN)) {
42         result += 5;
43     }
44
45     return result;
46 }
47
48 /*!
49  * @brief 魅力補正計算 - 変異
50  * @return 魅力補正値
51  * @details
52  * * 変異による魅力修正値
53  * * 変異MUT3_FLESH_ROTで減算(-1)
54  * * 変異MUT3_SILLY_VOIで減算(-4)
55  * * 変異MUT3_BLANK_FACで減算(-1)
56  * * 変異MUT3_WART_SKINで減算(-2)
57  * * 変異MUT3_SCALESで減算(-1)
58  */
59 int16_t PlayerCharisma::mutation_value()
60 {
61     int16_t result = 0;
62
63     if (this->player_ptr->muta.any()) {
64         if (this->player_ptr->muta.has(MUTA::FLESH_ROT)) {
65             result -= 1;
66         }
67         if (this->player_ptr->muta.has(MUTA::SILLY_VOI)) {
68             result -= 4;
69         }
70         if (this->player_ptr->muta.has(MUTA::BLANK_FAC)) {
71             result -= 1;
72         }
73         if (this->player_ptr->muta.has(MUTA::WART_SKIN)) {
74             result -= 2;
75         }
76         if (this->player_ptr->muta.has(MUTA::SCALES)) {
77             result -= 1;
78         }
79     }
80
81     return result;
82 }
83
84 int16_t PlayerCharisma::set_exception_value(int16_t value)
85 {
86     int16_t result = value;
87
88     if (this->player_ptr->muta.has(MUTA::ILL_NORM)) {
89         result = 0;
90     }
91
92     return result;
93 }
94
95 BIT_FLAGS PlayerCharisma::get_all_flags()
96 {
97     BIT_FLAGS flags = PlayerStatusBase::get_all_flags();
98
99     if (this->player_ptr->muta.has(MUTA::ILL_NORM)) {
100         set_bits(flags, FLAG_CAUSE_MUTATION);
101     }
102
103     return flags;
104 }
105
106 BIT_FLAGS PlayerCharisma::get_bad_flags()
107 {
108     BIT_FLAGS flags = PlayerStatusBase::get_bad_flags();
109
110     if (this->player_ptr->muta.has(MUTA::ILL_NORM)) {
111         set_bits(flags, FLAG_CAUSE_MUTATION);
112     }
113
114     return flags;
115 }
116
117 /*!
118  * @brief ステータス現在値更新の例外処理
119  * @param 通常処理されたステータスの値
120  * @returns 例外処理されたステータスの値
121  * @details
122  * * MUT3_ILL_NORMを保持しているときの例外処理。
123  * * 魅力現在値をレベル依存の値に修正する。
124  */
125 int16_t PlayerCharisma::set_exception_use_status(int16_t value)
126 {
127     if (this->player_ptr->muta.has(MUTA::ILL_NORM)) {
128         /* 10 to 18/90 charisma, guaranteed, based on level */
129         if (value < 8 + 2 * this->player_ptr->lev) {
130             value = 8 + 2 * this->player_ptr->lev;
131         }
132     }
133     return value;
134 }