OSDN Git Service

8e91dfa93eba8f86c279bf3b12338f165d211b33
[hengbandforosx/hengbandosx.git] / src / perception / object-perception.cpp
1 #include "perception/object-perception.h"
2 #include "flavor/flavor-describer.h"
3 #include "flavor/object-flavor-types.h"
4 #include "game-option/play-record-options.h"
5 #include "io/write-diary.h"
6 #include "object-enchant/item-feeling.h"
7 #include "object-enchant/special-object-flags.h"
8 #include "object-enchant/trg-types.h"
9 #include "object/item-tester-hooker.h" // 暫定、このファイルへ引っ越す.
10 #include "system/baseitem-info-definition.h"
11 #include "system/object-type-definition.h"
12 #include "system/player-type-definition.h"
13
14 /*!
15  * @brief オブジェクトを鑑定済にする /
16  * Known is true when the "attributes" of an object are "known".
17  * @param o_ptr 鑑定済にするオブジェクトの構造体参照ポインタ
18  * These include tohit, todam, toac, cost, and pval (charges).\n
19  *\n
20  * Note that "knowing" an object gives you everything that an "awareness"\n
21  * gives you, and much more.  In fact, the player is always "aware" of any\n
22  * item of which he has full "knowledge".\n
23  *\n
24  * But having full knowledge of, say, one "wand of wonder", does not, by\n
25  * itself, give you knowledge, or even awareness, of other "wands of wonder".\n
26  * It happens that most "identify" routines (including "buying from a shop")\n
27  * will make the player "aware" of the object as well as fully "know" it.\n
28  *\n
29  * This routine also removes any inscriptions generated by "feelings".\n
30  */
31 void object_known(ItemEntity *o_ptr)
32 {
33     o_ptr->feeling = FEEL_NONE;
34     o_ptr->ident &= ~(IDENT_SENSE);
35     o_ptr->ident &= ~(IDENT_EMPTY);
36     o_ptr->ident |= (IDENT_KNOWN);
37 }
38
39 /*!
40  * @brief オブジェクトを*鑑定*済にする /
41  * The player is now aware of the effects of the given object.
42  * @param player_ptr プレイヤーへの参照ポインタ
43  * @param o_ptr *鑑定*済にするオブジェクトの構造体参照ポインタ
44  */
45 void object_aware(PlayerType *player_ptr, const ItemEntity *o_ptr)
46 {
47     const bool is_already_awared = o_ptr->is_aware();
48
49     baseitems_info[o_ptr->k_idx].aware = true;
50
51     // 以下、playrecordに記録しない場合はreturnする
52     if (!record_ident) {
53         return;
54     }
55
56     if (is_already_awared || player_ptr->is_dead) {
57         return;
58     }
59
60     // アーティファクト専用ベースアイテムは記録しない
61     if (baseitems_info[o_ptr->k_idx].gen_flags.has(ItemGenerationTraitType::INSTA_ART)) {
62         return;
63     }
64
65     // 未鑑定名の無いアイテムは記録しない
66     if (!((o_ptr->tval >= ItemKindType::AMULET && o_ptr->tval <= ItemKindType::POTION) || o_ptr->tval == ItemKindType::FOOD)) {
67         return;
68     }
69
70     // playrecordに識別したアイテムを記録
71     ItemEntity forge;
72     ItemEntity *q_ptr;
73     GAME_TEXT o_name[MAX_NLEN];
74
75     q_ptr = &forge;
76     q_ptr->copy_from(o_ptr);
77
78     q_ptr->number = 1;
79     describe_flavor(player_ptr, o_name, q_ptr, OD_NAME_ONLY);
80
81     exe_write_diary(player_ptr, DIARY_FOUND, 0, o_name);
82 }
83
84 /*!
85  * @brief オブジェクトを試行済にする /
86  * Something has been "sampled"
87  * @param o_ptr 試行済にするオブジェクトの構造体参照ポインタ
88  */
89 void object_tried(const ItemEntity *o_ptr)
90 {
91     baseitems_info[o_ptr->k_idx].tried = true;
92 }