1 #include "system/angband.h"
2 #include "market/building-recharger.h"
3 #include "object/object-hook.h"
4 #include "object/object-kind.h"
5 #include "object/object-flavor.h"
6 #include "market/building-util.h"
7 #include "inventory/player-inventory.h"
8 #include "spell/spells3.h"
9 #include "autopick/autopick.h"
12 * @brief 魔道具の使用回数を回復させる施設のメインルーチン / Recharge rods, wands and staffs
14 * The player can select the number of charges to add\n
15 * (up to a limit), and the recharge never fails.\n
17 * The cost for rods depends on the level of the rod. The prices\n
18 * for recharging wands and staffs are dependent on the cost of\n
20 * @param player_ptr プレーヤーへの参照ポインタ
23 void building_recharge(player_type *player_ptr)
27 prt(_(" 再充填の費用はアイテムの種類によります。", " The prices of recharge depend on the type."), 6, 0);
28 item_tester_hook = item_tester_hook_recharge;
30 concptr q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
31 concptr s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
35 o_ptr = choose_object(player_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
40 k_ptr = &k_info[o_ptr->k_idx];
43 * We don't want to give the player free info about
44 * the level of the item or the number of charges.
46 /* The item must be "known" */
47 char tmp_str[MAX_NLEN];
48 if (!object_is_known(o_ptr)) {
49 msg_format(_("充填する前に鑑定されている必要があります!", "The item must be identified first!"));
52 if ((player_ptr->au >= 50) && get_check(_("$50で鑑定しますか? ", "Identify for 50 gold? ")))
56 identify_item(player_ptr, o_ptr);
57 object_desc(player_ptr, tmp_str, o_ptr, 0);
58 msg_format(_("%s です。", "You have: %s."), tmp_str);
60 autopick_alter_item(player_ptr, item, FALSE);
61 building_prt_gold(player_ptr);
67 DEPTH lev = k_info[o_ptr->k_idx].level;
69 if (o_ptr->tval == TV_ROD) {
70 if (o_ptr->timeout > 0) {
71 price = (lev * 50 * o_ptr->timeout) / k_ptr->pval;
74 msg_format(_("それは再充填する必要はありません。", "That doesn't need to be recharged."));
77 } else if (o_ptr->tval == TV_STAFF) {
78 price = (k_info[o_ptr->k_idx].cost / 10) * o_ptr->number;
79 price = MAX(10, price);
81 price = (k_info[o_ptr->k_idx].cost / 10);
82 price = MAX(10, price);
85 if (o_ptr->tval == TV_WAND
86 && (o_ptr->pval / o_ptr->number >= k_ptr->pval)) {
87 if (o_ptr->number > 1) {
88 msg_print(_("この魔法棒はもう充分に充填されています。", "These wands are already fully charged."));
90 msg_print(_("この魔法棒はもう充分に充填されています。", "This wand is already fully charged."));
94 } else if (o_ptr->tval == TV_STAFF && o_ptr->pval >= k_ptr->pval) {
95 if (o_ptr->number > 1) {
96 msg_print(_("この杖はもう充分に充填されています。", "These staffs are already fully charged."));
98 msg_print(_("この杖はもう充分に充填されています。", "This staff is already fully charged."));
104 if (player_ptr->au < price) {
105 object_desc(player_ptr, tmp_str, o_ptr, OD_NAME_ONLY);
107 msg_format("%sを再充填するには$%d 必要です!", tmp_str, price);
109 msg_format("You need %d gold to recharge %s!", price, tmp_str);
114 PARAMETER_VALUE charges;
115 if (o_ptr->tval == TV_ROD) {
117 if (get_check(format("そのロッドを$%d で再充填しますか?", price)))
119 if (get_check(format("Recharge the %s for %d gold? ",
120 ((o_ptr->number > 1) ? "rods" : "rod"), price)))
130 if (o_ptr->tval == TV_STAFF)
131 max_charges = k_ptr->pval - o_ptr->pval;
133 max_charges = o_ptr->number * k_ptr->pval - o_ptr->pval;
135 charges = (PARAMETER_VALUE)get_quantity(format(_("一回分$%d で何回分充填しますか?", "Add how many charges for %d gold? "), price),
136 MIN(player_ptr->au / price, max_charges));
142 o_ptr->pval += charges;
143 o_ptr->ident &= ~(IDENT_EMPTY);
146 object_desc(player_ptr, tmp_str, o_ptr, 0);
148 msg_format("%sを$%d で再充填しました。", tmp_str, price);
150 msg_format("%^s %s recharged for %d gold.", tmp_str, ((o_ptr->number > 1) ? "were" : "was"), price);
152 player_ptr->update |= (PU_COMBINE | PU_REORDER);
153 player_ptr->window |= (PW_INVEN);
154 player_ptr->au -= price;
158 * @brief 魔道具の使用回数を回復させる施設の一括処理向けサブルーチン / Recharge rods, wands and staffs
160 * The player can select the number of charges to add\n
161 * (up to a limit), and the recharge never fails.\n
163 * The cost for rods depends on the level of the rod. The prices\n
164 * for recharging wands and staffs are dependent on the cost of\n
166 * @param player_ptr プレーヤーへの参照ポインタ
169 void building_recharge_all(player_type *player_ptr)
173 prt(_(" 再充填の費用はアイテムの種類によります。", " The prices of recharge depend on the type."), 6, 0);
176 PRICE total_cost = 0;
177 for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++) {
179 o_ptr = &player_ptr->inventory_list[i];
181 if (o_ptr->tval < TV_STAFF || o_ptr->tval > TV_ROD)
183 if (!object_is_known(o_ptr))
186 DEPTH lev = k_info[o_ptr->k_idx].level;
188 k_ptr = &k_info[o_ptr->k_idx];
190 switch (o_ptr->tval) {
192 price = (lev * 50 * o_ptr->timeout) / k_ptr->pval;
196 price = (k_info[o_ptr->k_idx].cost / 10) * o_ptr->number;
197 price = MAX(10, price);
198 price = (k_ptr->pval - o_ptr->pval) * price;
202 price = (k_info[o_ptr->k_idx].cost / 10);
203 price = MAX(10, price);
204 price = (o_ptr->number * k_ptr->pval - o_ptr->pval) * price;
213 msg_print(_("充填する必要はありません。", "No need to recharge."));
218 if (player_ptr->au < total_cost) {
219 msg_format(_("すべてのアイテムを再充填するには$%d 必要です!", "You need %d gold to recharge all items!"), total_cost);
224 if (!get_check(format(_("すべてのアイテムを $%d で再充填しますか?", "Recharge all items for %d gold? "), total_cost)))
227 for (INVENTORY_IDX i = 0; i < INVEN_PACK; i++) {
229 o_ptr = &player_ptr->inventory_list[i];
231 k_ptr = &k_info[o_ptr->k_idx];
233 if (o_ptr->tval < TV_STAFF || o_ptr->tval > TV_ROD)
236 if (!object_is_known(o_ptr)) {
237 identify_item(player_ptr, o_ptr);
238 autopick_alter_item(player_ptr, i, FALSE);
241 switch (o_ptr->tval) {
246 if (o_ptr->pval < k_ptr->pval)
247 o_ptr->pval = k_ptr->pval;
249 o_ptr->ident &= ~(IDENT_EMPTY);
252 if (o_ptr->pval < o_ptr->number * k_ptr->pval)
253 o_ptr->pval = o_ptr->number * k_ptr->pval;
255 o_ptr->ident &= ~(IDENT_EMPTY);
260 msg_format(_("$%d で再充填しました。", "You pay %d gold."), total_cost);
262 player_ptr->update |= (PU_COMBINE | PU_REORDER);
263 player_ptr->window |= (PW_INVEN);
264 player_ptr->au -= total_cost;