OSDN Git Service

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