OSDN Git Service

[Refactor] #41053 Moved art-definition/*.h to artifact/
[hengband/hengband.git] / src / object-hook / hook-expendable.c
1 #include "object-hook/hook-expendable.h"
2 #include "artifact/fixed-art-types.h"
3 #include "core/player-update-types.h"
4 #include "core/window-redrawer.h"
5 #include "monster-race/monster-race.h"
6 #include "object-enchant/item-feeling.h"
7 #include "object-enchant/special-object-flags.h"
8 #include "object-hook/hook-checker.h"
9 #include "object-hook/hook-enchant.h"
10 #include "object/object-kind.h"
11 #include "perception/object-perception.h"
12 #include "player/mimic-info-table.h"
13 #include "sv-definition/sv-lite-types.h"
14 #include "sv-definition/sv-other-types.h"
15 #include "system/object-type-definition.h"
16 #include "util/string-processor.h"
17
18 /*!
19  * @brief オブジェクトをプレイヤーが食べることができるかを判定する /
20  * Hook to determine if an object is eatable
21  * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
22  * @return 食べることが可能ならばTRUEを返す
23  */
24 bool item_tester_hook_eatable(player_type *player_ptr, object_type *o_ptr)
25 {
26     if (o_ptr->tval == TV_FOOD)
27         return TRUE;
28
29     if (is_specific_player_race(player_ptr, RACE_SKELETON) || is_specific_player_race(player_ptr, RACE_GOLEM)
30         || is_specific_player_race(player_ptr, RACE_ZOMBIE) || is_specific_player_race(player_ptr, RACE_SPECTRE)) {
31         if (o_ptr->tval == TV_STAFF || o_ptr->tval == TV_WAND)
32             return TRUE;
33     } else if (is_specific_player_race(player_ptr, RACE_BALROG) || (mimic_info[player_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) {
34         if (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_CORPSE && angband_strchr("pht", r_info[o_ptr->pval].d_char))
35             return TRUE;
36     }
37
38     return FALSE;
39 }
40
41 /*!
42  * @brief オブジェクトをプレイヤーが飲むことができるかを判定する /
43  * Hook to determine if an object can be quaffed
44  * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
45  * @return 飲むことが可能ならばTRUEを返す
46  */
47 bool item_tester_hook_quaff(player_type *player_ptr, object_type *o_ptr)
48 {
49     if (o_ptr->tval == TV_POTION)
50         return TRUE;
51
52     if (is_specific_player_race(player_ptr, RACE_ANDROID) && (o_ptr->tval == TV_FLASK) && (o_ptr->sval == SV_FLASK_OIL))
53         return TRUE;
54
55     return FALSE;
56 }
57
58 /*!
59  * @brief オブジェクトをプレイヤーが読むことができるかを判定する /
60  * Hook to determine if an object is readable
61  * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
62  * @return 読むことが可能ならばTRUEを返す
63  */
64 bool item_tester_hook_readable(player_type *player_ptr, object_type *o_ptr)
65 {
66     /* Unused */
67     (void)player_ptr;
68
69     if ((o_ptr->tval == TV_SCROLL) || (o_ptr->tval == TV_PARCHMENT) || (o_ptr->name1 == ART_GHB) || (o_ptr->name1 == ART_POWER))
70         return TRUE;
71
72     return FALSE;
73 }
74
75 /*!
76  * @brief オブジェクトがランタンの燃料になるかどうかを判定する
77  * An "item_tester_hook" for refilling lanterns
78  * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
79  * @return オブジェクトがランタンの燃料になるならばTRUEを返す
80  */
81 bool item_tester_refill_lantern(player_type *player_ptr, object_type *o_ptr)
82 {
83     /* Unused */
84     (void)player_ptr;
85
86     if ((o_ptr->tval == TV_FLASK) || ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN)))
87         return TRUE;
88
89     return FALSE;
90 }
91
92 /*!
93  * @brief オブジェクトが松明に束ねられるかどうかを判定する
94  * An "item_tester_hook" for refilling torches
95  * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
96  * @return オブジェクトが松明に束ねられるならばTRUEを返す
97  */
98 bool object_can_refill_torch(player_type *player_ptr, object_type *o_ptr)
99 {
100     /* Unused */
101     (void)player_ptr;
102
103     if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
104         return TRUE;
105
106     return FALSE;
107 }
108
109 /*!
110  * @brief 破壊可能なアイテムかを返す /
111  * Determines whether an object can be destroyed, and makes fake inscription.
112  * @param o_ptr 破壊可能かを確認したいオブジェクトの構造体参照ポインタ
113  * @return オブジェクトが破壊可能ならばTRUEを返す
114  */
115 bool can_player_destroy_object(player_type *player_ptr, object_type *o_ptr)
116 {
117     /* Artifacts cannot be destroyed */
118     if (!object_is_artifact(o_ptr))
119         return TRUE;
120
121     if (!object_is_known(o_ptr)) {
122         byte feel = FEEL_SPECIAL;
123         if (object_is_cursed(o_ptr) || object_is_broken(o_ptr))
124             feel = FEEL_TERRIBLE;
125
126         o_ptr->feeling = feel;
127         o_ptr->ident |= IDENT_SENSE;
128         player_ptr->update |= (PU_COMBINE);
129         player_ptr->window |= (PW_INVEN | PW_EQUIP);
130         return FALSE;
131     }
132
133     return FALSE;
134 }
135
136 /*!
137  * @brief オブジェクトが薬であるかを返す
138  * @param o_ptr 対象のオブジェクト構造体ポインタ
139  * @return オブジェクトが薬ならばTRUEを返す
140  */
141 bool object_is_potion(object_type *o_ptr) { return (k_info[o_ptr->k_idx].tval == TV_POTION); }