2 * @file weapon-shield.cpp
6 #include "action/weapon-shield.h"
7 #include "flavor/flavor-describer.h"
8 #include "game-option/birth-options.h"
9 #include "inventory/inventory-object.h"
10 #include "inventory/inventory-slot-types.h"
11 #include "object-hook/hook-weapon.h"
12 #include "player-info/equipment-info.h"
13 #include "player-status/player-hand-types.h"
14 #include "system/item-entity.h"
15 #include "system/player-type-definition.h"
16 #include "view/display-messages.h"
20 * @param player_ptr プレイヤーへの参照ポインタ
21 * @param item 持ち替えを行いたい装備部位ID
23 void verify_equip_slot(PlayerType *player_ptr, INVENTORY_IDX item)
25 ItemEntity *o_ptr, *new_o_ptr;
26 std::string item_name;
27 if (item == INVEN_MAIN_HAND) {
28 if (!has_melee_weapon(player_ptr, INVEN_SUB_HAND)) {
32 o_ptr = &player_ptr->inventory_list[INVEN_SUB_HAND];
33 item_name = describe_flavor(player_ptr, o_ptr, 0);
35 if (o_ptr->is_cursed()) {
36 if (o_ptr->allow_two_hands_wielding() && can_two_hands_wielding(player_ptr)) {
37 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), item_name.data());
42 new_o_ptr = &player_ptr->inventory_list[INVEN_MAIN_HAND];
43 new_o_ptr->copy_from(o_ptr);
44 inven_item_increase(player_ptr, INVEN_SUB_HAND, -((int)o_ptr->number));
45 inven_item_optimize(player_ptr, INVEN_SUB_HAND);
46 if (new_o_ptr->allow_two_hands_wielding() && can_two_hands_wielding(player_ptr)) {
47 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), item_name.data());
49 const auto mes = _("%sを%sで構えた。", "You are wielding %s in your %s hand.");
50 msg_format(mes, item_name.data(), (left_hander ? _("左手", "left") : _("右手", "right")));
55 if (item != INVEN_SUB_HAND) {
59 o_ptr = &player_ptr->inventory_list[INVEN_MAIN_HAND];
60 if (o_ptr->is_valid()) {
61 item_name = describe_flavor(player_ptr, o_ptr, 0);
64 if (has_melee_weapon(player_ptr, INVEN_MAIN_HAND)) {
65 if (o_ptr->allow_two_hands_wielding() && can_two_hands_wielding(player_ptr)) {
66 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), item_name.data());
72 if ((empty_hands(player_ptr, false) & EMPTY_HAND_MAIN) || o_ptr->is_cursed()) {
76 new_o_ptr = &player_ptr->inventory_list[INVEN_SUB_HAND];
77 new_o_ptr->copy_from(o_ptr);
78 inven_item_increase(player_ptr, INVEN_MAIN_HAND, -((int)o_ptr->number));
79 inven_item_optimize(player_ptr, INVEN_MAIN_HAND);
80 msg_format(_("%sを持ち替えた。", "You shifted %s to your other hand."), item_name.data());