OSDN Git Service

Reworded English description for sniper's exploding arrow ability.
[hengband/hengband.git] / src / mind / mind-magic-resistance.c
1 #include "mind/mind-magic-resistance.h"
2 #include "core/disturbance.h"
3 #include "core/player-redraw-types.h"
4 #include "core/player-update-types.h"
5 #include "core/stuff-handler.h"
6 #include "game-option/disturbance-options.h"
7 #include "view/display-messages.h"
8
9 /*!
10  * @brief 連奇術師の耐魔法防御 / 鏡使いの水鏡の盾 の継続時間をセットする / Set "resist_magic", notice observable changes
11  * @param v 継続時間
12  * @param do_dec 現在の継続時間より長い値のみ上書きする
13  * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
14  */
15 bool set_resist_magic(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
16 {
17     bool notice = FALSE;
18     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
19
20     if (creature_ptr->is_dead)
21         return FALSE;
22
23     if (v) {
24         if (creature_ptr->resist_magic && !do_dec) {
25             if (creature_ptr->resist_magic > v)
26                 return FALSE;
27         } else if (!creature_ptr->resist_magic) {
28             msg_print(_("魔法への耐性がついた。", "You have been protected from magic!"));
29             notice = TRUE;
30         }
31     } else {
32         if (creature_ptr->resist_magic) {
33             msg_print(_("魔法に弱くなった。", "You are no longer protected from magic."));
34             notice = TRUE;
35         }
36     }
37
38     creature_ptr->resist_magic = v;
39     creature_ptr->redraw |= (PR_STATUS);
40
41     if (!notice)
42         return FALSE;
43
44     if (disturb_state)
45         disturb(creature_ptr, FALSE, FALSE);
46     creature_ptr->update |= (PU_BONUS);
47     handle_stuff(creature_ptr);
48     return TRUE;
49 }