OSDN Git Service

Merge pull request #3569 from sikabane-works/release/3.0.0.88-alpha
[hengbandforosx/hengbandosx.git] / src / player / temporary-resistances.cpp
1 #include "player/temporary-resistances.h"
2 #include "object-enchant/tr-types.h"
3 #include "player-info/race-info.h"
4 #include "player-info/race-types.h"
5 #include "player/player-status-flags.h"
6 #include "player/special-defense-types.h"
7 #include "realm/realm-hex-numbers.h"
8 #include "realm/realm-song-numbers.h"
9 #include "realm/realm-types.h"
10 #include "spell-realm/spells-hex.h"
11 #include "status/element-resistance.h"
12 #include "system/item-entity.h"
13 #include "system/player-type-definition.h"
14 #include "util/bit-flags-calculator.h"
15
16 /*!
17  * @brief プレイヤーの一時的魔法効果による耐性を返す
18  * Prints ratings on certain abilities
19  * @param player_ptr プレイヤーへの参照ポインタ
20  * @param flags フラグを保管する配列
21  */
22 void tim_player_flags(PlayerType *player_ptr, TrFlags &flags)
23 {
24     BIT_FLAGS tmp_effect_flag = FLAG_CAUSE_MAGIC_TIME_EFFECT;
25     set_bits(tmp_effect_flag, FLAG_CAUSE_STANCE);
26     BIT_FLAGS race_class_flag = FLAG_CAUSE_CLASS;
27     set_bits(race_class_flag, FLAG_CAUSE_RACE);
28
29     flags.clear();
30
31     if (is_oppose_acid(player_ptr) && none_bits(has_immune_acid(player_ptr), (race_class_flag | tmp_effect_flag))) {
32         flags.set(TR_RES_ACID);
33     }
34     if (is_oppose_elec(player_ptr) && none_bits(has_immune_elec(player_ptr), (race_class_flag | tmp_effect_flag))) {
35         flags.set(TR_RES_ELEC);
36     }
37     if (is_oppose_fire(player_ptr) && none_bits(has_immune_fire(player_ptr), (race_class_flag | tmp_effect_flag))) {
38         flags.set(TR_RES_FIRE);
39     }
40     if (is_oppose_cold(player_ptr) && none_bits(has_immune_cold(player_ptr), (race_class_flag | tmp_effect_flag))) {
41         flags.set(TR_RES_COLD);
42     }
43     if (is_oppose_pois(player_ptr)) {
44         flags.set(TR_RES_POIS);
45     }
46
47     for (int test_flag = 0; test_flag < TR_FLAG_MAX; test_flag++) {
48         if (any_bits(get_player_flags(player_ptr, i2enum<tr_type>(test_flag)), tmp_effect_flag)) {
49             flags.set(i2enum<tr_type>(test_flag));
50         }
51     }
52 }