OSDN Git Service

[Fix] 消去時に画面右端までの消去されないことがある
[hengbandforosx/hengbandosx.git] / src / view / object-describer.cpp
1 #include "view/object-describer.h"
2 #include "cmd-action/cmd-spell.h"
3 #include "flavor/flavor-describer.h"
4 #include "flavor/object-flavor-types.h"
5 #include "object-enchant/special-object-flags.h"
6 #include "object/tval-types.h"
7 #include "perception/object-perception.h"
8 #include "player-base/player-class.h"
9 #include "realm/realm-names-table.h"
10 #include "spell/spell-info.h"
11 #include "system/item-entity.h"
12 #include "system/player-type-definition.h"
13 #include "term/term-color-types.h"
14 #include "view/display-messages.h"
15
16 /*!
17  * @brief 魔道具の使用回数の残量を示すメッセージを表示する
18  * @param item 残量を表示したいインベントリ内のアイテム
19  */
20 void inven_item_charges(const ItemEntity &item)
21 {
22     if (!item.is_wand_staff() || !item.is_known()) {
23         return;
24     }
25
26 #ifdef JP
27     if (item.pval <= 0) {
28         msg_print("もう魔力が残っていない。");
29     } else {
30         msg_format("あと %d 回分の魔力が残っている。", item.pval);
31     }
32 #else
33     if (item.pval != 1) {
34         msg_format("You have %d charges remaining.", item.pval);
35     } else {
36         msg_format("You have %d charge remaining.", item.pval);
37     }
38 #endif
39 }
40
41 /*!
42  * @brief アイテムの残り所持数メッセージを表示する /
43  * Describe an item in the inventory.
44  * @param player_ptr プレイヤーへの参照ポインタ
45  * @param item 残量を表示したいプレイヤーのアイテム所持スロット
46  */
47 void inven_item_describe(PlayerType *player_ptr, short item)
48 {
49     auto *o_ptr = &player_ptr->inventory_list[item];
50     const auto item_name = describe_flavor(player_ptr, o_ptr, 0);
51 #ifdef JP
52     if (o_ptr->number <= 0) {
53         msg_format("もう%sを持っていない。", item_name.data());
54     } else {
55         msg_format("まだ %sを持っている。", item_name.data());
56     }
57 #else
58     msg_format("You have %s.", item_name.data());
59 #endif
60 }
61
62 /*!
63  * @brief 現在アクティブになっているウィンドウにオブジェクトの詳細を表示する
64  * @param player_ptr プレイヤーへの参照ポインタ
65  * @details Include list of usable spells for readible books
66  */
67 void display_koff(PlayerType *player_ptr)
68 {
69     if (player_ptr->tracking_bi_id == 0) {
70         return;
71     }
72
73     for (auto y = 0; y < game_term->hgt; y++) {
74         term_erase(0, y);
75     }
76
77     ItemEntity item;
78     item.prep(player_ptr->tracking_bi_id);
79     const auto item_name = describe_flavor(player_ptr, &item, (OD_OMIT_PREFIX | OD_NAME_ONLY | OD_STORE));
80     term_putstr(0, 0, -1, TERM_WHITE, item_name);
81     const auto sval = item.bi_key.sval().value();
82     const short use_realm = tval2realm(item.bi_key.tval());
83
84     if (player_ptr->realm1 || player_ptr->realm2) {
85         if ((use_realm != player_ptr->realm1) && (use_realm != player_ptr->realm2)) {
86             return;
87         }
88     } else {
89         PlayerClass pc(player_ptr);
90         if (!pc.is_every_magic()) {
91             return;
92         }
93         if (!is_magic(use_realm)) {
94             return;
95         }
96         if (pc.equals(PlayerClassType::RED_MAGE) && (use_realm != REALM_ARCANE) && (sval > 1)) {
97             return;
98         }
99     }
100
101     auto num = 0;
102     int spells[64]{};
103     for (int spell = 0; spell < 32; spell++) {
104         if (fake_spell_flags[sval] & (1UL << spell)) {
105             spells[num++] = spell;
106         }
107     }
108
109     print_spells(player_ptr, 0, spells, num, 2, 0, use_realm);
110 }