2 * @brief ベースアイテム情報の構造体 / Information about object "kinds", including player knowledge.
6 * ゲーム進行用のセーブファイル上では aware と tried のみ保存対象とすること。と英文ではあるが実際はもっとある様子である。 /
7 * Only "aware" and "tried" are saved in the savefile
10 #include "system/baseitem-info.h"
11 #include "object/tval-types.h"
12 #include "sv-definition/sv-armor-types.h"
13 #include "sv-definition/sv-bow-types.h"
14 #include "sv-definition/sv-food-types.h"
15 #include "sv-definition/sv-lite-types.h"
16 #include "sv-definition/sv-protector-types.h"
17 #include "sv-definition/sv-rod-types.h"
18 #include "sv-definition/sv-weapon-types.h"
19 #include "system/angband-exceptions.h"
21 #include <unordered_map>
24 constexpr auto ITEM_NOT_BOW = "This item is not a bow!";
25 constexpr auto ITEM_NOT_ROD = "This item is not a rod!";
26 constexpr auto ITEM_NOT_LITE = "This item is not a lite!";
29 bool BaseitemKey::operator==(const BaseitemKey &other) const
31 return (this->type_value == other.type_value) && (this->subtype_value == other.subtype_value);
34 // @details type_valueに大小があればそれを判定し、同一ならばsubtype_valueの大小を判定する.
35 bool BaseitemKey::operator<(const BaseitemKey &other) const
37 if (this->type_value < other.type_value) {
41 if (this->type_value > other.type_value) {
45 return this->subtype_value < other.subtype_value;
48 ItemKindType BaseitemKey::tval() const
50 return this->type_value;
53 std::optional<int> BaseitemKey::sval() const
55 return this->subtype_value;
59 * @brief 射撃武器に対応する矢/弾薬のベースアイテムIDを返す
60 * @return 対応する矢/弾薬のベースアイテムID
62 ItemKindType BaseitemKey::get_arrow_kind() const
64 if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) {
65 THROW_EXCEPTION(std::logic_error, ITEM_NOT_BOW);
68 switch (*this->subtype_value) {
70 return ItemKindType::SHOT;
74 return ItemKindType::ARROW;
77 return ItemKindType::BOLT;
80 return ItemKindType::NO_AMMO;
82 return ItemKindType::NONE;
86 bool BaseitemKey::is_spell_book() const
88 switch (this->type_value) {
89 case ItemKindType::LIFE_BOOK:
90 case ItemKindType::SORCERY_BOOK:
91 case ItemKindType::NATURE_BOOK:
92 case ItemKindType::CHAOS_BOOK:
93 case ItemKindType::DEATH_BOOK:
94 case ItemKindType::TRUMP_BOOK:
95 case ItemKindType::ARCANE_BOOK:
96 case ItemKindType::CRAFT_BOOK:
97 case ItemKindType::DEMON_BOOK:
98 case ItemKindType::CRUSADE_BOOK:
99 case ItemKindType::MUSIC_BOOK:
100 case ItemKindType::HISSATSU_BOOK:
101 case ItemKindType::HEX_BOOK:
108 bool BaseitemKey::is_high_level_book() const
110 if (!this->is_spell_book()) {
114 if (this->type_value == ItemKindType::ARCANE_BOOK) {
118 return this->subtype_value >= 2;
121 bool BaseitemKey::is_melee_weapon() const
123 switch (this->type_value) {
124 case ItemKindType::POLEARM:
125 case ItemKindType::SWORD:
126 case ItemKindType::DIGGING:
127 case ItemKindType::HAFTED:
134 bool BaseitemKey::is_ammo() const
136 switch (this->type_value) {
137 case ItemKindType::SHOT:
138 case ItemKindType::ARROW:
139 case ItemKindType::BOLT:
147 * @brief 未鑑定名を持つか否かの判定
148 * @details FOODはキノコが該当する
150 bool BaseitemKey::has_unidentified_name() const
152 switch (this->type_value) {
153 case ItemKindType::AMULET:
154 case ItemKindType::RING:
155 case ItemKindType::STAFF:
156 case ItemKindType::WAND:
157 case ItemKindType::ROD:
158 case ItemKindType::SCROLL:
159 case ItemKindType::POTION:
161 case ItemKindType::FOOD:
162 return this->is_mushrooms();
168 bool BaseitemKey::can_recharge() const
170 switch (this->type_value) {
171 case ItemKindType::STAFF:
172 case ItemKindType::WAND:
173 case ItemKindType::ROD:
180 bool BaseitemKey::is_wand_rod() const
182 switch (this->type_value) {
183 case ItemKindType::WAND:
184 case ItemKindType::ROD:
191 bool BaseitemKey::is_wand_staff() const
193 switch (this->type_value) {
194 case ItemKindType::WAND:
195 case ItemKindType::STAFF:
202 bool BaseitemKey::is_protector() const
204 switch (this->type_value) {
205 case ItemKindType::BOOTS:
206 case ItemKindType::GLOVES:
207 case ItemKindType::HELM:
208 case ItemKindType::CROWN:
209 case ItemKindType::SHIELD:
210 case ItemKindType::CLOAK:
211 case ItemKindType::SOFT_ARMOR:
212 case ItemKindType::HARD_ARMOR:
213 case ItemKindType::DRAG_ARMOR:
220 bool BaseitemKey::can_be_aura_protector() const
222 switch (this->type_value) {
223 case ItemKindType::CLOAK:
224 case ItemKindType::SOFT_ARMOR:
225 case ItemKindType::HARD_ARMOR:
232 bool BaseitemKey::is_wearable() const
234 switch (this->type_value) {
235 case ItemKindType::BOW:
236 case ItemKindType::DIGGING:
237 case ItemKindType::HAFTED:
238 case ItemKindType::POLEARM:
239 case ItemKindType::SWORD:
240 case ItemKindType::BOOTS:
241 case ItemKindType::GLOVES:
242 case ItemKindType::HELM:
243 case ItemKindType::CROWN:
244 case ItemKindType::SHIELD:
245 case ItemKindType::CLOAK:
246 case ItemKindType::SOFT_ARMOR:
247 case ItemKindType::HARD_ARMOR:
248 case ItemKindType::DRAG_ARMOR:
249 case ItemKindType::LITE:
250 case ItemKindType::AMULET:
251 case ItemKindType::RING:
252 case ItemKindType::CARD:
259 bool BaseitemKey::is_weapon() const
261 switch (this->type_value) {
262 case ItemKindType::BOW:
263 case ItemKindType::DIGGING:
264 case ItemKindType::HAFTED:
265 case ItemKindType::POLEARM:
266 case ItemKindType::SWORD:
273 bool BaseitemKey::is_equipement() const
275 switch (this->type_value) {
276 case ItemKindType::SHOT:
277 case ItemKindType::ARROW:
278 case ItemKindType::BOLT:
279 case ItemKindType::BOW:
280 case ItemKindType::DIGGING:
281 case ItemKindType::HAFTED:
282 case ItemKindType::POLEARM:
283 case ItemKindType::SWORD:
284 case ItemKindType::BOOTS:
285 case ItemKindType::GLOVES:
286 case ItemKindType::HELM:
287 case ItemKindType::CROWN:
288 case ItemKindType::SHIELD:
289 case ItemKindType::CLOAK:
290 case ItemKindType::SOFT_ARMOR:
291 case ItemKindType::HARD_ARMOR:
292 case ItemKindType::DRAG_ARMOR:
293 case ItemKindType::LITE:
294 case ItemKindType::AMULET:
295 case ItemKindType::RING:
296 case ItemKindType::CARD:
303 bool BaseitemKey::is_melee_ammo() const
305 switch (this->type_value) {
306 case ItemKindType::HAFTED:
307 case ItemKindType::POLEARM:
308 case ItemKindType::DIGGING:
309 case ItemKindType::BOLT:
310 case ItemKindType::ARROW:
311 case ItemKindType::SHOT:
313 case ItemKindType::SWORD:
314 return this->subtype_value != SV_POISON_NEEDLE;
320 bool BaseitemKey::is_orthodox_melee_weapon() const
322 switch (this->type_value) {
323 case ItemKindType::HAFTED:
324 case ItemKindType::POLEARM:
325 case ItemKindType::DIGGING:
327 case ItemKindType::SWORD:
328 return this->subtype_value != SV_POISON_NEEDLE;
334 bool BaseitemKey::is_broken_weapon() const
336 if (this->type_value != ItemKindType::SWORD) {
340 if (!this->subtype_value) {
344 switch (*this->subtype_value) {
345 case SV_BROKEN_DAGGER:
346 case SV_BROKEN_SWORD:
353 bool BaseitemKey::is_throwable() const
355 switch (this->type_value) {
356 case ItemKindType::DIGGING:
357 case ItemKindType::HAFTED:
358 case ItemKindType::POLEARM:
359 case ItemKindType::SWORD:
366 bool BaseitemKey::is_wieldable_in_etheir_hand() const
368 switch (this->type_value) {
369 case ItemKindType::DIGGING:
370 case ItemKindType::HAFTED:
371 case ItemKindType::POLEARM:
372 case ItemKindType::SWORD:
373 case ItemKindType::SHIELD:
374 case ItemKindType::CAPTURE:
375 case ItemKindType::CARD:
382 bool BaseitemKey::is_rare() const
384 static const std::unordered_map<ItemKindType, const std::set<int>> rare_table = {
385 { ItemKindType::HAFTED, { SV_MACE_OF_DISRUPTION, SV_WIZSTAFF } },
386 { ItemKindType::POLEARM, { SV_SCYTHE_OF_SLICING, SV_DEATH_SCYTHE } },
387 { ItemKindType::SWORD, { SV_BLADE_OF_CHAOS, SV_DIAMOND_EDGE, SV_POISON_NEEDLE, SV_HAYABUSA } },
388 { ItemKindType::SHIELD, { SV_DRAGON_SHIELD, SV_MIRROR_SHIELD } },
389 { ItemKindType::HELM, { SV_DRAGON_HELM } },
390 { ItemKindType::BOOTS, { SV_PAIR_OF_DRAGON_GREAVE } },
391 { ItemKindType::CLOAK, { SV_ELVEN_CLOAK, SV_ETHEREAL_CLOAK, SV_SHADOW_CLOAK, SV_MAGIC_RESISTANCE_CLOAK } },
392 { ItemKindType::GLOVES, { SV_SET_OF_DRAGON_GLOVES } },
393 { ItemKindType::SOFT_ARMOR, { SV_KUROSHOUZOKU, SV_ABUNAI_MIZUGI } },
394 { ItemKindType::HARD_ARMOR, { SV_MITHRIL_CHAIN_MAIL, SV_MITHRIL_PLATE_MAIL, SV_ADAMANTITE_PLATE_MAIL } },
395 { ItemKindType::DRAG_ARMOR, { /* Any */ } },
398 if (!this->subtype_value) {
402 if (auto it = rare_table.find(this->type_value); it != rare_table.end()) {
403 const auto &svals = it->second;
404 return svals.empty() || (svals.find(*this->subtype_value) != svals.end());
410 short BaseitemKey::get_bow_energy() const
412 if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) {
413 THROW_EXCEPTION(std::logic_error, ITEM_NOT_BOW);
416 switch (*this->subtype_value) {
430 int BaseitemKey::get_arrow_magnification() const
432 if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) {
433 THROW_EXCEPTION(std::logic_error, ITEM_NOT_BOW);
436 switch (*this->subtype_value) {
451 bool BaseitemKey::is_aiming_rod() const
453 if ((this->type_value != ItemKindType::ROD) || !this->subtype_value) {
454 THROW_EXCEPTION(std::logic_error, ITEM_NOT_ROD);
457 switch (*this->subtype_value) {
458 case SV_ROD_TELEPORT_AWAY:
459 case SV_ROD_DISARMING:
461 case SV_ROD_SLEEP_MONSTER:
462 case SV_ROD_SLOW_MONSTER:
463 case SV_ROD_HYPODYNAMIA:
464 case SV_ROD_POLYMORPH:
465 case SV_ROD_ACID_BOLT:
466 case SV_ROD_ELEC_BOLT:
467 case SV_ROD_FIRE_BOLT:
468 case SV_ROD_COLD_BOLT:
469 case SV_ROD_ACID_BALL:
470 case SV_ROD_ELEC_BALL:
471 case SV_ROD_FIRE_BALL:
472 case SV_ROD_COLD_BALL:
473 case SV_ROD_STONE_TO_MUD:
480 bool BaseitemKey::is_lite_requiring_fuel() const
482 if ((this->type_value != ItemKindType::LITE) || !this->subtype_value) {
483 THROW_EXCEPTION(std::logic_error, ITEM_NOT_LITE);
486 switch (*this->subtype_value) {
488 case SV_LITE_LANTERN:
495 bool BaseitemKey::is_junk() const
497 switch (this->type_value) {
498 case ItemKindType::SKELETON:
499 case ItemKindType::BOTTLE:
500 case ItemKindType::JUNK:
501 case ItemKindType::STATUE:
508 bool BaseitemKey::is_armour() const
510 switch (this->type_value) {
511 case ItemKindType::SOFT_ARMOR:
512 case ItemKindType::HARD_ARMOR:
513 case ItemKindType::DRAG_ARMOR:
520 bool BaseitemKey::is_cross_bow() const
522 if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) {
526 switch (*this->subtype_value) {
535 bool BaseitemKey::is_mushrooms() const
537 if (!this->subtype_value) {
541 switch (*this->subtype_value) {
543 case SV_FOOD_BLINDNESS:
544 case SV_FOOD_PARANOIA:
545 case SV_FOOD_CONFUSION:
546 case SV_FOOD_HALLUCINATION:
547 case SV_FOOD_PARALYSIS:
548 case SV_FOOD_WEAKNESS:
549 case SV_FOOD_SICKNESS:
550 case SV_FOOD_STUPIDITY:
551 case SV_FOOD_NAIVETY:
552 case SV_FOOD_UNHEALTH:
553 case SV_FOOD_DISEASE:
554 case SV_FOOD_CURE_POISON:
555 case SV_FOOD_CURE_BLINDNESS:
556 case SV_FOOD_CURE_PARANOIA:
557 case SV_FOOD_CURE_CONFUSION:
558 case SV_FOOD_CURE_SERIOUS:
559 case SV_FOOD_RESTORE_STR:
560 case SV_FOOD_RESTORE_CON:
561 case SV_FOOD_RESTORING:
568 BaseitemInfo::BaseitemInfo()
569 : bi_key(ItemKindType::NONE)
574 * @brief 最初から簡易な名称が明らかなベースアイテムにその旨のフラグを立てる
576 void BaseitemInfo::decide_easy_know()
578 switch (this->bi_key.tval()) {
579 case ItemKindType::LIFE_BOOK:
580 case ItemKindType::SORCERY_BOOK:
581 case ItemKindType::NATURE_BOOK:
582 case ItemKindType::CHAOS_BOOK:
583 case ItemKindType::DEATH_BOOK:
584 case ItemKindType::TRUMP_BOOK:
585 case ItemKindType::ARCANE_BOOK:
586 case ItemKindType::CRAFT_BOOK:
587 case ItemKindType::DEMON_BOOK:
588 case ItemKindType::CRUSADE_BOOK:
589 case ItemKindType::MUSIC_BOOK:
590 case ItemKindType::HISSATSU_BOOK:
591 case ItemKindType::HEX_BOOK:
592 case ItemKindType::FLASK:
593 case ItemKindType::JUNK:
594 case ItemKindType::BOTTLE:
595 case ItemKindType::SKELETON:
596 case ItemKindType::SPIKE:
597 case ItemKindType::WHISTLE:
598 case ItemKindType::FOOD:
599 case ItemKindType::POTION:
600 case ItemKindType::SCROLL:
601 case ItemKindType::ROD:
602 case ItemKindType::STATUE:
603 case ItemKindType::PARCHMENT:
604 this->easy_know = true;
607 this->easy_know = false;
613 * @brief オブジェクトを試行済にする
615 void BaseitemInfo::mark_as_tried()
620 std::vector<BaseitemInfo> baseitems_info;