The master and develop branches track hengband.
OS X development happens on the macos-1-6-2, macos-2-2-1, and macos-develop branches.
修订版 | 29320a5ddeaab6f085c655764bd1d47fb3d6e0b7 (tree) |
---|---|
时间 | 2022-11-25 23:10:19 |
作者 | Hourier <66951241+Hourier@user...> |
Commiter | GitHub |
Merge pull request #2827 from Hourier/Prepare-Replace-ItemEntity-TvalSval-to-BaseitemKey-2
ItemEntity::tval/sval をBaseitemKey に差し替えるための準備をした その2
@@ -156,7 +156,7 @@ void random_plus(ItemEntity *o_ptr) | ||
156 | 156 | return; |
157 | 157 | } |
158 | 158 | |
159 | - int this_type = o_ptr->is_weapon_ammo() ? 23 : 19; | |
159 | + const auto this_type = o_ptr->is_weapon_ammo() ? 23 : 19; | |
160 | 160 | switch (randint1(this_type)) { |
161 | 161 | case 1: |
162 | 162 | case 2: |
@@ -204,7 +204,7 @@ bool exe_eat_charge_of_magic_device(PlayerType *player_ptr, ItemEntity *o_ptr, I | ||
204 | 204 | } |
205 | 205 | |
206 | 206 | if (item >= 0) { |
207 | - inven_item_charges(player_ptr, item); | |
207 | + inven_item_charges(player_ptr->inventory_list[item]); | |
208 | 208 | } else { |
209 | 209 | floor_item_charges(player_ptr->current_floor_ptr, 0 - item); |
210 | 210 | } |
@@ -32,7 +32,7 @@ void AbstractWeaponEnchanter::give_killing_bonus() | ||
32 | 32 | auto tohit2 = static_cast<short>(m_bonus(10, this->level)); |
33 | 33 | auto todam2 = static_cast<short>(m_bonus(10, this->level)); |
34 | 34 | |
35 | - if ((this->o_ptr->tval == ItemKindType::BOLT) || (this->o_ptr->tval == ItemKindType::ARROW) || (this->o_ptr->tval == ItemKindType::SHOT)) { | |
35 | + if (this->o_ptr->is_ammo()) { | |
36 | 36 | tohit2 = (tohit2 + 1) / 2; |
37 | 37 | todam2 = (todam2 + 1) / 2; |
38 | 38 | } |
@@ -16,8 +16,7 @@ | ||
16 | 16 | */ |
17 | 17 | bool object_is_favorite(PlayerType *player_ptr, const ItemEntity *o_ptr) |
18 | 18 | { |
19 | - /* Only melee weapons match */ | |
20 | - if (!(o_ptr->tval == ItemKindType::POLEARM || o_ptr->tval == ItemKindType::SWORD || o_ptr->tval == ItemKindType::DIGGING || o_ptr->tval == ItemKindType::HAFTED)) { | |
19 | + if (!o_ptr->is_melee_weapon()) { | |
21 | 20 | return false; |
22 | 21 | } |
23 | 22 |
@@ -136,7 +136,7 @@ void ObjectUseEntity::execute() | ||
136 | 136 | } |
137 | 137 | |
138 | 138 | if (this->item >= 0) { |
139 | - inven_item_charges(this->player_ptr, this->item); | |
139 | + inven_item_charges(this->player_ptr->inventory_list[this->item]); | |
140 | 140 | } else { |
141 | 141 | floor_item_charges(this->player_ptr->current_floor_ptr, 0 - this->item); |
142 | 142 | } |
@@ -125,7 +125,7 @@ void ObjectZapWandEntity::execute(INVENTORY_IDX item) | ||
125 | 125 | set_bits(this->player_ptr->update, inventory_flags); |
126 | 126 | o_ptr->pval--; |
127 | 127 | if (item >= 0) { |
128 | - inven_item_charges(this->player_ptr, item); | |
128 | + inven_item_charges(this->player_ptr->inventory_list[item]); | |
129 | 129 | return; |
130 | 130 | } |
131 | 131 |
@@ -76,8 +76,6 @@ enum class ItemKindType : short { | ||
76 | 76 | |
77 | 77 | #define TV_EQUIP_BEGIN ItemKindType::SHOT |
78 | 78 | #define TV_EQUIP_END ItemKindType::CARD |
79 | -#define TV_MISSILE_BEGIN ItemKindType::SHOT | |
80 | -#define TV_MISSILE_END ItemKindType::BOLT | |
81 | 79 | #define TV_WEARABLE_BEGIN ItemKindType::BOW |
82 | 80 | #define TV_WEARABLE_END ItemKindType::CARD |
83 | 81 | #define TV_WEAPON_BEGIN ItemKindType::BOW |
@@ -62,8 +62,7 @@ void object_aware(PlayerType *player_ptr, const ItemEntity *o_ptr) | ||
62 | 62 | return; |
63 | 63 | } |
64 | 64 | |
65 | - // 未鑑定名の無いアイテムは記録しない | |
66 | - if (!((o_ptr->tval >= ItemKindType::AMULET && o_ptr->tval <= ItemKindType::POTION) || o_ptr->tval == ItemKindType::FOOD)) { | |
65 | + if (!o_ptr->has_unidentified_name()) { | |
67 | 66 | return; |
68 | 67 | } |
69 | 68 |
@@ -333,8 +333,7 @@ static void update_bonuses(PlayerType *player_ptr) | ||
333 | 333 | update_ability_scores(player_ptr); |
334 | 334 | o_ptr = &player_ptr->inventory_list[INVEN_BOW]; |
335 | 335 | if (o_ptr->bi_id) { |
336 | - const BaseitemKey key(o_ptr->tval, o_ptr->sval); | |
337 | - player_ptr->tval_ammo = key.get_arrow_kind(); | |
336 | + player_ptr->tval_ammo = o_ptr->get_arrow_kind(); | |
338 | 337 | player_ptr->num_fire = calc_num_fire(player_ptr, o_ptr); |
339 | 338 | } |
340 | 339 |
@@ -1048,8 +1047,7 @@ int16_t calc_num_fire(PlayerType *player_ptr, ItemEntity *o_ptr) | ||
1048 | 1047 | return (int16_t)num; |
1049 | 1048 | } |
1050 | 1049 | |
1051 | - const BaseitemKey key(o_ptr->tval, o_ptr->sval); | |
1052 | - const auto tval_ammo = key.get_arrow_kind(); | |
1050 | + const auto tval_ammo = o_ptr->get_arrow_kind(); | |
1053 | 1051 | PlayerClass pc(player_ptr); |
1054 | 1052 | if (pc.equals(PlayerClassType::RANGER) && (tval_ammo == ItemKindType::ARROW)) { |
1055 | 1053 | num += (player_ptr->lev * 4); |
@@ -167,7 +167,7 @@ int Smith::get_essence_consumption(SmithEffectType effect, const ItemEntity *o_p | ||
167 | 167 | return consumption; |
168 | 168 | } |
169 | 169 | |
170 | - if ((o_ptr->tval >= ItemKindType::SHOT) && (o_ptr->tval <= ItemKindType::BOLT)) { | |
170 | + if (o_ptr->is_ammo()) { | |
171 | 171 | consumption = (consumption + 9) / 10; |
172 | 172 | } |
173 | 173 |
@@ -273,19 +273,28 @@ bool detect_objects_normal(PlayerType *player_ptr, POSITION range) | ||
273 | 273 | return detect; |
274 | 274 | } |
275 | 275 | |
276 | +static bool is_object_magically(const ItemKindType tval) | |
277 | +{ | |
278 | + switch (tval) { | |
279 | + case ItemKindType::WHISTLE: | |
280 | + case ItemKindType::AMULET: | |
281 | + case ItemKindType::RING: | |
282 | + case ItemKindType::STAFF: | |
283 | + case ItemKindType::WAND: | |
284 | + case ItemKindType::ROD: | |
285 | + case ItemKindType::SCROLL: | |
286 | + case ItemKindType::POTION: | |
287 | + return true; | |
288 | + default: | |
289 | + return false; | |
290 | + } | |
291 | +} | |
292 | + | |
276 | 293 | /*! |
277 | - * @brief 魔法効果のあるのアイテムオブジェクトを感知する / Detect all "magic" objects on the current panel. | |
294 | + * @brief 魔法効果のあるのアイテムオブジェクトを感知する | |
278 | 295 | * @param player_ptr プレイヤーへの参照ポインタ |
279 | 296 | * @param range 効果範囲 |
280 | - * @return 効力があった場合TRUEを返す | |
281 | - * @details | |
282 | - * <pre> | |
283 | - * This will light up all spaces with "magic" items, including artifacts, | |
284 | - * ego-items, potions, scrolls, books, rods, wands, staffs, amulets, rings, | |
285 | - * and "enchanted" items of the "good" variety. | |
286 | - * | |
287 | - * It can probably be argued that this function is now too powerful. | |
288 | - * </pre> | |
297 | + * @return 1つ以上感知したか否か | |
289 | 298 | */ |
290 | 299 | bool detect_objects_magic(PlayerType *player_ptr, POSITION range) |
291 | 300 | { |
@@ -293,27 +302,22 @@ bool detect_objects_magic(PlayerType *player_ptr, POSITION range) | ||
293 | 302 | range /= 3; |
294 | 303 | } |
295 | 304 | |
296 | - ItemKindType tv; | |
297 | - bool detect = false; | |
305 | + auto detect = false; | |
298 | 306 | for (OBJECT_IDX i = 1; i < player_ptr->current_floor_ptr->o_max; i++) { |
299 | 307 | auto *o_ptr = &player_ptr->current_floor_ptr->o_list[i]; |
300 | - | |
301 | - if (!o_ptr->is_valid()) { | |
302 | - continue; | |
303 | - } | |
304 | - if (o_ptr->is_held_by_monster()) { | |
308 | + if (!o_ptr->is_valid() || o_ptr->is_held_by_monster()) { | |
305 | 309 | continue; |
306 | 310 | } |
307 | 311 | |
308 | - POSITION y = o_ptr->iy; | |
309 | - POSITION x = o_ptr->ix; | |
310 | - | |
312 | + auto y = o_ptr->iy; | |
313 | + auto x = o_ptr->ix; | |
311 | 314 | if (distance(player_ptr->y, player_ptr->x, y, x) > range) { |
312 | 315 | continue; |
313 | 316 | } |
314 | 317 | |
315 | - tv = o_ptr->tval; | |
316 | - if (o_ptr->is_artifact() || o_ptr->is_ego() || (tv == ItemKindType::WHISTLE) || (tv == ItemKindType::AMULET) || (tv == ItemKindType::RING) || (tv == ItemKindType::STAFF) || (tv == ItemKindType::WAND) || (tv == ItemKindType::ROD) || (tv == ItemKindType::SCROLL) || (tv == ItemKindType::POTION) || (tv == ItemKindType::LIFE_BOOK) || (tv == ItemKindType::SORCERY_BOOK) || (tv == ItemKindType::NATURE_BOOK) || (tv == ItemKindType::CHAOS_BOOK) || (tv == ItemKindType::DEATH_BOOK) || (tv == ItemKindType::TRUMP_BOOK) || (tv == ItemKindType::ARCANE_BOOK) || (tv == ItemKindType::CRAFT_BOOK) || (tv == ItemKindType::DEMON_BOOK) || (tv == ItemKindType::CRUSADE_BOOK) || (tv == ItemKindType::MUSIC_BOOK) || (tv == ItemKindType::HISSATSU_BOOK) || (tv == ItemKindType::HEX_BOOK) || ((o_ptr->to_a > 0) || (o_ptr->to_h + o_ptr->to_d > 0))) { | |
318 | + auto has_bonus = o_ptr->to_a > 0; | |
319 | + has_bonus |= o_ptr->to_h + o_ptr->to_d > 0; | |
320 | + if (o_ptr->is_artifact() || o_ptr->is_ego() || is_object_magically(o_ptr->tval) || o_ptr->is_spell_book() || has_bonus) { | |
317 | 321 | o_ptr->marked.set(OmType::FOUND); |
318 | 322 | lite_spot(player_ptr, y, x); |
319 | 323 | detect = true; |
@@ -10,6 +10,7 @@ | ||
10 | 10 | #include "system/baseitem-info.h" |
11 | 11 | #include "object/tval-types.h" |
12 | 12 | #include "sv-definition/sv-bow-types.h" |
13 | +#include "sv-definition/sv-food-types.h" | |
13 | 14 | |
14 | 15 | BaseitemKey::BaseitemKey(const ItemKindType type_value, const std::optional<int> &subtype_value) |
15 | 16 | : type_value(type_value) |
@@ -113,6 +114,86 @@ bool BaseitemKey::is_high_level_book() const | ||
113 | 114 | return this->subtype_value >= 2; |
114 | 115 | } |
115 | 116 | |
117 | +bool BaseitemKey::is_melee_weapon() const | |
118 | +{ | |
119 | + switch (this->type_value) { | |
120 | + case ItemKindType::POLEARM: | |
121 | + case ItemKindType::SWORD: | |
122 | + case ItemKindType::DIGGING: | |
123 | + case ItemKindType::HAFTED: | |
124 | + return true; | |
125 | + default: | |
126 | + return false; | |
127 | + } | |
128 | +} | |
129 | + | |
130 | +bool BaseitemKey::is_ammo() const | |
131 | +{ | |
132 | + switch (this->type_value) { | |
133 | + case ItemKindType::SHOT: | |
134 | + case ItemKindType::ARROW: | |
135 | + case ItemKindType::BOLT: | |
136 | + return true; | |
137 | + default: | |
138 | + return false; | |
139 | + } | |
140 | +} | |
141 | + | |
142 | +/* | |
143 | + * @brief 未鑑定名を持つか否かの判定 | |
144 | + * @details FOODはキノコが該当する | |
145 | + */ | |
146 | +bool BaseitemKey::has_unidentified_name() const | |
147 | +{ | |
148 | + switch (this->type_value) { | |
149 | + case ItemKindType::AMULET: | |
150 | + case ItemKindType::RING: | |
151 | + case ItemKindType::STAFF: | |
152 | + case ItemKindType::WAND: | |
153 | + case ItemKindType::ROD: | |
154 | + case ItemKindType::SCROLL: | |
155 | + case ItemKindType::POTION: | |
156 | + return true; | |
157 | + case ItemKindType::FOOD: | |
158 | + return this->is_mushrooms(); | |
159 | + default: | |
160 | + return false; | |
161 | + } | |
162 | +} | |
163 | + | |
164 | +bool BaseitemKey::is_mushrooms() const | |
165 | +{ | |
166 | + if (!this->subtype_value.has_value()) { | |
167 | + return false; | |
168 | + } | |
169 | + | |
170 | + switch (this->subtype_value.value()) { | |
171 | + case SV_FOOD_POISON: | |
172 | + case SV_FOOD_BLINDNESS: | |
173 | + case SV_FOOD_PARANOIA: | |
174 | + case SV_FOOD_CONFUSION: | |
175 | + case SV_FOOD_HALLUCINATION: | |
176 | + case SV_FOOD_PARALYSIS: | |
177 | + case SV_FOOD_WEAKNESS: | |
178 | + case SV_FOOD_SICKNESS: | |
179 | + case SV_FOOD_STUPIDITY: | |
180 | + case SV_FOOD_NAIVETY: | |
181 | + case SV_FOOD_UNHEALTH: | |
182 | + case SV_FOOD_DISEASE: | |
183 | + case SV_FOOD_CURE_POISON: | |
184 | + case SV_FOOD_CURE_BLINDNESS: | |
185 | + case SV_FOOD_CURE_PARANOIA: | |
186 | + case SV_FOOD_CURE_CONFUSION: | |
187 | + case SV_FOOD_CURE_SERIOUS: | |
188 | + case SV_FOOD_RESTORE_STR: | |
189 | + case SV_FOOD_RESTORE_CON: | |
190 | + case SV_FOOD_RESTORING: | |
191 | + return true; | |
192 | + default: | |
193 | + return false; | |
194 | + } | |
195 | +} | |
196 | + | |
116 | 197 | BaseitemInfo::BaseitemInfo() |
117 | 198 | : bi_key(ItemKindType::NONE) |
118 | 199 | { |
@@ -40,10 +40,15 @@ public: | ||
40 | 40 | ItemKindType get_arrow_kind() const; |
41 | 41 | bool is_spell_book() const; |
42 | 42 | bool is_high_level_book() const; |
43 | + bool is_melee_weapon() const; | |
44 | + bool is_ammo() const; | |
45 | + bool has_unidentified_name() const; | |
43 | 46 | |
44 | 47 | private: |
45 | 48 | ItemKindType type_value; |
46 | 49 | std::optional<int> subtype_value; |
50 | + | |
51 | + bool is_mushrooms() const; | |
47 | 52 | }; |
48 | 53 | |
49 | 54 | enum class ItemKindType : short; |
@@ -117,13 +117,12 @@ bool ItemEntity::is_weapon() const | ||
117 | 117 | } |
118 | 118 | |
119 | 119 | /*! |
120 | - * @brief アイテムが武器や矢弾として使用できるかを返す / Check if an object is weapon (including bows and ammo) | |
121 | - * Rare weapons/aromors including Blade of Chaos, Dragon armors, etc. | |
120 | + * @brief アイテムが武器や矢弾として使用できるかを返す | |
122 | 121 | * @return 武器や矢弾として使えるならばtrueを返す |
123 | 122 | */ |
124 | 123 | bool ItemEntity::is_weapon_ammo() const |
125 | 124 | { |
126 | - return (TV_MISSILE_BEGIN <= this->tval) && (this->tval <= TV_WEAPON_END); | |
125 | + return this->is_weapon() || this->is_ammo(); | |
127 | 126 | } |
128 | 127 | |
129 | 128 | /*! |
@@ -141,7 +140,7 @@ bool ItemEntity::is_weapon_armour_ammo() const | ||
141 | 140 | */ |
142 | 141 | bool ItemEntity::is_melee_weapon() const |
143 | 142 | { |
144 | - return (ItemKindType::DIGGING <= this->tval) && (this->tval <= ItemKindType::SWORD); | |
143 | + return BaseitemKey(this->tval).is_melee_weapon(); | |
145 | 144 | } |
146 | 145 | |
147 | 146 | /*! |
@@ -302,7 +301,7 @@ bool ItemEntity::allow_two_hands_wielding() const | ||
302 | 301 | */ |
303 | 302 | bool ItemEntity::is_ammo() const |
304 | 303 | { |
305 | - return (TV_MISSILE_BEGIN <= this->tval) && (this->tval <= TV_MISSILE_END); | |
304 | + return BaseitemKey(this->tval).is_ammo(); | |
306 | 305 | } |
307 | 306 | |
308 | 307 | /*! |
@@ -808,3 +807,13 @@ bool ItemEntity::is_specific_artifact(FixedArtifactId id) const | ||
808 | 807 | { |
809 | 808 | return this->fixed_artifact_idx == id; |
810 | 809 | } |
810 | + | |
811 | +bool ItemEntity::has_unidentified_name() const | |
812 | +{ | |
813 | + return BaseitemKey(this->tval).has_unidentified_name(); | |
814 | +} | |
815 | + | |
816 | +ItemKindType ItemEntity::get_arrow_kind() const | |
817 | +{ | |
818 | + return BaseitemKey(this->tval, this->sval).get_arrow_kind(); | |
819 | +} |
@@ -121,6 +121,8 @@ public: | ||
121 | 121 | char get_symbol() const; |
122 | 122 | int get_price() const; |
123 | 123 | bool is_specific_artifact(FixedArtifactId id) const; |
124 | + bool has_unidentified_name() const; | |
125 | + ItemKindType get_arrow_kind() const; | |
124 | 126 | |
125 | 127 | private: |
126 | 128 | int get_baseitem_price() const; |
@@ -14,6 +14,23 @@ | ||
14 | 14 | #include "system/monster-race-info.h" |
15 | 15 | #include "system/player-type-definition.h" |
16 | 16 | |
17 | +static int get_item_sort_rank(const ItemEntity &item) | |
18 | +{ | |
19 | + if (item.is_fixed_artifact()) { | |
20 | + return 3; | |
21 | + } | |
22 | + | |
23 | + if (item.art_name) { | |
24 | + return 2; | |
25 | + } | |
26 | + | |
27 | + if (item.is_ego()) { | |
28 | + return 1; | |
29 | + } | |
30 | + | |
31 | + return 0; | |
32 | +} | |
33 | + | |
17 | 34 | /*! |
18 | 35 | * @brief オブジェクトを定義された基準に従いソートするための関数 / |
19 | 36 | * Check if we have space for an item in the pack without overflow |
@@ -24,81 +41,73 @@ | ||
24 | 41 | */ |
25 | 42 | bool object_sort_comp(PlayerType *player_ptr, ItemEntity *o_ptr, int32_t o_value, ItemEntity *j_ptr) |
26 | 43 | { |
27 | - int o_type, j_type; | |
28 | - if (!j_ptr->bi_id) { | |
44 | + if (j_ptr->bi_id == 0) { | |
29 | 45 | return true; |
30 | 46 | } |
31 | 47 | |
32 | - if ((o_ptr->tval == get_realm1_book(player_ptr)) && (j_ptr->tval != get_realm1_book(player_ptr))) { | |
48 | + const auto o_tval = o_ptr->tval; | |
49 | + const auto j_tval = j_ptr->tval; | |
50 | + if ((o_tval == get_realm1_book(player_ptr)) && (j_tval != get_realm1_book(player_ptr))) { | |
33 | 51 | return true; |
34 | 52 | } |
35 | - if ((j_ptr->tval == get_realm1_book(player_ptr)) && (o_ptr->tval != get_realm1_book(player_ptr))) { | |
53 | + | |
54 | + if ((j_tval == get_realm1_book(player_ptr)) && (o_tval != get_realm1_book(player_ptr))) { | |
36 | 55 | return false; |
37 | 56 | } |
38 | 57 | |
39 | - if ((o_ptr->tval == get_realm2_book(player_ptr)) && (j_ptr->tval != get_realm2_book(player_ptr))) { | |
58 | + if ((o_tval == get_realm2_book(player_ptr)) && (j_tval != get_realm2_book(player_ptr))) { | |
40 | 59 | return true; |
41 | 60 | } |
42 | - if ((j_ptr->tval == get_realm2_book(player_ptr)) && (o_ptr->tval != get_realm2_book(player_ptr))) { | |
61 | + | |
62 | + if ((j_tval == get_realm2_book(player_ptr)) && (o_tval != get_realm2_book(player_ptr))) { | |
43 | 63 | return false; |
44 | 64 | } |
45 | 65 | |
46 | - if (o_ptr->tval > j_ptr->tval) { | |
66 | + if (o_tval > j_tval) { | |
47 | 67 | return true; |
48 | 68 | } |
49 | - if (o_ptr->tval < j_ptr->tval) { | |
69 | + | |
70 | + if (o_tval < j_tval) { | |
50 | 71 | return false; |
51 | 72 | } |
52 | 73 | |
53 | 74 | if (!o_ptr->is_aware()) { |
54 | 75 | return false; |
55 | 76 | } |
77 | + | |
56 | 78 | if (!j_ptr->is_aware()) { |
57 | 79 | return true; |
58 | 80 | } |
59 | 81 | |
60 | - if (o_ptr->sval < j_ptr->sval) { | |
82 | + const auto o_sval = o_ptr->sval; | |
83 | + const auto j_sval = j_ptr->sval; | |
84 | + if (o_sval < j_sval) { | |
61 | 85 | return true; |
62 | 86 | } |
63 | - if (o_ptr->sval > j_ptr->sval) { | |
87 | + | |
88 | + if (o_sval > j_sval) { | |
64 | 89 | return false; |
65 | 90 | } |
66 | 91 | |
67 | 92 | if (!o_ptr->is_known()) { |
68 | 93 | return false; |
69 | 94 | } |
95 | + | |
70 | 96 | if (!j_ptr->is_known()) { |
71 | 97 | return true; |
72 | 98 | } |
73 | 99 | |
74 | - if (o_ptr->is_fixed_artifact()) { | |
75 | - o_type = 3; | |
76 | - } else if (o_ptr->art_name) { | |
77 | - o_type = 2; | |
78 | - } else if (o_ptr->is_ego()) { | |
79 | - o_type = 1; | |
80 | - } else { | |
81 | - o_type = 0; | |
82 | - } | |
83 | - | |
84 | - if (j_ptr->is_fixed_artifact()) { | |
85 | - j_type = 3; | |
86 | - } else if (j_ptr->art_name) { | |
87 | - j_type = 2; | |
88 | - } else if (j_ptr->is_ego()) { | |
89 | - j_type = 1; | |
90 | - } else { | |
91 | - j_type = 0; | |
92 | - } | |
93 | - | |
94 | - if (o_type < j_type) { | |
100 | + const auto o_rank = get_item_sort_rank(*o_ptr); | |
101 | + const auto j_rank = get_item_sort_rank(*j_ptr); | |
102 | + if (o_rank < j_rank) { | |
95 | 103 | return true; |
96 | 104 | } |
97 | - if (o_type > j_type) { | |
105 | + | |
106 | + if (o_rank > j_rank) { | |
98 | 107 | return false; |
99 | 108 | } |
100 | 109 | |
101 | - switch (o_ptr->tval) { | |
110 | + switch (o_tval) { | |
102 | 111 | case ItemKindType::FIGURINE: |
103 | 112 | case ItemKindType::STATUE: |
104 | 113 | case ItemKindType::CORPSE: |
@@ -108,32 +117,35 @@ bool object_sort_comp(PlayerType *player_ptr, ItemEntity *o_ptr, int32_t o_value | ||
108 | 117 | if (monraces_info[o_r_idx].level < monraces_info[j_r_idx].level) { |
109 | 118 | return true; |
110 | 119 | } |
120 | + | |
111 | 121 | if ((monraces_info[o_r_idx].level == monraces_info[j_r_idx].level) && (o_ptr->pval < j_ptr->pval)) { |
112 | 122 | return true; |
113 | 123 | } |
124 | + | |
114 | 125 | return false; |
115 | 126 | } |
116 | - | |
117 | 127 | case ItemKindType::SHOT: |
118 | 128 | case ItemKindType::ARROW: |
119 | 129 | case ItemKindType::BOLT: |
120 | 130 | if (o_ptr->to_h + o_ptr->to_d < j_ptr->to_h + j_ptr->to_d) { |
121 | 131 | return true; |
122 | 132 | } |
133 | + | |
123 | 134 | if (o_ptr->to_h + o_ptr->to_d > j_ptr->to_h + j_ptr->to_d) { |
124 | 135 | return false; |
125 | 136 | } |
126 | - break; | |
127 | 137 | |
138 | + break; | |
128 | 139 | case ItemKindType::ROD: |
129 | 140 | if (o_ptr->pval < j_ptr->pval) { |
130 | 141 | return true; |
131 | 142 | } |
143 | + | |
132 | 144 | if (o_ptr->pval > j_ptr->pval) { |
133 | 145 | return false; |
134 | 146 | } |
135 | - break; | |
136 | 147 | |
148 | + break; | |
137 | 149 | default: |
138 | 150 | break; |
139 | 151 | } |
@@ -14,34 +14,31 @@ | ||
14 | 14 | #include "view/display-messages.h" |
15 | 15 | |
16 | 16 | /*! |
17 | - * @brief 魔道具の使用回数の残量を示すメッセージを表示する / | |
18 | - * Describe the charges on an item in the inventory. | |
19 | - * @param player_ptr プレイヤーへの参照ポインタ | |
20 | - * @param item 残量を表示したいプレイヤーのアイテム所持スロット | |
17 | + * @brief 魔道具の使用回数の残量を示すメッセージを表示する | |
18 | + * @param item 残量を表示したいインベントリ内のアイテム | |
21 | 19 | */ |
22 | -void inven_item_charges(PlayerType *player_ptr, INVENTORY_IDX item) | |
20 | +void inven_item_charges(const ItemEntity &item) | |
23 | 21 | { |
24 | - auto *o_ptr = &player_ptr->inventory_list[item]; | |
25 | - if ((o_ptr->tval != ItemKindType::STAFF) && (o_ptr->tval != ItemKindType::WAND)) { | |
22 | + const auto tval = item.tval; | |
23 | + if ((tval != ItemKindType::STAFF) && (tval != ItemKindType::WAND)) { | |
26 | 24 | return; |
27 | 25 | } |
28 | - if (!o_ptr->is_known()) { | |
26 | + | |
27 | + if (!item.is_known()) { | |
29 | 28 | return; |
30 | 29 | } |
31 | 30 | |
32 | 31 | #ifdef JP |
33 | - if (o_ptr->pval <= 0) { | |
32 | + if (item.pval <= 0) { | |
34 | 33 | msg_print("もう魔力が残っていない。"); |
35 | 34 | } else { |
36 | - msg_format("あと %d 回分の魔力が残っている。", o_ptr->pval); | |
35 | + msg_format("あと %d 回分の魔力が残っている。", item.pval); | |
37 | 36 | } |
38 | 37 | #else |
39 | - if (o_ptr->pval != 1) { | |
40 | - msg_format("You have %d charges remaining.", o_ptr->pval); | |
41 | - } | |
42 | - | |
43 | - else { | |
44 | - msg_format("You have %d charge remaining.", o_ptr->pval); | |
38 | + if (item.pval != 1) { | |
39 | + msg_format("You have %d charges remaining.", item.pval); | |
40 | + } else { | |
41 | + msg_format("You have %d charge remaining.", item.pval); | |
45 | 42 | } |
46 | 43 | #endif |
47 | 44 | } |
@@ -52,7 +49,7 @@ void inven_item_charges(PlayerType *player_ptr, INVENTORY_IDX item) | ||
52 | 49 | * @param player_ptr プレイヤーへの参照ポインタ |
53 | 50 | * @param item 残量を表示したいプレイヤーのアイテム所持スロット |
54 | 51 | */ |
55 | -void inven_item_describe(PlayerType *player_ptr, INVENTORY_IDX item) | |
52 | +void inven_item_describe(PlayerType *player_ptr, short item) | |
56 | 53 | { |
57 | 54 | auto *o_ptr = &player_ptr->inventory_list[item]; |
58 | 55 | GAME_TEXT o_name[MAX_NLEN]; |
@@ -1,8 +1,7 @@ | ||
1 | 1 | #pragma once |
2 | 2 | |
3 | -#include "system/angband.h" | |
4 | - | |
3 | +class ItemEntity; | |
5 | 4 | class PlayerType; |
6 | -void inven_item_charges(PlayerType *player_ptr, INVENTORY_IDX item); | |
7 | -void inven_item_describe(PlayerType *player_ptr, INVENTORY_IDX item); | |
5 | +void inven_item_charges(const ItemEntity &item); | |
6 | +void inven_item_describe(PlayerType *player_ptr, short item); | |
8 | 7 | void display_koff(PlayerType *player_ptr, short bi_id); |