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-bow-types.h"
13 #include "sv-definition/sv-food-types.h"
15 BaseitemKey::BaseitemKey(const ItemKindType type_value, const std::optional<int> &subtype_value)
16 : type_value(type_value)
17 , subtype_value(subtype_value)
21 bool BaseitemKey::operator==(const BaseitemKey &other) const
23 return (this->type_value == other.type_value) && (this->subtype_value == other.subtype_value);
26 // @details type_valueに大小があればそれを判定し、同一ならばsubtype_valueの大小を判定する.
27 bool BaseitemKey::operator<(const BaseitemKey &other) const
29 if (this->type_value < other.type_value) {
33 if (this->type_value > other.type_value) {
37 return this->subtype_value < other.subtype_value;
40 ItemKindType BaseitemKey::tval() const
42 return this->type_value;
45 std::optional<int> BaseitemKey::sval() const
47 return this->subtype_value;
51 * @brief 射撃武器に対応する矢/弾薬のベースアイテムIDを返す
52 * @return 対応する矢/弾薬のベースアイテムID
54 ItemKindType BaseitemKey::get_arrow_kind() const
56 if (this->type_value != ItemKindType::BOW) {
57 return ItemKindType::NONE;
60 if (!this->subtype_value.has_value()) {
61 return ItemKindType::NONE;
64 switch (this->subtype_value.value()) {
66 return ItemKindType::SHOT;
70 return ItemKindType::ARROW;
73 return ItemKindType::BOLT;
76 return ItemKindType::NO_AMMO;
78 return ItemKindType::NONE;
82 bool BaseitemKey::is_spell_book() const
84 switch (this->type_value) {
85 case ItemKindType::LIFE_BOOK:
86 case ItemKindType::SORCERY_BOOK:
87 case ItemKindType::NATURE_BOOK:
88 case ItemKindType::CHAOS_BOOK:
89 case ItemKindType::DEATH_BOOK:
90 case ItemKindType::TRUMP_BOOK:
91 case ItemKindType::ARCANE_BOOK:
92 case ItemKindType::CRAFT_BOOK:
93 case ItemKindType::DEMON_BOOK:
94 case ItemKindType::CRUSADE_BOOK:
95 case ItemKindType::MUSIC_BOOK:
96 case ItemKindType::HISSATSU_BOOK:
97 case ItemKindType::HEX_BOOK:
104 bool BaseitemKey::is_high_level_book() const
106 if (!this->is_spell_book()) {
110 if (this->type_value == ItemKindType::ARCANE_BOOK) {
114 return this->subtype_value >= 2;
117 bool BaseitemKey::is_melee_weapon() const
119 switch (this->type_value) {
120 case ItemKindType::POLEARM:
121 case ItemKindType::SWORD:
122 case ItemKindType::DIGGING:
123 case ItemKindType::HAFTED:
130 bool BaseitemKey::is_ammo() const
132 switch (this->type_value) {
133 case ItemKindType::SHOT:
134 case ItemKindType::ARROW:
135 case ItemKindType::BOLT:
143 * @brief 未鑑定名を持つか否かの判定
144 * @details FOODはキノコが該当する
146 bool BaseitemKey::has_unidentified_name() const
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:
157 case ItemKindType::FOOD:
158 return this->is_mushrooms();
164 bool BaseitemKey::can_recharge() const
166 switch (this->type_value) {
167 case ItemKindType::STAFF:
168 case ItemKindType::WAND:
169 case ItemKindType::ROD:
176 bool BaseitemKey::is_wand_rod() const
178 switch (this->type_value) {
179 case ItemKindType::WAND:
180 case ItemKindType::ROD:
187 bool BaseitemKey::is_wand_staff() const
189 switch (this->type_value) {
190 case ItemKindType::WAND:
191 case ItemKindType::STAFF:
198 bool BaseitemKey::is_protector() const
200 switch (this->type_value) {
201 case ItemKindType::BOOTS:
202 case ItemKindType::GLOVES:
203 case ItemKindType::HELM:
204 case ItemKindType::CROWN:
205 case ItemKindType::SHIELD:
206 case ItemKindType::CLOAK:
207 case ItemKindType::SOFT_ARMOR:
208 case ItemKindType::HARD_ARMOR:
209 case ItemKindType::DRAG_ARMOR:
216 bool BaseitemKey::can_be_aura_protector() const
218 switch (this->type_value) {
219 case ItemKindType::CLOAK:
220 case ItemKindType::SOFT_ARMOR:
221 case ItemKindType::HARD_ARMOR:
228 bool BaseitemKey::is_wearable() const
230 switch (this->type_value) {
231 case ItemKindType::BOW:
232 case ItemKindType::DIGGING:
233 case ItemKindType::HAFTED:
234 case ItemKindType::POLEARM:
235 case ItemKindType::SWORD:
236 case ItemKindType::BOOTS:
237 case ItemKindType::GLOVES:
238 case ItemKindType::HELM:
239 case ItemKindType::CROWN:
240 case ItemKindType::SHIELD:
241 case ItemKindType::CLOAK:
242 case ItemKindType::SOFT_ARMOR:
243 case ItemKindType::HARD_ARMOR:
244 case ItemKindType::DRAG_ARMOR:
245 case ItemKindType::LITE:
246 case ItemKindType::AMULET:
247 case ItemKindType::RING:
248 case ItemKindType::CARD:
255 bool BaseitemKey::is_mushrooms() const
257 if (!this->subtype_value.has_value()) {
261 switch (this->subtype_value.value()) {
263 case SV_FOOD_BLINDNESS:
264 case SV_FOOD_PARANOIA:
265 case SV_FOOD_CONFUSION:
266 case SV_FOOD_HALLUCINATION:
267 case SV_FOOD_PARALYSIS:
268 case SV_FOOD_WEAKNESS:
269 case SV_FOOD_SICKNESS:
270 case SV_FOOD_STUPIDITY:
271 case SV_FOOD_NAIVETY:
272 case SV_FOOD_UNHEALTH:
273 case SV_FOOD_DISEASE:
274 case SV_FOOD_CURE_POISON:
275 case SV_FOOD_CURE_BLINDNESS:
276 case SV_FOOD_CURE_PARANOIA:
277 case SV_FOOD_CURE_CONFUSION:
278 case SV_FOOD_CURE_SERIOUS:
279 case SV_FOOD_RESTORE_STR:
280 case SV_FOOD_RESTORE_CON:
281 case SV_FOOD_RESTORING:
288 BaseitemInfo::BaseitemInfo()
289 : bi_key(ItemKindType::NONE)
293 std::vector<BaseitemInfo> baseitems_info;