1 #include "market/building-recharger.h"
2 #include "autopick/autopick.h"
3 #include "core/asking-player.h"
4 #include "core/player-update-types.h"
5 #include "core/window-redrawer.h"
6 #include "flavor/flavor-describer.h"
7 #include "flavor/object-flavor-types.h"
8 #include "floor/floor-object.h"
9 #include "inventory/inventory-slot-types.h"
10 #include "market/building-util.h"
11 #include "object-enchant/special-object-flags.h"
12 #include "object-hook/hook-magic.h"
13 #include "object/item-tester-hooker.h"
14 #include "object/item-use-flags.h"
15 #include "object/object-kind.h"
16 #include "perception/object-perception.h"
17 #include "spell-kind/spells-perception.h"
18 #include "system/object-type-definition.h"
19 #include "system/player-type-definition.h"
20 #include "term/screen-processor.h"
21 #include "view/display-messages.h"
24 * @brief 魔道具の使用回数を回復させる施設のメインルーチン / Recharge rods, wands and staffs
26 * The player can select the number of charges to add\n
27 * (up to a limit), and the recharge never fails.\n
29 * The cost for rods depends on the level of the rod. The prices\n
30 * for recharging wands and staffs are dependent on the cost of\n
32 * @param player_ptr プレーヤーへの参照ポインタ
34 void building_recharge(player_type *player_ptr)
38 prt(_(" 再充填の費用はアイテムの種類によります。", " The prices of recharge depend on the type."), 6, 0);
39 item_tester_hook = item_tester_hook_recharge;
41 concptr q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
42 concptr s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
46 o_ptr = choose_object(player_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TV_NONE);
51 k_ptr = &k_info[o_ptr->k_idx];
54 * We don't want to give the player free info about
55 * the level of the item or the number of charges.
57 /* The item must be "known" */
58 char tmp_str[MAX_NLEN];
59 if (!object_is_known(o_ptr)) {
60 msg_format(_("充填する前に鑑定されている必要があります!", "The item must be identified first!"));
63 if ((player_ptr->au >= 50) && get_check(_("$50で鑑定しますか? ", "Identify for 50 gold? ")))
67 identify_item(player_ptr, o_ptr);
68 describe_flavor(player_ptr, tmp_str, o_ptr, 0);
69 msg_format(_("%s です。", "You have: %s."), tmp_str);
71 autopick_alter_item(player_ptr, item, FALSE);
72 building_prt_gold(player_ptr);
78 DEPTH lev = k_info[o_ptr->k_idx].level;
80 if (o_ptr->tval == TV_ROD) {
81 if (o_ptr->timeout > 0) {
82 price = (lev * 50 * o_ptr->timeout) / k_ptr->pval;
85 msg_format(_("それは再充填する必要はありません。", "That doesn't need to be recharged."));
88 } else if (o_ptr->tval == TV_STAFF) {
89 price = (k_info[o_ptr->k_idx].cost / 10) * o_ptr->number;
90 price = MAX(10, price);
92 price = (k_info[o_ptr->k_idx].cost / 10);
93 price = MAX(10, price);
96 if (o_ptr->tval == TV_WAND && (o_ptr->pval / o_ptr->number >= k_ptr->pval)) {
97 if (o_ptr->number > 1) {
98 msg_print(_("この魔法棒はもう充分に充填されています。", "These wands are already fully charged."));
100 msg_print(_("この魔法棒はもう充分に充填されています。", "This wand is already fully charged."));
104 } else if (o_ptr->tval == TV_STAFF && o_ptr->pval >= k_ptr->pval) {
105 if (o_ptr->number > 1) {
106 msg_print(_("この杖はもう充分に充填されています。", "These staffs are already fully charged."));
108 msg_print(_("この杖はもう充分に充填されています。", "This staff is already fully charged."));
114 if (player_ptr->au < price) {
115 describe_flavor(player_ptr, tmp_str, o_ptr, OD_NAME_ONLY);
117 msg_format("%sを再充填するには$%d 必要です!", tmp_str, price);
119 msg_format("You need %d gold to recharge %s!", price, tmp_str);
124 PARAMETER_VALUE charges;
125 if (o_ptr->tval == TV_ROD) {
127 if (get_check(format("そのロッドを$%d で再充填しますか?", price)))
129 if (get_check(format("Recharge the %s for %d gold? ", ((o_ptr->number > 1) ? "rods" : "rod"), price)))
139 if (o_ptr->tval == TV_STAFF)
140 max_charges = k_ptr->pval - o_ptr->pval;
142 max_charges = o_ptr->number * k_ptr->pval - o_ptr->pval;
144 charges = (PARAMETER_VALUE)get_quantity(
145 format(_("一回分$%d で何回分充填しますか?", "Add how many charges for %d gold apiece? "), price), MIN(player_ptr->au / price, max_charges));
151 o_ptr->pval += charges;
152 o_ptr->ident &= ~(IDENT_EMPTY);
155 describe_flavor(player_ptr, tmp_str, o_ptr, 0);
157 msg_format("%sを$%d で再充填しました。", tmp_str, price);
159 msg_format("%^s %s recharged for %d gold.", tmp_str, ((o_ptr->number > 1) ? "were" : "was"), price);
161 player_ptr->update |= (PU_COMBINE | PU_REORDER);
162 player_ptr->window_flags |= (PW_INVEN);
163 player_ptr->au -= price;
167 * @brief 魔道具の使用回数を回復させる施設の一括処理向けサブルーチン / Recharge rods, wands and staffs
169 * The player can select the number of charges to add\n
170 * (up to a limit), and the recharge never fails.\n
172 * The cost for rods depends on the level of the rod. The prices\n
173 * for recharging wands and staffs are dependent on the cost of\n
175 * @param player_ptr プレーヤーへの参照ポインタ
177 void building_recharge_all(player_type *player_ptr)
181 prt(_(" 再充填の費用はアイテムの種類によります。", " The prices of recharge depend on the type."), 6, 0);
184 PRICE total_cost = 0;
185 for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++) {
187 o_ptr = &player_ptr->inventory_list[i];
189 if (o_ptr->tval < TV_STAFF || o_ptr->tval > TV_ROD)
191 if (!object_is_known(o_ptr))
194 DEPTH lev = k_info[o_ptr->k_idx].level;
196 k_ptr = &k_info[o_ptr->k_idx];
198 switch (o_ptr->tval) {
200 price = (lev * 50 * o_ptr->timeout) / k_ptr->pval;
204 price = (k_info[o_ptr->k_idx].cost / 10) * o_ptr->number;
205 price = MAX(10, price);
206 price = (k_ptr->pval - o_ptr->pval) * price;
210 price = (k_info[o_ptr->k_idx].cost / 10);
211 price = MAX(10, price);
212 price = (o_ptr->number * k_ptr->pval - o_ptr->pval) * price;
224 msg_print(_("充填する必要はありません。", "No need to recharge."));
229 if (player_ptr->au < total_cost) {
230 msg_format(_("すべてのアイテムを再充填するには$%d 必要です!", "You need %d gold to recharge all items!"), total_cost);
235 if (!get_check(format(_("すべてのアイテムを $%d で再充填しますか?", "Recharge all items for %d gold? "), total_cost)))
238 for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++) {
240 o_ptr = &player_ptr->inventory_list[i];
242 k_ptr = &k_info[o_ptr->k_idx];
244 if (o_ptr->tval < TV_STAFF || o_ptr->tval > TV_ROD)
247 if (!object_is_known(o_ptr)) {
248 identify_item(player_ptr, o_ptr);
249 autopick_alter_item(player_ptr, i, FALSE);
252 switch (o_ptr->tval) {
257 if (o_ptr->pval < k_ptr->pval)
258 o_ptr->pval = k_ptr->pval;
260 o_ptr->ident &= ~(IDENT_EMPTY);
263 if (o_ptr->pval < o_ptr->number * k_ptr->pval)
264 o_ptr->pval = o_ptr->number * k_ptr->pval;
266 o_ptr->ident &= ~(IDENT_EMPTY);
274 msg_format(_("$%d で再充填しました。", "You pay %d gold."), total_cost);
276 player_ptr->update |= (PU_COMBINE | PU_REORDER);
277 player_ptr->window_flags |= (PW_INVEN);
278 player_ptr->au -= total_cost;