OSDN Git Service

[Refactor] #2523 PlayerType::poisoned をPlayerPoison の呼び出しに差し替えた
[hengbandforosx/hengbandosx.git] / src / system / player-type-definition.cpp
1 #include "system/player-type-definition.h"
2 #include "market/arena-info-table.h"
3 #include "timed-effect/player-confusion.h"
4 #include "timed-effect/player-cut.h"
5 #include "timed-effect/player-deceleration.h"
6 #include "timed-effect/player-fear.h"
7 #include "timed-effect/player-hallucination.h"
8 #include "timed-effect/player-paralysis.h"
9 #include "timed-effect/player-poison.h"
10 #include "timed-effect/player-stun.h"
11 #include "timed-effect/timed-effects.h"
12 #include "world/world.h"
13
14 /*!
15  * @brief プレイヤー構造体実体 / Static player info record
16  */
17 PlayerType p_body;
18
19 /*!
20  * @brief プレイヤー構造体へのグローバル参照ポインタ / Pointer to the player info
21  */
22 PlayerType *p_ptr = &p_body;
23
24 PlayerType::PlayerType()
25     : timed_effects(std::make_shared<TimedEffects>())
26 {
27 }
28
29 bool PlayerType::is_true_winner() const
30 {
31     return (w_ptr->total_winner > 0) && (this->arena_number > MAX_ARENA_MONS + 2);
32 }
33
34 std::shared_ptr<TimedEffects> PlayerType::effects() const
35 {
36     return this->timed_effects;
37 }
38
39 /*!
40  * @brief 自身の状態が全快で、かつフロアに影響を与えないかを検証する
41  * @return 上記の通りか
42  * @todo 時限効果系に分類されるものはいずれTimedEffectsクラスのメソッドとして繰り込みたい
43  */
44 bool PlayerType::is_fully_healthy() const
45 {
46     auto effects = this->effects();
47     auto is_fully_healthy = this->chp == this->mhp;
48     is_fully_healthy &= this->csp >= this->msp;
49     is_fully_healthy &= !this->blind;
50     is_fully_healthy &= !effects->confusion()->is_confused();
51     is_fully_healthy &= !effects->poison()->is_poisoned();
52     is_fully_healthy &= !effects->fear()->is_fearful();
53     is_fully_healthy &= !effects->stun()->is_stunned();
54     is_fully_healthy &= !effects->cut()->is_cut();
55     is_fully_healthy &= !effects->deceleration()->is_slow();
56     is_fully_healthy &= !effects->paralysis()->is_paralyzed();
57     is_fully_healthy &= !effects->hallucination()->is_hallucinated();
58     is_fully_healthy &= !this->word_recall;
59     is_fully_healthy &= !this->alter_reality;
60     return is_fully_healthy;
61 }