OSDN Git Service

[Refactor] #1578 Separated PlayerClass::lose_balance() from stun()
[hengbandforosx/hengbandosx.git] / src / player-base / player-class.cpp
1 /*!
2  * @brief プレイヤーの職業クラスに基づく耐性・能力の判定処理等を行うクラス
3  * @date 2021/09/08
4  * @author Hourier
5  * @details 本クラス作成時点で責務に対する余裕はかなりあるので、適宜ここへ移してくること.
6  */
7 #include "player-base/player-class.h"
8 #include "core/player-redraw-types.h"
9 #include "core/player-update-types.h"
10 #include "player/attack-defense-types.h"
11 #include "player/special-defense-types.h"
12 #include "system/player-type-definition.h"
13 #include "util/bit-flags-calculator.h"
14
15 PlayerClass::PlayerClass(player_type* player_ptr)
16     : player_ptr(player_ptr)
17 {
18 }
19
20 bool PlayerClass::can_resist_stun() const
21 {
22     return (this->player_ptr->pclass == CLASS_BERSERKER) && (this->player_ptr->lev > 34);
23 }
24
25 bool PlayerClass::is_wizard() const
26 {
27     auto is_wizard = this->player_ptr->pclass == CLASS_MAGE;
28     is_wizard |= this->player_ptr->pclass == CLASS_HIGH_MAGE;
29     is_wizard |= this->player_ptr->pclass == CLASS_SORCERER;
30     is_wizard |= this->player_ptr->pclass == CLASS_MAGIC_EATER;
31     is_wizard |= this->player_ptr->pclass == CLASS_BLUE_MAGE;
32     is_wizard |= this->player_ptr->pclass == CLASS_ELEMENTALIST;
33     return is_wizard;
34 }
35
36 bool PlayerClass::lose_balance()
37 {
38     if (this->player_ptr->pclass != CLASS_SAMURAI) {
39         return false;
40     }
41
42     if (none_bits(this->player_ptr->special_defense, KATA_MASK)) {
43         return false;
44     }
45
46     reset_bits(this->player_ptr->special_defense, KATA_MASK);
47     this->player_ptr->update |= PU_BONUS;
48     this->player_ptr->update |= PU_MONSTERS;
49     this->player_ptr->redraw |= PR_STATE;
50     this->player_ptr->redraw |= PR_STATUS;
51     this->player_ptr->action = ACTION_NONE;
52     return true;
53 }