OSDN Git Service

Merge pull request #1069 from sikabane-works/release/3.0.0Alpha22
[hengbandforosx/hengbandosx.git] / src / spell-kind / spells-enchant.cpp
1 #include "spell-kind/spells-enchant.h"
2 #include "artifact/random-art-generator.h"
3 #include "flavor/flavor-describer.h"
4 #include "flavor/object-flavor-types.h"
5 #include "floor/floor-object.h"
6 #include "game-option/disturbance-options.h"
7 #include "game-option/play-record-options.h"
8 #include "inventory/inventory-object.h"
9 #include "io/write-diary.h"
10 #include "object-hook/hook-enchant.h"
11 #include "object-hook/hook-perception.h"
12 #include "object-hook/hook-weapon.h"
13 #include "object/item-tester-hooker.h"
14 #include "object/item-use-flags.h"
15 #include "player-info/avatar.h"
16 #include "racial/racial-android.h"
17 #include "system/object-type-definition.h"
18 #include "system/player-type-definition.h"
19 #include "term/screen-processor.h"
20 #include "view/display-messages.h"
21
22 /*!
23  * @brief アーティファクト生成の巻物処理 /
24  * @param caster_ptr プレーヤーへの参照ポインタ
25  * @return 生成が実際に試みられたらTRUEを返す
26  */
27 bool artifact_scroll(player_type *caster_ptr)
28 {
29     item_tester_hook = item_tester_hook_nameless_weapon_armour;
30
31     concptr q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
32     concptr s = _("強化できるアイテムがない。", "You have nothing to enchant.");
33     object_type *o_ptr;
34     OBJECT_IDX item;
35     o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), TV_NONE);
36     if (!o_ptr)
37         return FALSE;
38
39     GAME_TEXT o_name[MAX_NLEN];
40     describe_flavor(caster_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
41 #ifdef JP
42     msg_format("%s は眩い光を発した!", o_name);
43 #else
44     msg_format("%s %s radiate%s a blinding light!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
45 #endif
46
47     bool okay = FALSE;
48     if (object_is_artifact(o_ptr)) {
49 #ifdef JP
50         msg_format("%sは既に伝説のアイテムです!", o_name);
51 #else
52         msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"), ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
53 #endif
54         okay = FALSE;
55     } else if (object_is_ego(o_ptr)) {
56 #ifdef JP
57         msg_format("%sは既に名のあるアイテムです!", o_name);
58 #else
59         msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"), ((o_ptr->number > 1) ? "ego items" : "an ego item"));
60 #endif
61         okay = FALSE;
62     } else if (o_ptr->xtra3) {
63 #ifdef JP
64         msg_format("%sは既に強化されています!", o_name);
65 #else
66         msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"), ((o_ptr->number > 1) ? "customized items" : "a customized item"));
67 #endif
68     } else {
69         if (o_ptr->number > 1) {
70             msg_print(_("複数のアイテムに魔法をかけるだけのエネルギーはありません!", "Not enough energy to enchant more than one object!"));
71 #ifdef JP
72             msg_format("%d 個の%sが壊れた!", (o_ptr->number) - 1, o_name);
73 #else
74             msg_format("%d of your %s %s destroyed!", (o_ptr->number) - 1, o_name, (o_ptr->number > 2 ? "were" : "was"));
75 #endif
76
77             if (item >= 0) {
78                 inven_item_increase(caster_ptr, item, 1 - (o_ptr->number));
79             } else {
80                 floor_item_increase(caster_ptr, 0 - item, 1 - (o_ptr->number));
81             }
82         }
83
84         okay = become_random_artifact(caster_ptr, o_ptr, TRUE);
85     }
86
87     if (!okay) {
88         if (flush_failure)
89             flush();
90
91         msg_print(_("強化に失敗した。", "The enchantment failed."));
92         if (one_in_(3))
93             chg_virtue(caster_ptr, V_ENCHANT, -1);
94
95         calc_android_exp(caster_ptr);
96         return TRUE;
97     }
98
99     if (record_rand_art) {
100         describe_flavor(caster_ptr, o_name, o_ptr, OD_NAME_ONLY);
101         exe_write_diary(caster_ptr, DIARY_ART_SCROLL, 0, o_name);
102     }
103
104     chg_virtue(caster_ptr, V_ENCHANT, 1);
105     calc_android_exp(caster_ptr);
106     return TRUE;
107 }
108
109 /*!
110  * @brief アイテム凡庸化のメインルーチン処理 /
111  * Identify an object in the inventory (or on the floor)
112  * @param owner_ptr プレーヤーへの参照ポインタ
113  * @param only_equip 装備品のみを対象とするならばTRUEを返す
114  * @return 実際に凡庸化をを行ったならばTRUEを返す
115  * @details
116  * <pre>
117  * Mundanify an object in the inventory (or on the floor)
118  * This routine does *not* automatically combine objects.
119  * Returns TRUE if something was mundanified, else FALSE.
120  * </pre>
121  */
122 bool mundane_spell(player_type *owner_ptr, bool only_equip)
123 {
124     if (only_equip)
125         item_tester_hook = object_is_weapon_armour_ammo;
126
127     OBJECT_IDX item;
128     object_type *o_ptr;
129     concptr q = _("どれを使いますか?", "Use which item? ");
130     concptr s = _("使えるものがありません。", "You have nothing you can use.");
131
132     o_ptr = choose_object(owner_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), TV_NONE);
133     if (!o_ptr)
134         return FALSE;
135
136     msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
137     POSITION iy = o_ptr->iy;
138     POSITION ix = o_ptr->ix;
139     byte marked = o_ptr->marked;
140     u16b inscription = o_ptr->inscription;
141
142     o_ptr->prep(owner_ptr, o_ptr->k_idx);
143
144     o_ptr->iy = iy;
145     o_ptr->ix = ix;
146     o_ptr->marked = marked;
147     o_ptr->inscription = inscription;
148
149     calc_android_exp(owner_ptr);
150     return TRUE;
151 }