OSDN Git Service

Merge pull request #3532 from sikabane-works/release/3.0.0.87-alpha
[hengbandforosx/hengbandosx.git] / src / spell-realm / spells-nature.cpp
1 #include "spell-realm/spells-nature.h"
2 #include "flavor/flavor-describer.h"
3 #include "flavor/object-flavor-types.h"
4 #include "floor/floor-object.h"
5 #include "object-enchant/tr-types.h"
6 #include "object-hook/hook-armor.h"
7 #include "object/item-tester-hooker.h"
8 #include "object/item-use-flags.h"
9 #include "racial/racial-android.h"
10 #include "system/item-entity.h"
11 #include "system/player-type-definition.h"
12 #include "util/bit-flags-calculator.h"
13 #include "view/display-messages.h"
14
15 /*!
16  * @brief 防具の錆止め防止処理
17  * @param player_ptr 錆止め実行者の参照ポインタ
18  * @return ターン消費を要する処理を行ったならばTRUEを返す
19  */
20 bool rustproof(PlayerType *player_ptr)
21 {
22     const auto q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
23     const auto s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
24     OBJECT_IDX item;
25     const auto options = USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT;
26     auto *o_ptr = choose_object(player_ptr, &item, q, s, options, FuncItemTester(&ItemEntity::is_protector));
27     if (o_ptr == nullptr) {
28         return false;
29     }
30
31     const auto item_name = describe_flavor(player_ptr, o_ptr, OD_OMIT_PREFIX | OD_NAME_ONLY);
32     o_ptr->art_flags.set(TR_IGNORE_ACID);
33     if ((o_ptr->to_a < 0) && !o_ptr->is_cursed()) {
34 #ifdef JP
35         msg_format("%sは新品同様になった!", item_name.data());
36 #else
37         msg_format("%s %s look%s as good as new!", ((item >= 0) ? "Your" : "The"), item_name.data(), ((o_ptr->number > 1) ? "" : "s"));
38 #endif
39         o_ptr->to_a = 0;
40     }
41
42 #ifdef JP
43     msg_format("%sは腐食しなくなった。", item_name.data());
44 #else
45     msg_format("%s %s %s now protected against corrosion.", ((item >= 0) ? "Your" : "The"), item_name.data(), ((o_ptr->number > 1) ? "are" : "is"));
46 #endif
47     calc_android_exp(player_ptr);
48     return true;
49 }