OSDN Git Service

Merge branch 'develop' into feature/hero_bless
[hengbandforosx/hengbandosx.git] / src / player / temporary-resistances.cpp
1 #include "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/object-type-definition.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  * @todo
22  * xtra1.c周りと多重実装になっているのを何とかする
23  */
24 void tim_player_flags(PlayerType *player_ptr, TrFlags &flags)
25 {
26     BIT_FLAGS tmp_effect_flag = FLAG_CAUSE_MAGIC_TIME_EFFECT;
27     set_bits(tmp_effect_flag, FLAG_CAUSE_STANCE);
28     BIT_FLAGS race_class_flag = FLAG_CAUSE_CLASS;
29     set_bits(race_class_flag, FLAG_CAUSE_RACE);
30
31     flags.clear();
32
33     if (is_oppose_acid(player_ptr) && none_bits(has_immune_acid(player_ptr), (race_class_flag | tmp_effect_flag)))
34         flags.set(TR_RES_ACID);
35     if (is_oppose_elec(player_ptr) && none_bits(has_immune_elec(player_ptr), (race_class_flag | tmp_effect_flag)))
36         flags.set(TR_RES_ELEC);
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     if (is_oppose_cold(player_ptr) && none_bits(has_immune_cold(player_ptr), (race_class_flag | tmp_effect_flag)))
40         flags.set(TR_RES_COLD);
41     if (is_oppose_pois(player_ptr))
42         flags.set(TR_RES_POIS);
43
44     for (int test_flag = 0; test_flag < TR_FLAG_MAX; test_flag++) {
45         if (any_bits(get_player_flags(player_ptr, i2enum<tr_type>(test_flag)), tmp_effect_flag))
46             flags.set(i2enum<tr_type>(test_flag));
47     }
48 }