OSDN Git Service

[feature] ソースファイルをC++に対応
[hengbandforosx/hengbandosx.git] / src / player / temporary-resistances.c
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 "util/bit-flags-calculator.h"
14
15 /*!
16  * @brief プレイヤーの一時的魔法効果による耐性を返す
17  * Prints ratings on certain abilities
18  * @param creature_ptr プレーヤーへの参照ポインタ
19  * @param flags フラグを保管する配列
20  * @return なし
21  * @todo
22  * xtra1.c周りと多重実装になっているのを何とかする
23  */
24 void tim_player_flags(player_type *creature_ptr, BIT_FLAGS *flags)
25 {
26     BIT_FLAGS tmp_effect_flag = FLAG_CAUSE_MAGIC_TIME_EFFECT;
27     set_bits(tmp_effect_flag, FLAG_CAUSE_BATTLE_FORM);
28     BIT_FLAGS race_class_flag = FLAG_CAUSE_CLASS;
29     set_bits(race_class_flag, FLAG_CAUSE_RACE);
30
31     for (int i = 0; i < TR_FLAG_SIZE; i++)
32         flags[i] = 0L;
33
34     if (is_oppose_acid(creature_ptr) && none_bits(has_immune_acid(creature_ptr), (race_class_flag | tmp_effect_flag)))
35         add_flag(flags, TR_RES_ACID);
36     if (is_oppose_elec(creature_ptr) && none_bits(has_immune_elec(creature_ptr), (race_class_flag | tmp_effect_flag)))
37         add_flag(flags, TR_RES_ELEC);
38     if (is_oppose_fire(creature_ptr) && none_bits(has_immune_fire(creature_ptr), (race_class_flag | tmp_effect_flag)))
39         add_flag(flags, TR_RES_FIRE);
40     if (is_oppose_cold(creature_ptr) && none_bits(has_immune_cold(creature_ptr), (race_class_flag | tmp_effect_flag)))
41         add_flag(flags, TR_RES_COLD);
42     if (is_oppose_pois(creature_ptr))
43         add_flag(flags, TR_RES_POIS);
44
45     for (int test_flag = 0; test_flag < TR_FLAG_MAX; test_flag++) {
46         if (any_bits(get_player_flags(creature_ptr, static_cast<tr_type>(test_flag)), tmp_effect_flag))
47             add_flag(flags, test_flag);
48     }
49 }