OSDN Git Service

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