OSDN Git Service

Merge pull request #938 from dis-/feature/RefactorPlayreInfraVision
[hengbandforosx/hengbandosx.git] / src / player / temporary-resistances.cpp
1 #include "temporary-resistances.h"
2 #include "object-enchant/tr-types.h"
3 #include "player/player-race-types.h"
4 #include "player/player-race.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 creature_ptr プレーヤーへの参照ポインタ
20  * @param flags フラグを保管する配列
21  * @return なし
22  * @todo
23  * xtra1.c周りと多重実装になっているのを何とかする
24  */
25 void tim_player_flags(player_type *creature_ptr, BIT_FLAGS *flags)
26 {
27     BIT_FLAGS tmp_effect_flag = FLAG_CAUSE_MAGIC_TIME_EFFECT;
28     set_bits(tmp_effect_flag, FLAG_CAUSE_BATTLE_FORM);
29     BIT_FLAGS race_class_flag = FLAG_CAUSE_CLASS;
30     set_bits(race_class_flag, FLAG_CAUSE_RACE);
31
32     for (int i = 0; i < TR_FLAG_SIZE; i++)
33         flags[i] = 0L;
34
35     if (is_oppose_acid(creature_ptr) && none_bits(has_immune_acid(creature_ptr), (race_class_flag | tmp_effect_flag)))
36         add_flag(flags, TR_RES_ACID);
37     if (is_oppose_elec(creature_ptr) && none_bits(has_immune_elec(creature_ptr), (race_class_flag | tmp_effect_flag)))
38         add_flag(flags, TR_RES_ELEC);
39     if (is_oppose_fire(creature_ptr) && none_bits(has_immune_fire(creature_ptr), (race_class_flag | tmp_effect_flag)))
40         add_flag(flags, TR_RES_FIRE);
41     if (is_oppose_cold(creature_ptr) && none_bits(has_immune_cold(creature_ptr), (race_class_flag | tmp_effect_flag)))
42         add_flag(flags, TR_RES_COLD);
43     if (is_oppose_pois(creature_ptr))
44         add_flag(flags, TR_RES_POIS);
45
46     for (int test_flag = 0; test_flag < TR_FLAG_MAX; test_flag++) {
47         if (any_bits(get_player_flags(creature_ptr, static_cast<tr_type>(test_flag)), tmp_effect_flag))
48             add_flag(flags, test_flag);
49     }
50 }