diff --git a/VisualStudio/Hengband/Hengband.vcxproj b/VisualStudio/Hengband/Hengband.vcxproj index cee37b3259..58d618c114 100644 --- a/VisualStudio/Hengband/Hengband.vcxproj +++ b/VisualStudio/Hengband/Hengband.vcxproj @@ -325,6 +325,8 @@ + + @@ -929,7 +931,7 @@ - + @@ -1429,6 +1431,8 @@ + + @@ -1993,7 +1997,7 @@ - + diff --git a/VisualStudio/Hengband/Hengband.vcxproj.filters b/VisualStudio/Hengband/Hengband.vcxproj.filters index 7eefb0dd70..75bacac43b 100644 --- a/VisualStudio/Hengband/Hengband.vcxproj.filters +++ b/VisualStudio/Hengband/Hengband.vcxproj.filters @@ -2436,9 +2436,6 @@ system - - system - system @@ -2529,6 +2526,15 @@ system + + system\baseitem + + + system\baseitem + + + system\baseitem + @@ -5361,9 +5367,6 @@ timed-effect - - system - system @@ -5478,6 +5481,15 @@ system\enums + + system\baseitem + + + system\baseitem + + + system\baseitem + @@ -5751,6 +5763,9 @@ {123780c8-0bf5-47ac-aabd-c9f3dbe74855} + + {b1f45c00-0add-4e05-8c05-bac1f29550c6} + diff --git a/src/Makefile.am b/src/Makefile.am index 3944654707..b39497b26f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -922,7 +922,6 @@ hengband_SOURCES = \ system/angband-system.h system/angband-system.cpp \ system/angband-version.cpp system/angband-version.h \ system/artifact-type-definition.cpp system/artifact-type-definition.h \ - system/baseitem-info.cpp system/baseitem-info.h \ system/building-type-definition.cpp system/building-type-definition.h \ system/dungeon-data-definition.cpp system/dungeon-data-definition.h \ system/dungeon-info.cpp system/dungeon-info.h \ @@ -941,6 +940,10 @@ hengband_SOURCES = \ system/terrain-type-definition.cpp system/terrain-type-definition.h \ system/gamevalue.h \ \ + system/baseitem/baseitem-definition.cpp system/baseitem/baseitem-definition.h \ + system/baseitem/baseitem-key.cpp system/baseitem/baseitem-key.h \ + system/baseitem/baseitem-list.cpp system/baseitem/baseitem-list.h \ + \ system/enums/game-option-page.h \ system/enums/grid-flow.h \ system/enums/monrace/monrace-id.h \ diff --git a/src/action/activation-execution.cpp b/src/action/activation-execution.cpp index 7196aeeea1..302564b07c 100644 --- a/src/action/activation-execution.cpp +++ b/src/action/activation-execution.cpp @@ -35,7 +35,7 @@ #include "sv-definition/sv-lite-types.h" #include "sv-definition/sv-ring-types.h" #include "system/artifact-type-definition.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-key.h" #include "system/floor-type-definition.h" #include "system/item-entity.h" #include "system/monster-entity.h" diff --git a/src/action/tunnel-execution.cpp b/src/action/tunnel-execution.cpp index 80d8c8410e..c54f31bb40 100644 --- a/src/action/tunnel-execution.cpp +++ b/src/action/tunnel-execution.cpp @@ -118,7 +118,7 @@ bool exe_tunnel(PlayerType *player_ptr, POSITION y, POSITION x) } } - if (is_hidden_door(player_ptr, grid) && one_in_(4)) { + if (grid.is_hidden_door() && one_in_(4)) { search(player_ptr); } diff --git a/src/artifact/random-art-generator.cpp b/src/artifact/random-art-generator.cpp index 52aec5429c..6fb775692d 100644 --- a/src/artifact/random-art-generator.cpp +++ b/src/artifact/random-art-generator.cpp @@ -29,7 +29,7 @@ #include "perception/identification.h" #include "perception/object-perception.h" #include "sv-definition/sv-weapon-types.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "system/redrawing-flags-updater.h" diff --git a/src/autopick/autopick-entry.cpp b/src/autopick/autopick-entry.cpp index 1d6de3dc6e..eabe36c9e0 100644 --- a/src/autopick/autopick-entry.cpp +++ b/src/autopick/autopick-entry.cpp @@ -17,7 +17,7 @@ #include "perception/object-perception.h" #include "player-base/player-class.h" #include "player/player-realm.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" #include "system/item-entity.h" #include "system/monster-race-info.h" #include "system/player-type-definition.h" diff --git a/src/autopick/autopick-matcher.cpp b/src/autopick/autopick-matcher.cpp index 49cd80e183..802aeb6e49 100644 --- a/src/autopick/autopick-matcher.cpp +++ b/src/autopick/autopick-matcher.cpp @@ -20,7 +20,7 @@ #include "perception/object-perception.h" #include "player-base/player-class.h" #include "player/player-realm.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" #include "system/floor-type-definition.h" #include "system/item-entity.h" #include "system/monster-race-info.h" diff --git a/src/birth/game-play-initializer.cpp b/src/birth/game-play-initializer.cpp index 4d6354d61b..0f85c3c253 100644 --- a/src/birth/game-play-initializer.cpp +++ b/src/birth/game-play-initializer.cpp @@ -15,7 +15,8 @@ #include "player/digestion-processor.h" #include "player/player-spell-status.h" #include "system/artifact-type-definition.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/building-type-definition.h" #include "system/dungeon-info.h" #include "system/floor-type-definition.h" diff --git a/src/birth/inventory-initializer.cpp b/src/birth/inventory-initializer.cpp index 00230f6134..d28b9bece5 100644 --- a/src/birth/inventory-initializer.cpp +++ b/src/birth/inventory-initializer.cpp @@ -29,6 +29,8 @@ #include "sv-definition/sv-staff-types.h" #include "sv-definition/sv-wand-types.h" #include "sv-definition/sv-weapon-types.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "util/enum-converter.h" diff --git a/src/cmd-action/cmd-spell.cpp b/src/cmd-action/cmd-spell.cpp index 48a8e4536c..bbdff32236 100644 --- a/src/cmd-action/cmd-spell.cpp +++ b/src/cmd-action/cmd-spell.cpp @@ -56,7 +56,7 @@ #include "status/bad-status-setter.h" #include "status/base-status.h" #include "status/experience.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-key.h" #include "system/floor-type-definition.h" #include "system/item-entity.h" #include "system/player-type-definition.h" diff --git a/src/cmd-item/cmd-destroy.cpp b/src/cmd-item/cmd-destroy.cpp index 0e5eaeecec..030309d455 100644 --- a/src/cmd-item/cmd-destroy.cpp +++ b/src/cmd-item/cmd-destroy.cpp @@ -30,7 +30,7 @@ #include "racial/racial-android.h" #include "status/action-setter.h" #include "status/experience.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-key.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "system/redrawing-flags-updater.h" diff --git a/src/cmd-item/cmd-eat.cpp b/src/cmd-item/cmd-eat.cpp index 2aadd8e4d2..6218648523 100644 --- a/src/cmd-item/cmd-eat.cpp +++ b/src/cmd-item/cmd-eat.cpp @@ -227,7 +227,7 @@ void exe_eat_food(PlayerType *player_ptr, INVENTORY_IDX i_idx) sound(SOUND_EAT); PlayerEnergy(player_ptr).set_player_turn_energy(100); - const auto lev = o_ptr->get_baseitem().level; + const auto level = o_ptr->get_baseitem_level(); /* Identity not known yet */ const auto &bi_key = o_ptr->bi_key; @@ -263,7 +263,7 @@ void exe_eat_food(PlayerType *player_ptr, INVENTORY_IDX i_idx) /* The player is now aware of the object */ if (ident && !o_ptr->is_aware()) { object_aware(player_ptr, o_ptr); - gain_exp(player_ptr, (lev + (player_ptr->lev >> 1)) / player_ptr->lev); + gain_exp(player_ptr, (level + (player_ptr->lev >> 1)) / player_ptr->lev); } static constexpr auto flags_swrf = { diff --git a/src/cmd-item/cmd-magiceat.cpp b/src/cmd-item/cmd-magiceat.cpp index 376e7b296f..c9bc04dea3 100644 --- a/src/cmd-item/cmd-magiceat.cpp +++ b/src/cmd-item/cmd-magiceat.cpp @@ -71,7 +71,8 @@ #include "player-status/player-energy.h" #include "player/player-status-table.h" #include "spell/spell-info.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/player-type-definition.h" #include "target/target-getter.h" #include "term/screen-processor.h" diff --git a/src/cmd-item/cmd-zapwand.cpp b/src/cmd-item/cmd-zapwand.cpp index fa24bf7574..8874facd64 100644 --- a/src/cmd-item/cmd-zapwand.cpp +++ b/src/cmd-item/cmd-zapwand.cpp @@ -32,7 +32,7 @@ #include "status/action-setter.h" #include "status/experience.h" #include "sv-definition/sv-wand-types.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-key.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "target/target-getter.h" diff --git a/src/cmd-visual/cmd-visuals.cpp b/src/cmd-visual/cmd-visuals.cpp index 76e588e502..4cad915d16 100644 --- a/src/cmd-visual/cmd-visuals.cpp +++ b/src/cmd-visual/cmd-visuals.cpp @@ -14,6 +14,8 @@ #include "knowledge/knowledge-monsters.h" #include "knowledge/lighting-level-table.h" #include "main/sound-of-music.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/item-entity.h" #include "system/monster-race-info.h" #include "system/player-type-definition.h" diff --git a/src/combat/shoot.cpp b/src/combat/shoot.cpp index a57515ce46..bb863d6167 100644 --- a/src/combat/shoot.cpp +++ b/src/combat/shoot.cpp @@ -47,7 +47,7 @@ #include "player/player-status-table.h" #include "sv-definition/sv-bow-types.h" #include "system/artifact-type-definition.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-key.h" #include "system/enums/monrace/monrace-id.h" #include "system/floor-type-definition.h" #include "system/grid-type-definition.h" diff --git a/src/core/object-compressor.cpp b/src/core/object-compressor.cpp index 3879037416..fda13d1032 100644 --- a/src/core/object-compressor.cpp +++ b/src/core/object-compressor.cpp @@ -3,7 +3,6 @@ #include "floor/floor-object.h" #include "floor/geometry.h" #include "grid/grid.h" -#include "system/baseitem-info.h" #include "system/floor-type-definition.h" #include "system/item-entity.h" #include "system/monster-entity.h" @@ -72,7 +71,7 @@ void compact_objects(PlayerType *player_ptr, int size) for (OBJECT_IDX i = 1; i < floor_ptr->o_max; i++) { o_ptr = &floor_ptr->o_list[i]; - if (!o_ptr->is_valid() || (o_ptr->get_baseitem().level > cur_lev)) { + if (!o_ptr->is_valid() || (o_ptr->get_baseitem_level() > cur_lev)) { continue; } diff --git a/src/core/visuals-reseter.cpp b/src/core/visuals-reseter.cpp index 2a42f7f0b6..c7edab9722 100644 --- a/src/core/visuals-reseter.cpp +++ b/src/core/visuals-reseter.cpp @@ -1,7 +1,8 @@ #include "core/visuals-reseter.h" #include "game-option/special-options.h" #include "io/read-pref-file.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/monster-race-info.h" #include "system/player-type-definition.h" #include "system/terrain-type-definition.h" diff --git a/src/effect/effect-feature.cpp b/src/effect/effect-feature.cpp index 1fc7248156..f95114c865 100644 --- a/src/effect/effect-feature.cpp +++ b/src/effect/effect-feature.cpp @@ -171,7 +171,7 @@ bool affect_feature(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POS break; } case AttributeType::KILL_TRAP: { - if (is_hidden_door(player_ptr, grid)) { + if (grid.is_hidden_door()) { disclose_grid(player_ptr, y, x); if (known) { obvious = true; diff --git a/src/flavor/flavor-describer.cpp b/src/flavor/flavor-describer.cpp index c08978c4be..9ef2c0c433 100644 --- a/src/flavor/flavor-describer.cpp +++ b/src/flavor/flavor-describer.cpp @@ -29,7 +29,7 @@ #include "sv-definition/sv-lite-types.h" #include "sv-definition/sv-ring-types.h" #include "sv-definition/sv-weapon-types.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" #include "system/floor-type-definition.h" #include "system/item-entity.h" #include "system/player-type-definition.h" @@ -345,7 +345,7 @@ static std::string describe_charges_rod(const ItemEntity &item) return _("(充填中)", " (charging)"); } - const auto timeout_per_one = item.get_baseitem().pval; + const auto timeout_per_one = item.get_baseitem_pval(); auto num_of_charging = (item.timeout + (timeout_per_one - 1)) / timeout_per_one; if (num_of_charging > item.number) { num_of_charging = item.number; diff --git a/src/flavor/flavor-util.cpp b/src/flavor/flavor-util.cpp index 6522316ce9..2eda4171b6 100644 --- a/src/flavor/flavor-util.cpp +++ b/src/flavor/flavor-util.cpp @@ -5,6 +5,7 @@ #include "object/tval-types.h" #include "sv-definition/sv-food-types.h" #include "system/artifact-type-definition.h" +#include "system/baseitem/baseitem-definition.h" #include "system/item-entity.h" #include "util/string-processor.h" #include diff --git a/src/flavor/named-item-describer.cpp b/src/flavor/named-item-describer.cpp index fd050f95d2..f5a331cd59 100644 --- a/src/flavor/named-item-describer.cpp +++ b/src/flavor/named-item-describer.cpp @@ -11,6 +11,7 @@ #include "object-enchant/tr-types.h" #include "perception/object-perception.h" #include "system/artifact-type-definition.h" +#include "system/baseitem/baseitem-definition.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "util/bit-flags-calculator.h" diff --git a/src/flavor/object-flavor.cpp b/src/flavor/object-flavor.cpp index 40f1a00ada..36581dc2bd 100644 --- a/src/flavor/object-flavor.cpp +++ b/src/flavor/object-flavor.cpp @@ -32,7 +32,7 @@ #include "player/player-status.h" #include "sv-definition/sv-food-types.h" #include "sv-definition/sv-lite-types.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-key.h" #include "util/bit-flags-calculator.h" #include #include diff --git a/src/flavor/tval-description-switcher.cpp b/src/flavor/tval-description-switcher.cpp index 2a063b8966..31479cc0d5 100644 --- a/src/flavor/tval-description-switcher.cpp +++ b/src/flavor/tval-description-switcher.cpp @@ -10,7 +10,8 @@ #include "locale/english.h" #include "object-enchant/trg-types.h" #include "object/tval-types.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/item-entity.h" #include "system/monster-race-info.h" #include "util/bit-flags-calculator.h" diff --git a/src/floor/fixed-map-generator.cpp b/src/floor/fixed-map-generator.cpp index fc0005384c..0c3babf840 100644 --- a/src/floor/fixed-map-generator.cpp +++ b/src/floor/fixed-map-generator.cpp @@ -25,6 +25,8 @@ #include "room/rooms-vault.h" #include "sv-definition/sv-scroll-types.h" #include "system/artifact-type-definition.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/dungeon-info.h" #include "system/floor-type-definition.h" #include "system/grid-type-definition.h" diff --git a/src/floor/floor-events.cpp b/src/floor/floor-events.cpp index 21ea5d7111..132da3fb1e 100644 --- a/src/floor/floor-events.cpp +++ b/src/floor/floor-events.cpp @@ -28,7 +28,6 @@ #include "sv-definition/sv-protector-types.h" #include "sv-definition/sv-ring-types.h" #include "system/angband-system.h" -#include "system/baseitem-info.h" #include "system/dungeon-info.h" #include "system/floor-type-definition.h" #include "system/grid-type-definition.h" @@ -231,9 +230,9 @@ static byte get_dungeon_feeling(PlayerType *player_ptr) delta += 15 * base; } - const auto &baseitem = o_ptr->get_baseitem(); - if (!o_ptr->is_cursed() && !o_ptr->is_broken() && baseitem.level > floor_ptr->dun_level) { - delta += (baseitem.level - floor_ptr->dun_level) * base; + const auto item_level = o_ptr->get_baseitem_level(); + if (!o_ptr->is_cursed() && !o_ptr->is_broken() && item_level > floor_ptr->dun_level) { + delta += (item_level - floor_ptr->dun_level) * base; } rating += rating_boost(delta); diff --git a/src/grid/grid.cpp b/src/grid/grid.cpp index af1ba78a52..a5980dac73 100644 --- a/src/grid/grid.cpp +++ b/src/grid/grid.cpp @@ -145,18 +145,6 @@ bool new_player_spot(PlayerType *player_ptr) return true; } -/*! - * @brief マスに隠されたドアがあるかの判定を行う。 / Return TRUE if the given grid is a hidden closed door - * @param player_ptr プレイヤーへの参照ポインタ - * @param grid マス構造体の参照ポインタ - * @return 隠されたドアがあるならTRUEを返す。 - */ -bool is_hidden_door(PlayerType *player_ptr, const Grid &grid) -{ - (void)player_ptr; // 後でリファクタリングする. - return (grid.mimic || grid.cave_has_flag(TerrainCharacteristics::SECRET)) && grid.get_terrain().is_closed_door(); -} - /*! * @brief 指定された座標のマスが現在照らされているかを返す。 / Check for "local" illumination * @param y y座標 diff --git a/src/grid/grid.h b/src/grid/grid.h index 0d6501cf73..9ca06a4ef0 100644 --- a/src/grid/grid.h +++ b/src/grid/grid.h @@ -67,7 +67,6 @@ class MonraceDefinition; enum class GridCountKind; enum class TerrainCharacteristics; bool new_player_spot(PlayerType *player_ptr); -bool is_hidden_door(PlayerType *player_ptr, const Grid &grid); bool player_can_enter(PlayerType *player_ptr, FEAT_IDX feature, BIT_FLAGS16 mode); bool feat_uses_special(FEAT_IDX f_idx); void update_local_illumination(PlayerType *player_ptr, POSITION y, POSITION x); diff --git a/src/info-reader/baseitem-reader.cpp b/src/info-reader/baseitem-reader.cpp index bcc158cdda..344d578fc1 100644 --- a/src/info-reader/baseitem-reader.cpp +++ b/src/info-reader/baseitem-reader.cpp @@ -14,7 +14,8 @@ #include "main/angband-headers.h" #include "object-enchant/tr-types.h" #include "object/tval-types.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "term/gameterm.h" #include "util/bit-flags-calculator.h" #include "util/enum-converter.h" @@ -27,7 +28,7 @@ * @param what 参照元の文字列 * @return 見つけたらtrue */ -static bool grab_one_baseitem_flag(BaseitemInfo &baseitem, std::string_view what) +static bool grab_one_baseitem_flag(BaseitemDefinition &baseitem, std::string_view what) { if (TrFlags::grab_one_flag(baseitem.flags, baseitem_flags, what)) { return true; @@ -47,7 +48,7 @@ static bool grab_one_baseitem_flag(BaseitemInfo &baseitem, std::string_view what * @param baseitem 保管先のベースアイテム情報インスタンス * @return エラーコード */ -static errr set_baseitem_symbol(const nlohmann::json &symbol_data, BaseitemInfo &baseitem) +static errr set_baseitem_symbol(const nlohmann::json &symbol_data, BaseitemDefinition &baseitem) { if (symbol_data.is_null()) { return PARSE_ERROR_TOO_FEW_ARGUMENTS; @@ -81,7 +82,7 @@ static errr set_baseitem_symbol(const nlohmann::json &symbol_data, BaseitemInfo * @param baseitem 保管先のベースアイテム情報インスタンス * @return エラーコード */ -static errr set_baseitem_kind(nlohmann::json &baseitem_data, BaseitemInfo &baseitem) +static errr set_baseitem_kind(nlohmann::json &baseitem_data, BaseitemDefinition &baseitem) { if (baseitem_data.is_null()) { return PARSE_ERROR_TOO_FEW_ARGUMENTS; @@ -106,7 +107,7 @@ static errr set_baseitem_kind(nlohmann::json &baseitem_data, BaseitemInfo &basei * @param baseitem 保管先のベースアイテム情報インスタンス * @return エラーコード */ -static errr set_baseitem_parameter_value(const nlohmann::json &pval_data, BaseitemInfo &baseitem) +static errr set_baseitem_parameter_value(const nlohmann::json &pval_data, BaseitemDefinition &baseitem) { if (auto err = info_set_integer(pval_data, baseitem.pval, false, Range(-9999, 9999))) { return err; @@ -124,7 +125,7 @@ static errr set_baseitem_parameter_value(const nlohmann::json &pval_data, Baseit * @param baseitem 保管先のベースアイテム情報インスタンス * @return エラーコード */ -static errr set_baseitem_allocations(nlohmann::json &allocations_data, BaseitemInfo &baseitem) +static errr set_baseitem_allocations(nlohmann::json &allocations_data, BaseitemDefinition &baseitem) { if (allocations_data.is_null()) { return PARSE_ERROR_NONE; @@ -153,7 +154,7 @@ static errr set_baseitem_allocations(nlohmann::json &allocations_data, BaseitemI * @param baseitem 保管先のベースアイテム情報インスタンス * @return エラーコード */ -static errr set_baseitem_activate(const nlohmann::json &act_data, BaseitemInfo &baseitem) +static errr set_baseitem_activate(const nlohmann::json &act_data, BaseitemDefinition &baseitem) { if (!act_data.is_string()) { return PARSE_ERROR_NONE; @@ -175,7 +176,7 @@ static errr set_baseitem_activate(const nlohmann::json &act_data, BaseitemInfo & * @param baseitem 保管先のベースアイテム情報インスタンス * @return エラーコード */ -static errr set_baseitem_flags(const nlohmann::json &flag_data, BaseitemInfo &baseitem) +static errr set_baseitem_flags(const nlohmann::json &flag_data, BaseitemDefinition &baseitem) { if (flag_data.is_null()) { return PARSE_ERROR_NONE; diff --git a/src/info-reader/general-parser.cpp b/src/info-reader/general-parser.cpp index 2a0342e077..c172bfbc7b 100644 --- a/src/info-reader/general-parser.cpp +++ b/src/info-reader/general-parser.cpp @@ -12,7 +12,8 @@ #include "player-info/race-types.h" #include "realm/realm-types.h" #include "system/artifact-type-definition.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/building-type-definition.h" #include "system/floor-type-definition.h" #include "system/system-variables.h" diff --git a/src/inventory/recharge-processor.cpp b/src/inventory/recharge-processor.cpp index dd7ac060b4..0f451c16ed 100644 --- a/src/inventory/recharge-processor.cpp +++ b/src/inventory/recharge-processor.cpp @@ -6,7 +6,6 @@ #include "hpmp/hp-mp-regenerator.h" #include "inventory/inventory-slot-types.h" #include "object/tval-types.h" -#include "system/baseitem-info.h" #include "system/floor-type-definition.h" #include "system/item-entity.h" #include "system/player-type-definition.h" @@ -84,28 +83,30 @@ void recharge_magic_items(PlayerType *player_ptr) */ for (changed = false, i = 0; i < INVEN_PACK; i++) { auto &item = player_ptr->inventory_list[i]; - const auto &baseitem = item.get_baseitem(); if (!item.is_valid()) { continue; } - if ((item.bi_key.tval() == ItemKindType::ROD) && (item.timeout)) { - TIME_EFFECT temp = (item.timeout + (baseitem.pval - 1)) / baseitem.pval; - if (temp > item.number) { - temp = (TIME_EFFECT)item.number; - } + if ((item.bi_key.tval() != ItemKindType::ROD) || (item.timeout == 0)) { + continue; + } - item.timeout -= temp; - if (item.timeout < 0) { - item.timeout = 0; - } + const auto base_pval = item.get_baseitem_pval(); + short temp = (item.timeout + (base_pval - 1)) / base_pval; + if (temp > item.number) { + temp = static_cast(item.number); + } - if (!(item.timeout)) { - recharged_notice(player_ptr, item); - changed = true; - } else if (item.timeout % baseitem.pval) { - changed = true; - } + item.timeout -= temp; + if (item.timeout < 0) { + item.timeout = 0; + } + + if (!(item.timeout)) { + recharged_notice(player_ptr, item); + changed = true; + } else if (item.timeout % base_pval) { + changed = true; } } diff --git a/src/io-dump/special-class-dump.cpp b/src/io-dump/special-class-dump.cpp index 8e19f954eb..5af1cca9c7 100644 --- a/src/io-dump/special-class-dump.cpp +++ b/src/io-dump/special-class-dump.cpp @@ -10,11 +10,13 @@ #include "mind/mind-blue-mage.h" #include "monster-race/race-ability-flags.h" #include "mspell/monster-power-table.h" +#include "object/tval-types.h" #include "player-base/player-class.h" #include "player-info/bluemage-data-type.h" #include "player-info/magic-eater-data-type.h" #include "smith/object-smith.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/player-type-definition.h" #include "util/enum-converter.h" #include "util/flag-group.h" diff --git a/src/io/interpret-pref-file.cpp b/src/io/interpret-pref-file.cpp index ce81c0c5eb..946ad8066c 100644 --- a/src/io/interpret-pref-file.cpp +++ b/src/io/interpret-pref-file.cpp @@ -13,7 +13,8 @@ #include "io/gf-descriptions.h" #include "io/input-key-requester.h" #include "io/tokenizer.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/enums/game-option-page.h" #include "system/monster-race-info.h" #include "system/player-type-definition.h" diff --git a/src/item-info/flavor-initializer.cpp b/src/item-info/flavor-initializer.cpp index f63b81088c..af75e99a8e 100644 --- a/src/item-info/flavor-initializer.cpp +++ b/src/item-info/flavor-initializer.cpp @@ -7,7 +7,8 @@ #include "item-info/flavor-initializer.h" #include "object/tval-types.h" #include "system/angband-system.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" /*! * @brief ゲーム開始時に行われるベースアイテムの初期化ルーチン @@ -35,7 +36,7 @@ void initialize_items_flavor() } if (!baseitem.flavor) { - baseitem.mark_as_aware(); + baseitem.mark_awareness(true); } baseitem.decide_easy_know(); diff --git a/src/knowledge/knowledge-experiences.cpp b/src/knowledge/knowledge-experiences.cpp index 521a3651a4..78b74b0ebc 100644 --- a/src/knowledge/knowledge-experiences.cpp +++ b/src/knowledge/knowledge-experiences.cpp @@ -16,7 +16,8 @@ #include "spell/spells-execution.h" #include "spell/technic-info-table.h" #include "sv-definition/sv-bow-types.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/player-type-definition.h" #include "util/angband-files.h" diff --git a/src/knowledge/knowledge-items.cpp b/src/knowledge/knowledge-items.cpp index 81902d5c91..efceb28cbb 100644 --- a/src/knowledge/knowledge-items.cpp +++ b/src/knowledge/knowledge-items.cpp @@ -19,6 +19,8 @@ #include "perception/identification.h" #include "perception/object-perception.h" #include "system/artifact-type-definition.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/floor-type-definition.h" #include "system/grid-type-definition.h" #include "system/item-entity.h" @@ -120,7 +122,7 @@ void do_cmd_knowledge_artifacts(PlayerType *player_ptr) * @param baseitem ベースアイテムへの参照 * @return collect_objects() の処理を続行するか否か */ -static bool check_baseitem_chance(const BIT_FLAGS8 mode, const BaseitemInfo &baseitem) +static bool check_baseitem_chance(const BIT_FLAGS8 mode, const BaseitemDefinition &baseitem) { if (mode & 0x02) { return true; diff --git a/src/load/item/item-loader-base.cpp b/src/load/item/item-loader-base.cpp index 0452b2a0c0..8b983f0718 100644 --- a/src/load/item/item-loader-base.cpp +++ b/src/load/item/item-loader-base.cpp @@ -3,7 +3,8 @@ #include "load/angband-version-comparer.h" #include "load/load-util.h" #include "system/artifact-type-definition.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "util/bit-flags-calculator.h" #include "util/enum-converter.h" @@ -13,7 +14,7 @@ void ItemLoaderBase::load_item() { auto loading_max_k_idx = rd_u16b(); - BaseitemInfo dummy; + BaseitemDefinition dummy; auto &baseitems = BaseitemList::get_instance(); for (uint16_t i = 0; i < loading_max_k_idx; i++) { auto &baseitem = i < baseitems.size() ? baseitems.get_baseitem(i) : dummy; diff --git a/src/load/old/item-loader-savefile50.cpp b/src/load/old/item-loader-savefile50.cpp index 11266b7e6d..da606c5c06 100644 --- a/src/load/old/item-loader-savefile50.cpp +++ b/src/load/old/item-loader-savefile50.cpp @@ -11,7 +11,7 @@ #include "object/tval-types.h" #include "sv-definition/sv-lite-types.h" #include "system/angband.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "util/bit-flags-calculator.h" diff --git a/src/load/old/load-v1-5-0.cpp b/src/load/old/load-v1-5-0.cpp index d6b1ff8f50..aa90ee900f 100644 --- a/src/load/old/load-v1-5-0.cpp +++ b/src/load/old/load-v1-5-0.cpp @@ -35,7 +35,8 @@ #include "sv-definition/sv-lite-types.h" #include "system/angband-exceptions.h" #include "system/artifact-type-definition.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/dungeon-info.h" #include "system/enums/monrace/monrace-id.h" #include "system/floor-type-definition.h" diff --git a/src/main/game-data-initializer.cpp b/src/main/game-data-initializer.cpp index 1677fea3bb..77506b5ccc 100644 --- a/src/main/game-data-initializer.cpp +++ b/src/main/game-data-initializer.cpp @@ -12,7 +12,8 @@ #include "game-option/option-flags.h" #include "game-option/option-types-table.h" #include "system/alloc-entries.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/dungeon-info.h" #include "system/floor-type-definition.h" #include "system/grid-type-definition.h" diff --git a/src/main/info-initializer.cpp b/src/main/info-initializer.cpp index c7d6f8fe22..ad95cbaed2 100644 --- a/src/main/info-initializer.cpp +++ b/src/main/info-initializer.cpp @@ -28,7 +28,8 @@ #include "room/rooms-vault.h" #include "system/angband-version.h" #include "system/artifact-type-definition.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/dungeon-info.h" #include "system/monster-race-info.h" #include "system/player-type-definition.h" diff --git a/src/market/arena-entry.cpp b/src/market/arena-entry.cpp index c6e0bfd15f..2364e32a82 100644 --- a/src/market/arena-entry.cpp +++ b/src/market/arena-entry.cpp @@ -8,7 +8,7 @@ #include "sv-definition/sv-scroll-types.h" #include "sv-definition/sv-staff-types.h" #include "sv-definition/sv-wand-types.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-key.h" #include "system/enums/monrace/monrace-id.h" #include "system/monster-race-info.h" #ifndef JP diff --git a/src/market/bounty-prize-table.cpp b/src/market/bounty-prize-table.cpp index 5e16b21d1d..3a89f310dc 100644 --- a/src/market/bounty-prize-table.cpp +++ b/src/market/bounty-prize-table.cpp @@ -2,7 +2,7 @@ #include "object/tval-types.h" #include "sv-definition/sv-potion-types.h" #include "sv-definition/sv-scroll-types.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-key.h" const std::vector prize_list = { { ItemKindType::POTION, SV_POTION_CURING }, diff --git a/src/market/building-craft-fix.cpp b/src/market/building-craft-fix.cpp index 8e8ef62190..e90953903f 100644 --- a/src/market/building-craft-fix.cpp +++ b/src/market/building-craft-fix.cpp @@ -19,7 +19,8 @@ #include "spell-realm/spells-hex.h" #include "sv-definition/sv-other-types.h" #include "sv-definition/sv-weapon-types.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "system/redrawing-flags-updater.h" diff --git a/src/market/building-initializer.cpp b/src/market/building-initializer.cpp index 37d0cd4ce5..a2c8658621 100644 --- a/src/market/building-initializer.cpp +++ b/src/market/building-initializer.cpp @@ -8,7 +8,8 @@ #include "store/store-util.h" #include "store/store.h" #include "system/angband.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/building-type-definition.h" #include "system/item-entity.h" #include "util/angband-files.h" diff --git a/src/market/building-recharger.cpp b/src/market/building-recharger.cpp index 23e90d35a9..139ca07f62 100644 --- a/src/market/building-recharger.cpp +++ b/src/market/building-recharger.cpp @@ -13,7 +13,6 @@ #include "object/item-use-flags.h" #include "perception/object-perception.h" #include "spell-kind/spells-perception.h" -#include "system/baseitem-info.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "system/redrawing-flags-updater.h" @@ -63,14 +62,15 @@ void building_recharge(PlayerType *player_ptr) return; } - const auto &baseitem = o_ptr->get_baseitem(); - const auto lev = baseitem.level; + const auto item_level = o_ptr->get_baseitem_level(); const auto tval = o_ptr->bi_key.tval(); + const auto base_pval = o_ptr->get_baseitem_pval(); + const auto base_cost = o_ptr->get_baseitem_cost(); int price; switch (tval) { case ItemKindType::ROD: if (o_ptr->timeout > 0) { - price = (lev * 50 * o_ptr->timeout) / baseitem.pval; + price = (item_level * 50 * o_ptr->timeout) / base_pval; break; } @@ -78,16 +78,16 @@ void building_recharge(PlayerType *player_ptr) msg_format(_("それは再充填する必要はありません。", "That doesn't need to be recharged.")); return; case ItemKindType::STAFF: - price = (baseitem.cost / 10) * o_ptr->number; + price = (base_cost / 10) * o_ptr->number; price = std::max(10, price); break; default: - price = baseitem.cost / 10; + price = base_cost / 10; price = std::max(10, price); break; } - if ((tval == ItemKindType::WAND) && (o_ptr->pval / o_ptr->number >= baseitem.pval)) { + if ((tval == ItemKindType::WAND) && (o_ptr->pval / o_ptr->number >= base_pval)) { if (o_ptr->number > 1) { msg_print(_("この魔法棒はもう充分に充填されています。", "These wands are already fully charged.")); } else { @@ -95,7 +95,7 @@ void building_recharge(PlayerType *player_ptr) } return; - } else if ((tval == ItemKindType::STAFF) && o_ptr->pval >= baseitem.pval) { + } else if ((tval == ItemKindType::STAFF) && o_ptr->pval >= base_pval) { if (o_ptr->number > 1) { msg_print(_("この杖はもう充分に充填されています。", "These staffs are already fully charged.")); } else { @@ -130,9 +130,9 @@ void building_recharge(PlayerType *player_ptr) } else { int max_charges; if (tval == ItemKindType::STAFF) { - max_charges = baseitem.pval - o_ptr->pval; + max_charges = base_pval - o_ptr->pval; } else { - max_charges = o_ptr->number * baseitem.pval - o_ptr->pval; + max_charges = o_ptr->number * base_pval - o_ptr->pval; } const auto mes = _("一回分$%d で何回分充填しますか?", "Add how many charges for %d gold apiece? "); @@ -191,21 +191,22 @@ void building_recharge_all(PlayerType *player_ptr) total_cost += 50; } - const auto &baseitem = item.get_baseitem(); - const auto lev = baseitem.level; + const auto item_level = item.get_baseitem_level(); + const auto base_pval = item.get_baseitem_pval(); + const auto base_cost = item.get_baseitem_cost(); switch (item.bi_key.tval()) { case ItemKindType::ROD: - price = (lev * 50 * item.timeout) / baseitem.pval; + price = (item_level * 50 * item.timeout) / base_pval; break; case ItemKindType::STAFF: - price = (baseitem.cost / 10) * item.number; + price = (base_cost / 10) * item.number; price = std::max(10, price); - price = (baseitem.pval - item.pval) * price; + price = (base_pval - item.pval) * price; break; case ItemKindType::WAND: - price = (baseitem.cost / 10); + price = (base_cost / 10); price = std::max(10, price); - price = (item.number * baseitem.pval - item.pval) * price; + price = (item.number * base_pval - item.pval) * price; break; default: break; @@ -234,7 +235,6 @@ void building_recharge_all(PlayerType *player_ptr) for (short i = 0; i < INVEN_PACK; i++) { auto *o_ptr = &player_ptr->inventory_list[i]; - const auto &baseitem = o_ptr->get_baseitem(); if (!o_ptr->can_recharge()) { continue; } @@ -244,20 +244,21 @@ void building_recharge_all(PlayerType *player_ptr) autopick_alter_item(player_ptr, i, false); } + const auto base_pval = o_ptr->get_baseitem_pval(); switch (o_ptr->bi_key.tval()) { case ItemKindType::ROD: o_ptr->timeout = 0; break; case ItemKindType::STAFF: - if (o_ptr->pval < baseitem.pval) { - o_ptr->pval = baseitem.pval; + if (o_ptr->pval < base_pval) { + o_ptr->pval = base_pval; } o_ptr->ident &= ~(IDENT_EMPTY); break; case ItemKindType::WAND: - if (o_ptr->pval < o_ptr->number * baseitem.pval) { - o_ptr->pval = o_ptr->number * baseitem.pval; + if (o_ptr->pval < o_ptr->number * base_pval) { + o_ptr->pval = o_ptr->number * base_pval; } o_ptr->ident &= ~(IDENT_EMPTY); diff --git a/src/mind/mind-mage.cpp b/src/mind/mind-mage.cpp index 01bc448ea9..e00d05ce57 100644 --- a/src/mind/mind-mage.cpp +++ b/src/mind/mind-mage.cpp @@ -15,7 +15,6 @@ #include "object/item-tester-hooker.h" #include "object/item-use-flags.h" #include "player-base/player-class.h" -#include "system/baseitem-info.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "view/display-messages.h" @@ -37,25 +36,25 @@ bool eat_magic(PlayerType *player_ptr, int power) return false; } - const auto &baseitem = o_ptr->get_baseitem(); - const auto lev = baseitem.level; + const auto base_pval = o_ptr->get_baseitem_pval(); + const auto item_level = o_ptr->get_baseitem_level(); const auto tval = o_ptr->bi_key.tval(); auto recharge_strength = 0; auto is_eating_successful = true; if (tval == ItemKindType::ROD) { - recharge_strength = ((power > lev / 2) ? (power - lev / 2) : 0) / 5; + recharge_strength = ((power > item_level / 2) ? (power - item_level / 2) : 0) / 5; if (one_in_(recharge_strength)) { is_eating_successful = false; } else { - if (o_ptr->timeout > (o_ptr->number - 1) * baseitem.pval) { + if (o_ptr->timeout > (o_ptr->number - 1) * base_pval) { msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod.")); } else { - player_ptr->csp += lev; - o_ptr->timeout += baseitem.pval; + player_ptr->csp += item_level; + o_ptr->timeout += base_pval; } } } else { - recharge_strength = (100 + power - lev) / 15; + recharge_strength = (100 + power - item_level) / 15; if (recharge_strength < 0) { recharge_strength = 0; } @@ -64,7 +63,7 @@ bool eat_magic(PlayerType *player_ptr, int power) is_eating_successful = false; } else { if (o_ptr->pval > 0) { - player_ptr->csp += lev / 2; + player_ptr->csp += item_level / 2; o_ptr->pval--; if ((tval == ItemKindType::STAFF) && (i_idx >= 0) && (o_ptr->number > 1)) { @@ -98,7 +97,7 @@ bool eat_magic(PlayerType *player_ptr, int power) const auto item_name = describe_flavor(player_ptr, *o_ptr, OD_NAME_ONLY); msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), item_name.data()); if (tval == ItemKindType::ROD) { - o_ptr->timeout = baseitem.pval * o_ptr->number; + o_ptr->timeout = base_pval * o_ptr->number; } else if (o_ptr->is_wand_staff()) { o_ptr->pval = 0; } @@ -163,7 +162,7 @@ bool eat_magic(PlayerType *player_ptr, int power) if (fail_type == 1) { if (tval == ItemKindType::ROD) { msg_print(_("ロッドは破損を免れたが、魔力は全て失なわれた。", "You save your rod from destruction, but all charges are lost.")); - o_ptr->timeout = baseitem.pval * o_ptr->number; + o_ptr->timeout = base_pval * o_ptr->number; } else if (tval == ItemKindType::WAND) { constexpr auto mes = _("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."); msg_format(mes, item_name.data()); @@ -176,7 +175,7 @@ bool eat_magic(PlayerType *player_ptr, int power) msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), item_name.data()); /* Reduce rod stack maximum timeout, drain wands. */ if (tval == ItemKindType::ROD) { - o_ptr->timeout = std::min(o_ptr->timeout, baseitem.pval * (o_ptr->number - 1)); + o_ptr->timeout = std::min(o_ptr->timeout, base_pval * (o_ptr->number - 1)); } else if (tval == ItemKindType::WAND) { o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number; } diff --git a/src/monster-attack/monster-eating.cpp b/src/monster-attack/monster-eating.cpp index 50629617dc..fa66b4fe11 100644 --- a/src/monster-attack/monster-eating.cpp +++ b/src/monster-attack/monster-eating.cpp @@ -22,7 +22,6 @@ #include "player/player-status-flags.h" #include "player/player-status-table.h" #include "status/experience.h" -#include "system/baseitem-info.h" #include "system/floor-type-definition.h" #include "system/item-entity.h" #include "system/monster-entity.h" @@ -227,10 +226,9 @@ bool process_un_power(PlayerType *player_ptr, MonsterAttackPlayer *monap_ptr) } const auto is_magic_mastery = has_magic_mastery(player_ptr) != 0; - const auto &baseitem = monap_ptr->o_ptr->get_baseitem(); - const auto pval = baseitem.pval; + const auto base_pval = monap_ptr->o_ptr->get_baseitem_pval(); const auto level = monap_ptr->rlev; - auto drain = is_magic_mastery ? std::min(pval, pval * level / 400 + pval * randint1(level) / 400) : pval; + auto drain = is_magic_mastery ? std::min(base_pval, base_pval * level / 400 + base_pval * randint1(level) / 400) : base_pval; drain = std::min(drain, monap_ptr->o_ptr->pval); if (drain <= 0) { return false; @@ -242,7 +240,7 @@ bool process_un_power(PlayerType *player_ptr, MonsterAttackPlayer *monap_ptr) } monap_ptr->obvious = true; - auto recovery = drain * baseitem.level; + auto recovery = drain * monap_ptr->o_ptr->get_baseitem_level(); const auto tval = monap_ptr->o_ptr->bi_key.tval(); if (tval == ItemKindType::STAFF) { recovery *= monap_ptr->o_ptr->number; diff --git a/src/monster-floor/monster-death.cpp b/src/monster-floor/monster-death.cpp index 4da3bc0cd0..501ec12983 100644 --- a/src/monster-floor/monster-death.cpp +++ b/src/monster-floor/monster-death.cpp @@ -30,6 +30,8 @@ #include "sv-definition/sv-scroll-types.h" #include "system/angband-system.h" #include "system/artifact-type-definition.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/building-type-definition.h" #include "system/dungeon-info.h" #include "system/enums/monrace/monrace-id.h" diff --git a/src/object-activation/activation-util.cpp b/src/object-activation/activation-util.cpp index febe74fb39..480705b0d9 100644 --- a/src/object-activation/activation-util.cpp +++ b/src/object-activation/activation-util.cpp @@ -1,12 +1,11 @@ #include "object-activation/activation-util.h" #include "object/object-info.h" -#include "system/baseitem-info.h" #include "system/item-entity.h" #include "system/player-type-definition.h" ae_type *initialize_ae_type(PlayerType *player_ptr, ae_type *ae_ptr, const INVENTORY_IDX i_idx) { ae_ptr->o_ptr = ref_item(player_ptr, i_idx); - ae_ptr->lev = ae_ptr->o_ptr->get_baseitem().level; + ae_ptr->lev = ae_ptr->o_ptr->get_baseitem_level(); return ae_ptr; } diff --git a/src/object-enchant/item-magic-applier.cpp b/src/object-enchant/item-magic-applier.cpp index e01a208917..fbb0c11929 100644 --- a/src/object-enchant/item-magic-applier.cpp +++ b/src/object-enchant/item-magic-applier.cpp @@ -13,7 +13,7 @@ #include "object-enchant/special-object-flags.h" #include "player/player-status-flags.h" #include "system/artifact-type-definition.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" #include "system/dungeon-info.h" #include "system/floor-type-definition.h" #include "system/item-entity.h" @@ -204,11 +204,11 @@ void ItemMagicApplier::apply_cursed() return; } - const auto &baseitem = this->o_ptr->get_baseitem(); - if (!baseitem.cost) { + if (this->o_ptr->is_worthless()) { set_bits(this->o_ptr->ident, IDENT_BROKEN); } + const auto &baseitem = this->o_ptr->get_baseitem(); if (baseitem.gen_flags.has(ItemGenerationTraitType::CURSED)) { this->o_ptr->curse_flags.set(CurseTraitType::CURSED); } diff --git a/src/object-enchant/object-boost.cpp b/src/object-enchant/object-boost.cpp index 0d20a2f112..1ac723a86c 100644 --- a/src/object-enchant/object-boost.cpp +++ b/src/object-enchant/object-boost.cpp @@ -2,7 +2,7 @@ #include "artifact/random-art-effects.h" #include "object-enchant/tr-types.h" #include "player-ability/player-ability-types.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" #include "system/floor-type-definition.h" #include "system/item-entity.h" #include "util/bit-flags-calculator.h" diff --git a/src/object-enchant/others/apply-magic-amulet.cpp b/src/object-enchant/others/apply-magic-amulet.cpp index 7208ae22c3..0b0eda3a89 100644 --- a/src/object-enchant/others/apply-magic-amulet.cpp +++ b/src/object-enchant/others/apply-magic-amulet.cpp @@ -11,7 +11,7 @@ #include "object-enchant/special-object-flags.h" #include "object-enchant/trc-types.h" #include "sv-definition/sv-amulet-types.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "util/bit-flags-calculator.h" diff --git a/src/object-enchant/others/apply-magic-others.cpp b/src/object-enchant/others/apply-magic-others.cpp index 4428ec53c0..acd795e20d 100644 --- a/src/object-enchant/others/apply-magic-others.cpp +++ b/src/object-enchant/others/apply-magic-others.cpp @@ -20,7 +20,6 @@ #include "perception/object-perception.h" #include "sv-definition/sv-lite-types.h" #include "sv-definition/sv-other-types.h" -#include "system/baseitem-info.h" #include "system/enums/monrace/monrace-id.h" #include "system/floor-type-definition.h" #include "system/item-entity.h" @@ -60,7 +59,7 @@ void OtherItemsEnchanter::apply_magic() this->enchant_wand_staff(); break; case ItemKindType::ROD: - this->o_ptr->pval = this->o_ptr->get_baseitem().pval; + this->o_ptr->pval = this->o_ptr->get_baseitem_pval(); break; case ItemKindType::CAPTURE: this->o_ptr->pval = 0; @@ -91,8 +90,8 @@ void OtherItemsEnchanter::apply_magic() */ void OtherItemsEnchanter::enchant_wand_staff() { - const auto &baseitem = this->o_ptr->get_baseitem(); - this->o_ptr->pval = baseitem.pval / 2 + randint1((baseitem.pval + 1) / 2); + const auto base_pval = this->o_ptr->get_baseitem_pval(); + this->o_ptr->pval = base_pval / 2 + randint1((base_pval + 1) / 2); } /* @@ -198,12 +197,12 @@ void OtherItemsEnchanter::generate_statue() */ void OtherItemsEnchanter::generate_chest() { - auto obj_level = this->o_ptr->get_baseitem().level; - if (obj_level <= 0) { + const auto item_level = this->o_ptr->get_baseitem_level(); + if (item_level <= 0) { return; } - this->o_ptr->pval = randnum1(obj_level); + this->o_ptr->pval = randnum1(item_level); if (this->o_ptr->bi_key.sval() == SV_CHEST_KANDUME) { this->o_ptr->pval = 6; } diff --git a/src/object-enchant/others/apply-magic-ring.cpp b/src/object-enchant/others/apply-magic-ring.cpp index 1d0718081e..7e2f6f7583 100644 --- a/src/object-enchant/others/apply-magic-ring.cpp +++ b/src/object-enchant/others/apply-magic-ring.cpp @@ -11,7 +11,7 @@ #include "object-enchant/special-object-flags.h" #include "object-enchant/trc-types.h" #include "sv-definition/sv-ring-types.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "util/bit-flags-calculator.h" diff --git a/src/object-enchant/protector/apply-magic-soft-armor.cpp b/src/object-enchant/protector/apply-magic-soft-armor.cpp index 2704563387..ae0940583b 100644 --- a/src/object-enchant/protector/apply-magic-soft-armor.cpp +++ b/src/object-enchant/protector/apply-magic-soft-armor.cpp @@ -7,7 +7,8 @@ #include "object-enchant/protector/apply-magic-soft-armor.h" #include "object/tval-types.h" #include "sv-definition/sv-armor-types.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/item-entity.h" #include "system/player-type-definition.h" diff --git a/src/object-hook/hook-expendable.cpp b/src/object-hook/hook-expendable.cpp index 78707525f7..3bbb88a30c 100644 --- a/src/object-hook/hook-expendable.cpp +++ b/src/object-hook/hook-expendable.cpp @@ -9,7 +9,7 @@ #include "player-info/mimic-info-table.h" #include "sv-definition/sv-lite-types.h" #include "sv-definition/sv-other-types.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-key.h" #include "system/item-entity.h" #include "system/monster-race-info.h" #include "system/player-type-definition.h" diff --git a/src/object-hook/hook-magic.cpp b/src/object-hook/hook-magic.cpp index ce257cf245..e04b3c2d94 100644 --- a/src/object-hook/hook-magic.cpp +++ b/src/object-hook/hook-magic.cpp @@ -5,7 +5,7 @@ #include "player-base/player-class.h" #include "player-info/class-info.h" #include "player/player-realm.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-key.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "util/bit-flags-calculator.h" diff --git a/src/object-use/quaff/quaff-execution.cpp b/src/object-use/quaff/quaff-execution.cpp index 3c4e2865f4..c52e684929 100644 --- a/src/object-use/quaff/quaff-execution.cpp +++ b/src/object-use/quaff/quaff-execution.cpp @@ -23,7 +23,6 @@ #include "spell-realm/spells-hex.h" #include "spell-realm/spells-song.h" #include "status/experience.h" -#include "system/baseitem-info.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "system/redrawing-flags-updater.h" @@ -71,7 +70,7 @@ void ObjectQuaffEntity::execute(INVENTORY_IDX i_idx) item.mark_as_tried(); if (ident && !item.is_aware()) { object_aware(this->player_ptr, &item); - gain_exp(this->player_ptr, (item.get_baseitem().level + (this->player_ptr->lev >> 1)) / this->player_ptr->lev); + gain_exp(this->player_ptr, (item.get_baseitem_level() + (this->player_ptr->lev >> 1)) / this->player_ptr->lev); } static constexpr auto flags = { @@ -124,7 +123,7 @@ bool ObjectQuaffEntity::can_quaff() ItemEntity ObjectQuaffEntity::copy_object(const INVENTORY_IDX i_idx) { auto *tmp_o_ptr = ref_item(this->player_ptr, i_idx); - auto o_val = *tmp_o_ptr; + ItemEntity o_val = *tmp_o_ptr; o_val.number = 1; return o_val; } diff --git a/src/object-use/read/read-execution.cpp b/src/object-use/read/read-execution.cpp index 8ff4fdd03f..c16f985435 100644 --- a/src/object-use/read/read-execution.cpp +++ b/src/object-use/read/read-execution.cpp @@ -20,7 +20,6 @@ #include "spell-realm/spells-hex.h" #include "spell-realm/spells-song.h" #include "status/experience.h" -#include "system/baseitem-info.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "system/redrawing-flags-updater.h" @@ -119,6 +118,6 @@ void ObjectReadEntity::gain_exp_from_item_use(ItemEntity *o_ptr, bool is_identif } object_aware(this->player_ptr, o_ptr); - auto lev = o_ptr->get_baseitem().level; - gain_exp(this->player_ptr, (lev + (this->player_ptr->lev >> 1)) / this->player_ptr->lev); + const auto item_level = o_ptr->get_baseitem_level(); + gain_exp(this->player_ptr, (item_level + (this->player_ptr->lev >> 1)) / this->player_ptr->lev); } diff --git a/src/object-use/throw-execution.cpp b/src/object-use/throw-execution.cpp index cca0fec99d..b2353daea8 100644 --- a/src/object-use/throw-execution.cpp +++ b/src/object-use/throw-execution.cpp @@ -51,7 +51,6 @@ #include "player/player-status-table.h" #include "racial/racial-android.h" #include "specific-object/torch.h" -#include "system/baseitem-info.h" #include "system/floor-type-definition.h" #include "system/grid-type-definition.h" #include "system/item-entity.h" @@ -66,6 +65,7 @@ #include "util/bit-flags-calculator.h" #include "util/string-processor.h" #include "view/display-messages.h" +#include "view/display-symbol.h" #include "view/object-describer.h" #include "wizard/wizard-messages.h" diff --git a/src/object-use/use-execution.cpp b/src/object-use/use-execution.cpp index 5fdb0d2a18..4e5b5add84 100644 --- a/src/object-use/use-execution.cpp +++ b/src/object-use/use-execution.cpp @@ -20,7 +20,6 @@ #include "player-base/player-class.h" #include "player-status/player-energy.h" #include "status/experience.h" -#include "system/baseitem-info.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "system/redrawing-flags-updater.h" @@ -58,9 +57,9 @@ void ObjectUseEntity::execute() return; } - auto lev = o_ptr->get_baseitem().level; - if (lev > 50) { - lev = 50 + (lev - 50) / 2; + auto item_level = o_ptr->get_baseitem_level(); + if (item_level > 50) { + item_level = 50 + (item_level - 50) / 2; } auto chance = this->player_ptr->skill_dev; @@ -68,7 +67,7 @@ void ObjectUseEntity::execute() chance = chance / 2; } - chance = chance - lev; + chance = chance - item_level; if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1)) { chance = USE_DEVICE; } @@ -119,7 +118,7 @@ void ObjectUseEntity::execute() o_ptr->mark_as_tried(); if (ident && !o_ptr->is_aware()) { object_aware(this->player_ptr, o_ptr); - gain_exp(this->player_ptr, (lev + (this->player_ptr->lev >> 1)) / this->player_ptr->lev); + gain_exp(this->player_ptr, (item_level + (this->player_ptr->lev >> 1)) / this->player_ptr->lev); } static constexpr auto flags_swrf = { diff --git a/src/object-use/zaprod-execution.cpp b/src/object-use/zaprod-execution.cpp index 8c0b07ec81..c26644c8cd 100644 --- a/src/object-use/zaprod-execution.cpp +++ b/src/object-use/zaprod-execution.cpp @@ -19,7 +19,6 @@ #include "status/experience.h" #include "sv-definition/sv-other-types.h" #include "sv-definition/sv-rod-types.h" -#include "system/baseitem-info.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "system/redrawing-flags-updater.h" @@ -63,13 +62,13 @@ void ObjectZapRodEntity::execute(INVENTORY_IDX i_idx) return; } - auto lev = o_ptr->get_baseitem().level; + const auto item_level = o_ptr->get_baseitem_level(); auto chance = this->player_ptr->skill_dev; if (this->player_ptr->effects()->confusion().is_confused()) { chance = chance / 2; } - auto fail = lev + 5; + auto fail = item_level + 5; if (chance > fail) { fail -= (chance - fail) * 2; } else { @@ -103,7 +102,7 @@ void ObjectZapRodEntity::execute(INVENTORY_IDX i_idx) return; } - const auto &baseitem = o_ptr->get_baseitem(); + const auto base_pval = o_ptr->get_baseitem_pval(); if ((o_ptr->number == 1) && (o_ptr->timeout)) { if (flush_failure) { flush(); @@ -111,7 +110,7 @@ void ObjectZapRodEntity::execute(INVENTORY_IDX i_idx) msg_print(_("このロッドはまだ魔力を充填している最中だ。", "The rod is still charging.")); return; - } else if ((o_ptr->number > 1) && (o_ptr->timeout > baseitem.pval * (o_ptr->number - 1))) { + } else if ((o_ptr->number > 1) && (o_ptr->timeout > base_pval * (o_ptr->number - 1))) { if (flush_failure) { flush(); } @@ -123,7 +122,7 @@ void ObjectZapRodEntity::execute(INVENTORY_IDX i_idx) sound(SOUND_ZAP); auto ident = rod_effect(this->player_ptr, *o_ptr->bi_key.sval(), dir, &use_charge, false); if (use_charge) { - o_ptr->timeout += baseitem.pval; + o_ptr->timeout += base_pval; } auto &rfu = RedrawingFlagsUpdater::get_instance(); @@ -141,7 +140,7 @@ void ObjectZapRodEntity::execute(INVENTORY_IDX i_idx) o_ptr->mark_as_tried(); if ((ident != 0) && !o_ptr->is_aware()) { object_aware(this->player_ptr, o_ptr); - gain_exp(this->player_ptr, (lev + (this->player_ptr->lev >> 1)) / this->player_ptr->lev); + gain_exp(this->player_ptr, (item_level + (this->player_ptr->lev >> 1)) / this->player_ptr->lev); } static constexpr auto flags_swrf = { diff --git a/src/object-use/zapwand-execution.cpp b/src/object-use/zapwand-execution.cpp index f9680dd714..47b8a2b611 100644 --- a/src/object-use/zapwand-execution.cpp +++ b/src/object-use/zapwand-execution.cpp @@ -16,7 +16,6 @@ #include "player-status/player-energy.h" #include "status/experience.h" #include "sv-definition/sv-wand-types.h" -#include "system/baseitem-info.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "system/redrawing-flags-updater.h" @@ -62,9 +61,9 @@ void ObjectZapWandEntity::execute(INVENTORY_IDX i_idx) return; } - auto lev = o_ptr->get_baseitem().level; - if (lev > 50) { - lev = 50 + (lev - 50) / 2; + auto item_level = o_ptr->get_baseitem_level(); + if (item_level > 50) { + item_level = 50 + (item_level - 50) / 2; } auto chance = this->player_ptr->skill_dev; @@ -72,7 +71,7 @@ void ObjectZapWandEntity::execute(INVENTORY_IDX i_idx) chance = chance / 2; } - chance = chance - lev; + chance = chance - item_level; if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1)) { chance = USE_DEVICE; } @@ -122,7 +121,7 @@ void ObjectZapWandEntity::execute(INVENTORY_IDX i_idx) o_ptr->mark_as_tried(); if (ident && !o_ptr->is_aware()) { object_aware(this->player_ptr, o_ptr); - gain_exp(this->player_ptr, (lev + (this->player_ptr->lev >> 1)) / this->player_ptr->lev); + gain_exp(this->player_ptr, (item_level + (this->player_ptr->lev >> 1)) / this->player_ptr->lev); } static constexpr auto flags_swrf = { diff --git a/src/object/object-broken.cpp b/src/object/object-broken.cpp index 6309173cae..17870f21ce 100644 --- a/src/object/object-broken.cpp +++ b/src/object/object-broken.cpp @@ -11,7 +11,8 @@ #include "object-enchant/tr-types.h" #include "object/tval-types.h" #include "sv-definition/sv-potion-types.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "util/bit-flags-calculator.h" diff --git a/src/object/object-kind-hook.cpp b/src/object/object-kind-hook.cpp index c8179601fe..8f9b1b9fa3 100644 --- a/src/object/object-kind-hook.cpp +++ b/src/object/object-kind-hook.cpp @@ -9,7 +9,8 @@ #include "sv-definition/sv-amulet-types.h" #include "sv-definition/sv-other-types.h" #include "sv-definition/sv-ring-types.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include #include #include diff --git a/src/object/object-stack.cpp b/src/object/object-stack.cpp index 00a35ed4a9..04cbf10bb7 100644 --- a/src/object/object-stack.cpp +++ b/src/object/object-stack.cpp @@ -13,7 +13,6 @@ #include "object/tval-types.h" #include "smith/object-smith.h" #include "sv-definition/sv-other-types.h" -#include "system/baseitem-info.h" #include "system/item-entity.h" #include "util/bit-flags-calculator.h" diff --git a/src/object/object-value-calc.cpp b/src/object/object-value-calc.cpp index 2ebf454083..32da1846ee 100644 --- a/src/object/object-value-calc.cpp +++ b/src/object/object-value-calc.cpp @@ -4,7 +4,7 @@ #include "object-enchant/tr-types.h" #include "object-enchant/trc-types.h" #include "system/artifact-type-definition.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "util/bit-flags-calculator.h" diff --git a/src/object/object-value.cpp b/src/object/object-value.cpp index 0ccdce4709..3a89684769 100644 --- a/src/object/object-value.cpp +++ b/src/object/object-value.cpp @@ -2,7 +2,7 @@ #include "object/object-value-calc.h" #include "object/tval-types.h" #include "system/artifact-type-definition.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" #include "system/item-entity.h" #include "system/monster-race-info.h" #include "system/player-type-definition.h" @@ -35,13 +35,11 @@ */ PRICE object_value_real(const ItemEntity *o_ptr) { - const auto &baseitem = o_ptr->get_baseitem(); - - if (!baseitem.cost) { + if (o_ptr->is_worthless()) { return 0; } - PRICE value = baseitem.cost; + auto value = o_ptr->get_baseitem_cost(); const auto flags = o_ptr->get_flags(); if (o_ptr->is_fixed_artifact()) { const auto &artifact = o_ptr->get_fixed_artifact(); @@ -67,6 +65,7 @@ PRICE object_value_real(const ItemEntity *o_ptr) } /* Analyze pval bonus for normal object */ + const auto &baseitem = o_ptr->get_baseitem(); switch (o_ptr->bi_key.tval()) { case ItemKindType::SHOT: case ItemKindType::ARROW: @@ -140,19 +139,20 @@ PRICE object_value_real(const ItemEntity *o_ptr) break; } + const auto base_pval = o_ptr->get_baseitem_pval(); switch (o_ptr->bi_key.tval()) { case ItemKindType::WAND: { /* Pay extra for charges, depending on standard number of * charges. Handle new-style wands correctly. -LM- */ - value += (value * o_ptr->pval / o_ptr->number / (baseitem.pval * 2)); + value += (value * o_ptr->pval / o_ptr->number / (base_pval * 2)); break; } case ItemKindType::STAFF: { /* Pay extra for charges, depending on standard number of * charges. -LM- */ - value += (value * o_ptr->pval / (baseitem.pval * 2)); + value += (value * o_ptr->pval / (base_pval * 2)); break; } case ItemKindType::RING: diff --git a/src/perception/identification.cpp b/src/perception/identification.cpp index d2c45daace..985c055259 100644 --- a/src/perception/identification.cpp +++ b/src/perception/identification.cpp @@ -14,7 +14,7 @@ #include "sv-definition/sv-ring-types.h" #include "sv-definition/sv-weapon-types.h" #include "system/artifact-type-definition.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" #include "system/enums/monrace/monrace-id.h" #include "system/item-entity.h" #include "system/monster-race-info.h" diff --git a/src/perception/object-perception.cpp b/src/perception/object-perception.cpp index 9e268eee82..dd52a7bafd 100644 --- a/src/perception/object-perception.cpp +++ b/src/perception/object-perception.cpp @@ -3,6 +3,7 @@ #include "flavor/object-flavor-types.h" #include "game-option/play-record-options.h" #include "io/write-diary.h" +#include "system/baseitem/baseitem-definition.h" #include "system/item-entity.h" #include "system/player-type-definition.h" @@ -16,7 +17,7 @@ void object_aware(PlayerType *player_ptr, const ItemEntity *o_ptr) { const bool is_already_awared = o_ptr->is_aware(); auto &baseitem = o_ptr->get_baseitem(); - baseitem.mark_as_aware(); + baseitem.mark_awareness(true); // 以下、playrecordに記録しない場合はreturnする if (!record_ident) { diff --git a/src/player-info/magic-eater-data-type.cpp b/src/player-info/magic-eater-data-type.cpp index e8881901e6..a943231f6f 100644 --- a/src/player-info/magic-eater-data-type.cpp +++ b/src/player-info/magic-eater-data-type.cpp @@ -3,7 +3,8 @@ #include "sv-definition/sv-rod-types.h" #include "sv-definition/sv-staff-types.h" #include "sv-definition/sv-wand-types.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" MagicEaterDataList::MagicEaterDataList() : staves(SV_STAFF_MAX) diff --git a/src/player/player-move.cpp b/src/player/player-move.cpp index 6aa0ed8ce3..2f669ebaf3 100644 --- a/src/player/player-move.cpp +++ b/src/player/player-move.cpp @@ -73,7 +73,7 @@ static void discover_hidden_things(PlayerType *player_ptr, const Pos2D &pos) disturb(player_ptr, false, true); } - if (is_hidden_door(player_ptr, grid)) { + if (grid.is_hidden_door()) { msg_print(_("隠しドアを発見した。", "You have found a secret door.")); disclose_grid(player_ptr, pos.y, pos.x); disturb(player_ptr, false, false); diff --git a/src/racial/racial-android.cpp b/src/racial/racial-android.cpp index a792def6cb..84fe4c1782 100644 --- a/src/racial/racial-android.cpp +++ b/src/racial/racial-android.cpp @@ -15,7 +15,6 @@ #include "sv-definition/sv-protector-types.h" #include "sv-definition/sv-weapon-types.h" #include "system/artifact-type-definition.h" -#include "system/baseitem-info.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "target/target-getter.h" @@ -69,7 +68,7 @@ void calc_android_exp(PlayerType *player_ptr) ItemEntity forge; auto *q_ptr = &forge; uint32_t value, exp; - DEPTH level = std::max(o_ptr->get_baseitem().level - 8, 1); + DEPTH level = std::max(o_ptr->get_baseitem_level() - 8, 1); if ((i == INVEN_MAIN_RING) || (i == INVEN_SUB_RING) || (i == INVEN_NECK) || (i == INVEN_LITE)) { continue; diff --git a/src/save/item-writer.cpp b/src/save/item-writer.cpp index 3aee2a2d89..75b0a10656 100644 --- a/src/save/item-writer.cpp +++ b/src/save/item-writer.cpp @@ -2,7 +2,8 @@ #include "artifact/random-art-effects.h" #include "load/old/item-flag-types-savefile50.h" #include "save/save-util.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/item-entity.h" #include "util/bit-flags-calculator.h" #include "util/enum-converter.h" diff --git a/src/save/save.cpp b/src/save/save.cpp index 68605711a8..8618abb904 100644 --- a/src/save/save.cpp +++ b/src/save/save.cpp @@ -33,7 +33,8 @@ #include "store/store-util.h" #include "system/angband-system.h" #include "system/artifact-type-definition.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/floor-type-definition.h" #include "system/item-entity.h" #include "system/monster-race-info.h" diff --git a/src/spell-kind/magic-item-recharger.cpp b/src/spell-kind/magic-item-recharger.cpp index ad109bc51b..cf9e163579 100644 --- a/src/spell-kind/magic-item-recharger.cpp +++ b/src/spell-kind/magic-item-recharger.cpp @@ -22,7 +22,6 @@ #include "object/item-use-flags.h" #include "player-base/player-class.h" #include "system/angband-exceptions.h" -#include "system/baseitem-info.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "view/display-messages.h" @@ -59,15 +58,14 @@ bool recharge(PlayerType *player_ptr, int power) return false; } - const auto &baseitem = o_ptr->get_baseitem(); - const auto lev = baseitem.level; + const auto item_level = o_ptr->get_baseitem_level(); TIME_EFFECT recharge_amount; int recharge_strength; auto is_recharge_successful = true; const auto tval = o_ptr->bi_key.tval(); if (tval == ItemKindType::ROD) { - recharge_strength = ((power > lev / 2) ? (power - lev / 2) : 0) / 5; + recharge_strength = ((power > item_level / 2) ? (power - item_level / 2) : 0) / 5; if (one_in_(recharge_strength)) { is_recharge_successful = false; } else { @@ -80,9 +78,9 @@ bool recharge(PlayerType *player_ptr, int power) } } else { if ((tval == ItemKindType::WAND) && (o_ptr->number > 1)) { - recharge_strength = (100 + power - lev - (8 * o_ptr->pval / o_ptr->number)) / 15; + recharge_strength = (100 + power - item_level - (8 * o_ptr->pval / o_ptr->number)) / 15; } else { - recharge_strength = (100 + power - lev - (8 * o_ptr->pval)) / 15; + recharge_strength = (100 + power - item_level - (8 * o_ptr->pval)) / 15; } if (recharge_strength < 0) { @@ -92,7 +90,7 @@ bool recharge(PlayerType *player_ptr, int power) if (one_in_(recharge_strength)) { is_recharge_successful = false; } else { - recharge_amount = randnum1(1 + baseitem.pval / 2); + recharge_amount = randnum1(1 + o_ptr->get_baseitem_pval() / 2); if ((tval == ItemKindType::WAND) && (o_ptr->number > 1)) { recharge_amount += (randint1(recharge_amount * (o_ptr->number - 1))) / 2; if (recharge_amount < 1) { @@ -205,7 +203,7 @@ bool recharge(PlayerType *player_ptr, int power) } if (tval == ItemKindType::ROD) { - o_ptr->timeout = (o_ptr->number - 1) * baseitem.pval; + o_ptr->timeout = (o_ptr->number - 1) * o_ptr->get_baseitem_pval(); } if (tval == ItemKindType::WAND) { diff --git a/src/spell/spells-object.cpp b/src/spell/spells-object.cpp index 88a047b1bb..e9b3e68611 100644 --- a/src/spell/spells-object.cpp +++ b/src/spell/spells-object.cpp @@ -32,7 +32,7 @@ #include "sv-definition/sv-scroll-types.h" #include "sv-definition/sv-weapon-types.h" #include "system/artifact-type-definition.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-key.h" #include "system/floor-type-definition.h" #include "system/item-entity.h" #include "system/monster-race-info.h" diff --git a/src/spell/spells-status.cpp b/src/spell/spells-status.cpp index d49dc175c9..81caabf1b9 100644 --- a/src/spell/spells-status.cpp +++ b/src/spell/spells-status.cpp @@ -41,7 +41,8 @@ #include "status/experience.h" #include "status/shape-changer.h" #include "status/sight-setter.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/floor-type-definition.h" #include "system/grid-type-definition.h" #include "system/item-entity.h" diff --git a/src/store/articles-on-sale.cpp b/src/store/articles-on-sale.cpp index 36568f47f5..7611d3bcaa 100644 --- a/src/store/articles-on-sale.cpp +++ b/src/store/articles-on-sale.cpp @@ -16,7 +16,7 @@ #include "sv-definition/sv-staff-types.h" #include "sv-definition/sv-wand-types.h" #include "sv-definition/sv-weapon-types.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-key.h" /*! * @brief 店舗で常時販売するオブジェクトを定義する diff --git a/src/store/rumor.cpp b/src/store/rumor.cpp index 8e74363592..09f383a194 100644 --- a/src/store/rumor.cpp +++ b/src/store/rumor.cpp @@ -7,7 +7,8 @@ #include "object-enchant/special-object-flags.h" #include "system/angband-exceptions.h" #include "system/artifact-type-definition.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/dungeon-info.h" #include "system/item-entity.h" #include "system/monster-race-info.h" @@ -57,7 +58,7 @@ static std::string bind_rumor_name(std::string_view base, std::string_view item_ * @return トークン読み込み成否 とトークン群の配列 * @todo tmp_tokensを使わず単なるsplitにすればもっと簡略化できそう */ -std::pair> get_rumor_tokens(std::string rumor) +static std::pair> get_rumor_tokens(std::string rumor) { constexpr auto num_tokens = 3; char *tmp_tokens[num_tokens]; diff --git a/src/store/store-util.cpp b/src/store/store-util.cpp index 34fe327a45..c3db53de48 100644 --- a/src/store/store-util.cpp +++ b/src/store/store-util.cpp @@ -9,7 +9,6 @@ #include "object-enchant/special-object-flags.h" #include "object/object-value.h" #include "object/tval-types.h" -#include "system/baseitem-info.h" #include "system/item-entity.h" #include @@ -103,7 +102,7 @@ std::vector store_same_magic_device_pvals(ItemEntity *j_ptr) */ static void store_object_absorb(ItemEntity &item1, const ItemEntity &item2) { - const auto max_num = (item1.bi_key.tval() == ItemKindType::ROD) ? std::min(99, MAX_SHORT / item1.get_baseitem().pval) : 99; + const auto max_num = (item1.bi_key.tval() == ItemKindType::ROD) ? std::min(99, MAX_SHORT / item1.get_baseitem_pval()) : 99; const auto total = item1.number + item2.number; const auto diff = (total > max_num) ? total - max_num : 0; item1.number = (total > max_num) ? max_num : total; diff --git a/src/system/alloc-entries.cpp b/src/system/alloc-entries.cpp index 22358171fe..7ef55325b7 100644 --- a/src/system/alloc-entries.cpp +++ b/src/system/alloc-entries.cpp @@ -1,5 +1,6 @@ #include "system/alloc-entries.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/monster-race-info.h" MonraceAllocationEntry::MonraceAllocationEntry(MonraceId index, int level, short prob1, short prob2) @@ -110,7 +111,7 @@ MonraceAllocationEntry &MonraceAllocationTable::get_entry(int index) /* The entries in the "kind allocator table" */ std::vector alloc_kind_table; -BaseitemInfo &alloc_entry::get_baseitem() const +BaseitemDefinition &alloc_entry::get_baseitem() const { return BaseitemList::get_instance().get_baseitem(this->index); } diff --git a/src/system/alloc-entries.h b/src/system/alloc-entries.h index 7135529f07..b0f999e1fa 100644 --- a/src/system/alloc-entries.h +++ b/src/system/alloc-entries.h @@ -33,13 +33,13 @@ class MonraceAllocationEntry { * Pass 1 is determined from allocation information * Pass 2 is determined from allocation restriction */ -class BaseitemInfo; +class BaseitemDefinition; struct alloc_entry { short index; /* The actual index */ int level; /* Base dungeon level */ short prob1; /* Probability, pass 1 */ short prob2; /* Probability, pass 2 */ - BaseitemInfo &get_baseitem() const; + BaseitemDefinition &get_baseitem() const; }; class MonraceAllocationTable { diff --git a/src/system/artifact-type-definition.cpp b/src/system/artifact-type-definition.cpp index d2b8fffbee..b35af088ee 100644 --- a/src/system/artifact-type-definition.cpp +++ b/src/system/artifact-type-definition.cpp @@ -1,6 +1,8 @@ #include "system/artifact-type-definition.h" #include "artifact/fixed-art-types.h" #include "object/tval-types.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/item-entity.h" ArtifactType::ArtifactType() diff --git a/src/system/artifact-type-definition.h b/src/system/artifact-type-definition.h index f64a715446..34e96241ba 100644 --- a/src/system/artifact-type-definition.h +++ b/src/system/artifact-type-definition.h @@ -3,7 +3,7 @@ #include "object-enchant/tr-flags.h" #include "object-enchant/trg-types.h" #include "system/angband.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-key.h" #include "util/dice.h" #include "util/flag-group.h" #include diff --git a/src/system/baseitem-info.cpp b/src/system/baseitem-info.cpp deleted file mode 100644 index 3a8d0b2732..0000000000 --- a/src/system/baseitem-info.cpp +++ /dev/null @@ -1,1160 +0,0 @@ -/*! - * @brief ベースアイテム情報の構造体 / Information about object "kinds", including player knowledge. - * @date 2019/05/01 - * @author deskull - * @details - * ゲーム進行用のセーブファイル上では aware と tried のみ保存対象とすること。と英文ではあるが実際はもっとある様子である。 / - * Only "aware" and "tried" are saved in the savefile - */ - -#include "system/baseitem-info.h" -#include "object/tval-types.h" -#include "sv-definition/sv-armor-types.h" -#include "sv-definition/sv-bow-types.h" -#include "sv-definition/sv-food-types.h" -#include "sv-definition/sv-lite-types.h" -#include "sv-definition/sv-other-types.h" -#include "sv-definition/sv-potion-types.h" -#include "sv-definition/sv-protector-types.h" -#include "sv-definition/sv-rod-types.h" -#include "sv-definition/sv-staff-types.h" -#include "sv-definition/sv-weapon-types.h" -#include "system/angband-exceptions.h" -#include "system/enums/monrace/monrace-id.h" -#include "util/enum-converter.h" -#include "util/string-processor.h" -#include -#include -#include -#include - -namespace { -constexpr auto ITEM_NOT_BOW = "This item is not a bow!"; -constexpr auto ITEM_NOT_ROD = "This item is not a rod!"; -constexpr auto ITEM_NOT_LITE = "This item is not a lite!"; -constexpr auto INVALID_BI_ID_FORMAT = "Invalid Baseitem ID is specified! %d"; -constexpr auto INVALID_BASEITEM_KEY = "Invalid Baseitem Key is specified! Type: %d, Subtype: %d"; -const std::map GOLD_KINDS = { - { MoneyKind::COPPER, _("銅塊", "copper") }, - { MoneyKind::SILVER, _("銀塊", "silver") }, - { MoneyKind::GARNET, _("ガーネット", "garnets") }, - { MoneyKind::GOLD, _("金塊", "gold") }, - { MoneyKind::OPAL, _("オパール", "opals") }, - { MoneyKind::SAPPHIRE, _("サファイア", "sapphires") }, - { MoneyKind::RUBY, _("ルビー", "rubies") }, - { MoneyKind::DIAMOND, _("ダイヤモンド", "diamonds") }, - { MoneyKind::EMERALD, _("エメラルド", "emeralds") }, - { MoneyKind::MITHRIL, _("ミスリル", "mithril") }, - { MoneyKind::ADAMANTITE, _("アダマンタイト", "adamantite") }, -}; -const std::map CREEPING_COIN_DROPS = { - { MonraceId::COPPER_COINS, { ItemKindType::GOLD, 3 } }, - { MonraceId::SILVER_COINS, { ItemKindType::GOLD, 6 } }, - { MonraceId::GOLD_COINS, { ItemKindType::GOLD, 11 } }, - { MonraceId::MITHRIL_COINS, { ItemKindType::GOLD, 17 } }, - { MonraceId::MITHRIL_GOLEM, { ItemKindType::GOLD, 17 } }, - { MonraceId::ADAMANT_COINS, { ItemKindType::GOLD, 18 } }, -}; -} - -bool BaseitemKey::operator==(const BaseitemKey &other) const -{ - return (this->type_value == other.type_value) && (this->subtype_value == other.subtype_value); -} - -// @details type_valueに大小があればそれを判定し、同一ならばsubtype_valueの大小を判定する. -bool BaseitemKey::operator<(const BaseitemKey &other) const -{ - if (this->type_value < other.type_value) { - return true; - } - - if (this->type_value > other.type_value) { - return false; - } - - return this->subtype_value < other.subtype_value; -} - -ItemKindType BaseitemKey::tval() const -{ - return this->type_value; -} - -std::optional BaseitemKey::sval() const -{ - return this->subtype_value; -} - -bool BaseitemKey::is_valid() const -{ - return (this->type_value > ItemKindType::NONE) && this->subtype_value.has_value(); -} - -bool BaseitemKey::is(ItemKindType tval) const -{ - return this->type_value == tval; -} - -/*! - * @brief 射撃武器に対応する矢/弾薬のベースアイテムIDを返す - * @return 対応する矢/弾薬のベースアイテムID - */ -ItemKindType BaseitemKey::get_arrow_kind() const -{ - if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) { - THROW_EXCEPTION(std::logic_error, ITEM_NOT_BOW); - } - - switch (*this->subtype_value) { - case SV_SLING: - return ItemKindType::SHOT; - case SV_SHORT_BOW: - case SV_LONG_BOW: - case SV_NAMAKE_BOW: - return ItemKindType::ARROW; - case SV_LIGHT_XBOW: - case SV_HEAVY_XBOW: - return ItemKindType::BOLT; - case SV_CRIMSON: - case SV_HARP: - return ItemKindType::NO_AMMO; - default: - return ItemKindType::NONE; - } -} - -bool BaseitemKey::is_spell_book() const -{ - switch (this->type_value) { - case ItemKindType::LIFE_BOOK: - case ItemKindType::SORCERY_BOOK: - case ItemKindType::NATURE_BOOK: - case ItemKindType::CHAOS_BOOK: - case ItemKindType::DEATH_BOOK: - case ItemKindType::TRUMP_BOOK: - case ItemKindType::ARCANE_BOOK: - case ItemKindType::CRAFT_BOOK: - case ItemKindType::DEMON_BOOK: - case ItemKindType::CRUSADE_BOOK: - case ItemKindType::MUSIC_BOOK: - case ItemKindType::HISSATSU_BOOK: - case ItemKindType::HEX_BOOK: - return true; - default: - return false; - } -} - -bool BaseitemKey::is_high_level_book() const -{ - if (!this->is_spell_book()) { - return false; - } - - if (this->type_value == ItemKindType::ARCANE_BOOK) { - return false; - } - - return this->subtype_value >= 2; -} - -bool BaseitemKey::is_melee_weapon() const -{ - switch (this->type_value) { - case ItemKindType::POLEARM: - case ItemKindType::SWORD: - case ItemKindType::DIGGING: - case ItemKindType::HAFTED: - return true; - default: - return false; - } -} - -bool BaseitemKey::is_ammo() const -{ - switch (this->type_value) { - case ItemKindType::SHOT: - case ItemKindType::ARROW: - case ItemKindType::BOLT: - return true; - default: - return false; - } -} - -/* - * @brief 未鑑定名を持つか否かの判定 - * @details FOODはキノコが該当する - */ -bool BaseitemKey::has_unidentified_name() const -{ - switch (this->type_value) { - case ItemKindType::AMULET: - case ItemKindType::RING: - case ItemKindType::STAFF: - case ItemKindType::WAND: - case ItemKindType::ROD: - case ItemKindType::SCROLL: - case ItemKindType::POTION: - return true; - case ItemKindType::FOOD: - return this->is_mushrooms(); - default: - return false; - } -} - -bool BaseitemKey::can_recharge() const -{ - switch (this->type_value) { - case ItemKindType::STAFF: - case ItemKindType::WAND: - case ItemKindType::ROD: - return true; - default: - return false; - } -} - -bool BaseitemKey::is_wand_rod() const -{ - switch (this->type_value) { - case ItemKindType::WAND: - case ItemKindType::ROD: - return true; - default: - return false; - } -} - -bool BaseitemKey::is_wand_staff() const -{ - switch (this->type_value) { - case ItemKindType::WAND: - case ItemKindType::STAFF: - return true; - default: - return false; - } -} - -bool BaseitemKey::is_protector() const -{ - switch (this->type_value) { - case ItemKindType::BOOTS: - case ItemKindType::GLOVES: - case ItemKindType::HELM: - case ItemKindType::CROWN: - case ItemKindType::SHIELD: - case ItemKindType::CLOAK: - case ItemKindType::SOFT_ARMOR: - case ItemKindType::HARD_ARMOR: - case ItemKindType::DRAG_ARMOR: - return true; - default: - return false; - } -} - -bool BaseitemKey::can_be_aura_protector() const -{ - switch (this->type_value) { - case ItemKindType::CLOAK: - case ItemKindType::SOFT_ARMOR: - case ItemKindType::HARD_ARMOR: - return true; - default: - return false; - } -} - -bool BaseitemKey::is_wearable() const -{ - switch (this->type_value) { - case ItemKindType::BOW: - case ItemKindType::DIGGING: - case ItemKindType::HAFTED: - case ItemKindType::POLEARM: - case ItemKindType::SWORD: - case ItemKindType::BOOTS: - case ItemKindType::GLOVES: - case ItemKindType::HELM: - case ItemKindType::CROWN: - case ItemKindType::SHIELD: - case ItemKindType::CLOAK: - case ItemKindType::SOFT_ARMOR: - case ItemKindType::HARD_ARMOR: - case ItemKindType::DRAG_ARMOR: - case ItemKindType::LITE: - case ItemKindType::AMULET: - case ItemKindType::RING: - case ItemKindType::CARD: - return true; - default: - return false; - } -} - -bool BaseitemKey::is_weapon() const -{ - switch (this->type_value) { - case ItemKindType::BOW: - case ItemKindType::DIGGING: - case ItemKindType::HAFTED: - case ItemKindType::POLEARM: - case ItemKindType::SWORD: - return true; - default: - return false; - } -} - -bool BaseitemKey::is_equipement() const -{ - return this->is_wearable() || this->is_ammo(); -} - -bool BaseitemKey::is_melee_ammo() const -{ - switch (this->type_value) { - case ItemKindType::HAFTED: - case ItemKindType::POLEARM: - case ItemKindType::DIGGING: - case ItemKindType::BOLT: - case ItemKindType::ARROW: - case ItemKindType::SHOT: - return true; - case ItemKindType::SWORD: - return this->subtype_value != SV_POISON_NEEDLE; - default: - return false; - } -} - -bool BaseitemKey::is_orthodox_melee_weapon() const -{ - switch (this->type_value) { - case ItemKindType::HAFTED: - case ItemKindType::POLEARM: - case ItemKindType::DIGGING: - return true; - case ItemKindType::SWORD: - return this->subtype_value != SV_POISON_NEEDLE; - default: - return false; - } -} - -bool BaseitemKey::is_broken_weapon() const -{ - if (this->type_value != ItemKindType::SWORD) { - return false; - } - - if (!this->subtype_value) { - return false; - } - - switch (*this->subtype_value) { - case SV_BROKEN_DAGGER: - case SV_BROKEN_SWORD: - return true; - default: - return false; - } -} - -bool BaseitemKey::is_throwable() const -{ - switch (this->type_value) { - case ItemKindType::DIGGING: - case ItemKindType::HAFTED: - case ItemKindType::POLEARM: - case ItemKindType::SWORD: - return true; - default: - return false; - } -} - -bool BaseitemKey::is_wieldable_in_etheir_hand() const -{ - switch (this->type_value) { - case ItemKindType::DIGGING: - case ItemKindType::HAFTED: - case ItemKindType::POLEARM: - case ItemKindType::SWORD: - case ItemKindType::SHIELD: - case ItemKindType::CAPTURE: - case ItemKindType::CARD: - return true; - default: - return false; - } -} - -bool BaseitemKey::is_rare() const -{ - static const std::unordered_map> rare_table = { - { ItemKindType::HAFTED, { SV_MACE_OF_DISRUPTION, SV_WIZSTAFF } }, - { ItemKindType::POLEARM, { SV_SCYTHE_OF_SLICING, SV_DEATH_SCYTHE } }, - { ItemKindType::SWORD, { SV_BLADE_OF_CHAOS, SV_DIAMOND_EDGE, SV_POISON_NEEDLE, SV_HAYABUSA } }, - { ItemKindType::SHIELD, { SV_DRAGON_SHIELD, SV_MIRROR_SHIELD } }, - { ItemKindType::HELM, { SV_DRAGON_HELM } }, - { ItemKindType::BOOTS, { SV_PAIR_OF_DRAGON_GREAVE } }, - { ItemKindType::CLOAK, { SV_ELVEN_CLOAK, SV_ETHEREAL_CLOAK, SV_SHADOW_CLOAK, SV_MAGIC_RESISTANCE_CLOAK } }, - { ItemKindType::GLOVES, { SV_SET_OF_DRAGON_GLOVES } }, - { ItemKindType::SOFT_ARMOR, { SV_KUROSHOUZOKU, SV_ABUNAI_MIZUGI } }, - { ItemKindType::HARD_ARMOR, { SV_MITHRIL_CHAIN_MAIL, SV_MITHRIL_PLATE_MAIL, SV_ADAMANTITE_PLATE_MAIL } }, - { ItemKindType::DRAG_ARMOR, { /* Any */ } }, - }; - - if (!this->subtype_value) { - return false; - } - - if (auto it = rare_table.find(this->type_value); it != rare_table.end()) { - const auto &svals = it->second; - return svals.empty() || (svals.find(*this->subtype_value) != svals.end()); - } - - return false; -} - -short BaseitemKey::get_bow_energy() const -{ - if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) { - THROW_EXCEPTION(std::logic_error, ITEM_NOT_BOW); - } - - switch (*this->subtype_value) { - case SV_SLING: - return 8000; - case SV_NAMAKE_BOW: - return 7777; - case SV_LIGHT_XBOW: - return 12000; - case SV_HEAVY_XBOW: - return 13333; - default: - return 10000; - } -} - -int BaseitemKey::get_arrow_magnification() const -{ - if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) { - THROW_EXCEPTION(std::logic_error, ITEM_NOT_BOW); - } - - switch (*this->subtype_value) { - case SV_SLING: - case SV_SHORT_BOW: - return 2; - case SV_LONG_BOW: - case SV_NAMAKE_BOW: - case SV_LIGHT_XBOW: - return 3; - case SV_HEAVY_XBOW: - return 4; - default: - return 0; - } -} - -bool BaseitemKey::is_aiming_rod() const -{ - if ((this->type_value != ItemKindType::ROD) || !this->subtype_value) { - THROW_EXCEPTION(std::logic_error, ITEM_NOT_ROD); - } - - switch (*this->subtype_value) { - case SV_ROD_TELEPORT_AWAY: - case SV_ROD_DISARMING: - case SV_ROD_LITE: - case SV_ROD_SLEEP_MONSTER: - case SV_ROD_SLOW_MONSTER: - case SV_ROD_HYPODYNAMIA: - case SV_ROD_POLYMORPH: - case SV_ROD_ACID_BOLT: - case SV_ROD_ELEC_BOLT: - case SV_ROD_FIRE_BOLT: - case SV_ROD_COLD_BOLT: - case SV_ROD_ACID_BALL: - case SV_ROD_ELEC_BALL: - case SV_ROD_FIRE_BALL: - case SV_ROD_COLD_BALL: - case SV_ROD_STONE_TO_MUD: - return true; - default: - return false; - } -} - -bool BaseitemKey::is_lite_requiring_fuel() const -{ - if ((this->type_value != ItemKindType::LITE) || !this->subtype_value) { - THROW_EXCEPTION(std::logic_error, ITEM_NOT_LITE); - } - - switch (*this->subtype_value) { - case SV_LITE_TORCH: - case SV_LITE_LANTERN: - return true; - default: - return false; - } -} - -bool BaseitemKey::is_junk() const -{ - switch (this->type_value) { - case ItemKindType::FLAVOR_SKELETON: - case ItemKindType::BOTTLE: - case ItemKindType::JUNK: - case ItemKindType::STATUE: - return true; - default: - return false; - } -} - -bool BaseitemKey::is_armour() const -{ - switch (this->type_value) { - case ItemKindType::SOFT_ARMOR: - case ItemKindType::HARD_ARMOR: - case ItemKindType::DRAG_ARMOR: - return true; - default: - return false; - } -} - -bool BaseitemKey::is_cross_bow() const -{ - if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) { - return false; - } - - switch (*this->subtype_value) { - case SV_LIGHT_XBOW: - case SV_HEAVY_XBOW: - return true; - default: - return false; - } -} - -bool BaseitemKey::should_refuse_enchant() const -{ - return *this == BaseitemKey(ItemKindType::SWORD, SV_POISON_NEEDLE); -} - -bool BaseitemKey::is_convertible() const -{ - auto is_convertible = this->is(ItemKindType::JUNK) || this->is(ItemKindType::FLAVOR_SKELETON); - is_convertible |= *this == BaseitemKey(ItemKindType::MONSTER_REMAINS, SV_SKELETON); - return is_convertible; -} - -bool BaseitemKey::is_fuel() const -{ - auto is_fuel = *this == BaseitemKey(ItemKindType::LITE, SV_LITE_TORCH); - is_fuel |= *this == BaseitemKey(ItemKindType::LITE, SV_LITE_LANTERN); - is_fuel |= *this == BaseitemKey(ItemKindType::FLASK, SV_FLASK_OIL); - return is_fuel; -} - -bool BaseitemKey::is_lance() const -{ - auto is_lance = *this == BaseitemKey(ItemKindType::POLEARM, SV_LANCE); - is_lance |= *this == BaseitemKey(ItemKindType::POLEARM, SV_HEAVY_LANCE); - return is_lance; -} - -bool BaseitemKey::is_readable() const -{ - auto can_read = this->is(ItemKindType::SCROLL); - can_read |= this->is(ItemKindType::PARCHMENT); - return can_read; -} - -bool BaseitemKey::is_corpse() const -{ - return *this == BaseitemKey(ItemKindType::MONSTER_REMAINS, SV_CORPSE); -} - -bool BaseitemKey::is_monster() const -{ - switch (this->type_value) { - case ItemKindType::FIGURINE: - case ItemKindType::STATUE: - case ItemKindType::MONSTER_REMAINS: - case ItemKindType::CAPTURE: - return true; - default: - return false; - } -} - -/*! - * @brief 2つのアイテムが同時に「普通の」像であることを示す - * @param チェック対象のベースアイテムキー - * @return 両方が写真の時だけfalse、少なくとも片方が「普通の」像ならばtrue、像ですらないならば例外 - */ -bool BaseitemKey::are_both_statue(const BaseitemKey &other) const -{ - if ((this->type_value != ItemKindType::STATUE)) { - THROW_EXCEPTION(std::logic_error, "This item is not a statue!"); - } - - if (other.type_value != ItemKindType::STATUE) { - THROW_EXCEPTION(std::logic_error, "The other item is not a statue!"); - } - - return (this->subtype_value != SV_PHOTO) || (other.subtype_value != SV_PHOTO); -} - -bool BaseitemKey::is_mushrooms() const -{ - if (!this->subtype_value) { - return false; - } - - switch (*this->subtype_value) { - case SV_FOOD_POISON: - case SV_FOOD_BLINDNESS: - case SV_FOOD_PARANOIA: - case SV_FOOD_CONFUSION: - case SV_FOOD_HALLUCINATION: - case SV_FOOD_PARALYSIS: - case SV_FOOD_WEAKNESS: - case SV_FOOD_SICKNESS: - case SV_FOOD_STUPIDITY: - case SV_FOOD_NAIVETY: - case SV_FOOD_UNHEALTH: - case SV_FOOD_DISEASE: - case SV_FOOD_CURE_POISON: - case SV_FOOD_CURE_BLINDNESS: - case SV_FOOD_CURE_PARANOIA: - case SV_FOOD_CURE_CONFUSION: - case SV_FOOD_CURE_SERIOUS: - case SV_FOOD_RESTORE_STR: - case SV_FOOD_RESTORE_CON: - case SV_FOOD_RESTORING: - return true; - default: - return false; - } -} - -BaseitemInfo::BaseitemInfo() - : bi_key(ItemKindType::NONE) - , symbol_definition(DisplaySymbol(0, '\0')) - , symbol_config(DisplaySymbol(0, '\0')) -{ -} - -/*! - * @brief 正常なベースアイテムかを判定する - * @return 正常なベースアイテムか否か - * @details ID 0は「何か」という異常アイテム - * その他、ベースアイテムIDは歴史的事情により歯抜けが多数あり、それらは名前が空欄になるようにオブジェクトを生成している - * @todo v3.1以降で歯抜けを埋めるようにベースアイテムを追加していきたい (詳細未定) - */ -bool BaseitemInfo::is_valid() const -{ - return (this->idx > 0) && !this->name.empty(); -} - -/*! - * @brief ベースアイテム名を返す - * @return ベースアイテム名 - */ -std::string BaseitemInfo::stripped_name() const -{ - const auto tokens = str_split(this->name, ' '); - std::stringstream ss; - for (const auto &token : tokens) { - if (token == "" || token == "~" || token == "&" || token == "#") { - continue; - } - - auto offset = 0; - auto endpos = token.size(); - auto is_kanji = false; - if (token[0] == '~' || token[0] == '#') { - offset++; - } -#ifdef JP - if (token.size() > 2) { - is_kanji = iskanji(token[endpos - 2]); - } - -#endif - if (!is_kanji && (token[endpos - 1] == '~' || token[endpos - 1] == '#')) { - endpos--; - } - - ss << token.substr(offset, endpos); - } - - ss << " "; - return ss.str(); -} - -bool BaseitemInfo::order_cost(const BaseitemInfo &other) const -{ - return this->cost < other.cost; -} - -/*! - * @brief 最初から簡易な名称が明らかなベースアイテムにその旨のフラグを立てる - */ -void BaseitemInfo::decide_easy_know() -{ - switch (this->bi_key.tval()) { - case ItemKindType::LIFE_BOOK: - case ItemKindType::SORCERY_BOOK: - case ItemKindType::NATURE_BOOK: - case ItemKindType::CHAOS_BOOK: - case ItemKindType::DEATH_BOOK: - case ItemKindType::TRUMP_BOOK: - case ItemKindType::ARCANE_BOOK: - case ItemKindType::CRAFT_BOOK: - case ItemKindType::DEMON_BOOK: - case ItemKindType::CRUSADE_BOOK: - case ItemKindType::MUSIC_BOOK: - case ItemKindType::HISSATSU_BOOK: - case ItemKindType::HEX_BOOK: - case ItemKindType::FLASK: - case ItemKindType::JUNK: - case ItemKindType::BOTTLE: - case ItemKindType::FLAVOR_SKELETON: - case ItemKindType::SPIKE: - case ItemKindType::WHISTLE: - case ItemKindType::FOOD: - case ItemKindType::POTION: - case ItemKindType::SCROLL: - case ItemKindType::ROD: - case ItemKindType::STATUE: - case ItemKindType::PARCHMENT: - this->easy_know = true; - return; - default: - this->easy_know = false; - return; - } -} - -/*! - * @brief オブジェクトを試行済にする - */ -void BaseitemInfo::mark_as_tried() -{ - this->tried = true; -} - -void BaseitemInfo::mark_as_aware() -{ - this->aware = true; -} - -BaseitemList BaseitemList::instance{}; - -BaseitemList &BaseitemList::get_instance() -{ - return instance; -} - -BaseitemInfo &BaseitemList::get_baseitem(const short bi_id) -{ - if ((bi_id < 0) || (bi_id >= static_cast(this->baseitems.size()))) { - THROW_EXCEPTION(std::logic_error, format(INVALID_BI_ID_FORMAT, bi_id)); - } - - return this->baseitems[bi_id]; -} - -const BaseitemInfo &BaseitemList::get_baseitem(const short bi_id) const -{ - if ((bi_id < 0) || (bi_id >= static_cast(this->baseitems.size()))) { - THROW_EXCEPTION(std::logic_error, format(INVALID_BI_ID_FORMAT, bi_id)); - } - - return this->baseitems[bi_id]; -} - -std::vector::iterator BaseitemList::begin() -{ - return this->baseitems.begin(); -} - -std::vector::const_iterator BaseitemList::begin() const -{ - return this->baseitems.begin(); -} - -std::vector::iterator BaseitemList::end() -{ - return this->baseitems.end(); -} - -std::vector::const_iterator BaseitemList::end() const -{ - return this->baseitems.end(); -} - -std::vector::reverse_iterator BaseitemList::rbegin() -{ - return this->baseitems.rbegin(); -} - -std::vector::const_reverse_iterator BaseitemList::rbegin() const -{ - return this->baseitems.rbegin(); -} - -std::vector::reverse_iterator BaseitemList::rend() -{ - return this->baseitems.rend(); -} - -std::vector::const_reverse_iterator BaseitemList::rend() const -{ - return this->baseitems.rend(); -} - -size_t BaseitemList::size() const -{ - return this->baseitems.size(); -} - -bool BaseitemList::empty() const -{ - return this->baseitems.empty(); -} - -void BaseitemList::resize(size_t new_size) -{ - this->baseitems.resize(new_size); -} - -void BaseitemList::shrink_to_fit() -{ - this->baseitems.shrink_to_fit(); -} - -/*! - * @brief ベースアイテムキーからIDを引いて返す - * @param key ベースアイテムキー、但しsvalはランダム(nullopt) の可能性がある - * @return ベースアイテムID - * @details ベースアイテムIDが存在しなければ例外 - */ -short BaseitemList::lookup_baseitem_id(const BaseitemKey &bi_key) const -{ - const auto sval = bi_key.sval(); - if (sval) { - return exe_lookup(bi_key); - } - - static const auto &cache = create_baseitems_cache(); - const auto itr = cache.find(bi_key.tval()); - if (itr == cache.end()) { - constexpr auto fmt = "Specified ItemKindType has no subtype! %d"; - THROW_EXCEPTION(std::runtime_error, format(fmt, enum2i(bi_key.tval()))); - } - - const auto &svals = itr->second; - return exe_lookup({ bi_key.tval(), rand_choice(svals) }); -} - -const BaseitemInfo &BaseitemList::lookup_baseitem(const BaseitemKey &bi_key) const -{ - const auto bi_id = this->lookup_baseitem_id(bi_key); - return this->baseitems[bi_id]; -} - -/*! - * @brief モンスター種族IDから財宝アイテムの価値を引く - * @param monrace_id モンスター種族ID - * @return 特定の財宝を落とすならそのアイテムの価値オフセット、一般的な財宝ドロップならばnullopt - */ -std::optional BaseitemList::lookup_creeping_coin_drop_offset(MonraceId monrace_id) const -{ - const auto it = CREEPING_COIN_DROPS.find(monrace_id); - if (it == CREEPING_COIN_DROPS.end()) { - return std::nullopt; - } - - return this->lookup_gold_offset(it->second); -} - -/*! - * @brief ベースアイテム定義群から財宝アイテムの数を計算する - * @return 財宝を示すベースアイテム数 - */ -int BaseitemList::calc_num_gold_subtypes() const -{ - static const auto &golds = this->create_sorted_golds(); - static const auto sum = std::accumulate(golds.begin(), golds.end(), 0, - [](int count, const auto &pair) { - return count + pair.second.size(); - }); - return sum; -} - -/*! - * @brief 財宝アイテムの価値からベースアイテムを引く - * @param target_offset 財宝アイテムの価値 - * @return ベースアイテムID - * @details 同一の財宝カテゴリ内ならば常に大きいほど価値が高い. - * カテゴリが異なるならば価値の大小は保証しない. 即ち「最も高い銅貨>最も安い銀貨」はあり得る. - */ -const BaseitemInfo &BaseitemList::lookup_gold(int target_offset) const -{ - auto offset = 0; - for (const auto &pair : this->create_sorted_golds()) { - for (const auto &bi_key : pair.second) { - if (offset == target_offset) { - return this->get_baseitem(this->exe_lookup(bi_key)); - } - - offset++; - } - } - - THROW_EXCEPTION(std::runtime_error, format("Invalid gold offset is specified! %d", target_offset)); -} - -/*! - * @brief ベースアイテムIDから財宝アイテムの価値を引く - * @param bi_id ベースアイテムID - * @return 財宝アイテムの価値オフセット - * @details 同一の財宝カテゴリ内ならば常に大きいほど価値が高い. - * カテゴリが異なるならば価値の大小は保証しない. 即ち「最も高い銅貨>最も安い銀貨」はあり得る. - */ -int BaseitemList::lookup_gold_offset(short bi_id) const -{ - auto offset = 0; - for (const auto &pair : this->create_sorted_golds()) { - for (const auto &bi_key : pair.second) { - if (bi_id == this->exe_lookup(bi_key)) { - return offset; - } - - offset++; - } - } - - THROW_EXCEPTION(std::runtime_error, format(INVALID_BI_ID_FORMAT, bi_id)); -} - -void BaseitemList::reset_all_visuals() -{ - for (auto &baseitem : this->baseitems) { - baseitem.symbol_config = baseitem.symbol_definition; - } -} - -/*! - * @brief ベースアイテムの鑑定済みフラグをリセットする - * @details 不具合対策で0からリセットする(セーブは0から) - */ -void BaseitemList::reset_identification_flags() -{ - for (auto &baseitem : this->baseitems) { - baseitem.tried = false; - baseitem.aware = false; - } -} - -/*! - * @brief 未鑑定アイテム種別の内、ゲーム開始時から鑑定済とするアイテムの鑑定済フラグをONにする - * @todo 食料用の杖は該当種族 (ゴーレム/骸骨/ゾンビ/幽霊)では鑑定済だが、本来はこのメソッドで鑑定済にすべき. - */ -void BaseitemList::mark_common_items_as_aware() -{ - std::vector bi_keys; - bi_keys.emplace_back(ItemKindType::POTION, SV_POTION_WATER); - bi_keys.emplace_back(ItemKindType::STAFF, SV_STAFF_NOTHING); - for (const auto &bi_key : bi_keys) { - this->lookup_baseitem(bi_key).mark_as_aware(); - } -} - -void BaseitemList::shuffle_flavors() -{ - this->shuffle_flavors(ItemKindType::RING); - this->shuffle_flavors(ItemKindType::AMULET); - this->shuffle_flavors(ItemKindType::STAFF); - this->shuffle_flavors(ItemKindType::WAND); - this->shuffle_flavors(ItemKindType::ROD); - this->shuffle_flavors(ItemKindType::FOOD); - this->shuffle_flavors(ItemKindType::POTION); - this->shuffle_flavors(ItemKindType::SCROLL); -} - -/*! - * @brief ベースアイテムキーに対応するベースアイテムのIDを検索する - * @param key 検索したいベースアイテムキー - * @return ベースアイテムID - * @details ベースアイテムIDが存在しなければ例外 - */ -short BaseitemList::exe_lookup(const BaseitemKey &bi_key) const -{ - static const auto &cache = create_baseitem_index_chache(); - const auto itr = cache.find(bi_key); - if (itr == cache.end()) { - THROW_EXCEPTION(std::runtime_error, format(INVALID_BASEITEM_KEY, enum2i(bi_key.tval()), *bi_key.sval())); - } - - return itr->second; -} - -/* - * @brief tvalとbi_key.svalに対応する、BaseitenDefinitions のIDを返すためのキャッシュを生成する - * @return tvalと(実在する)svalの組み合わせをキーに、ベースアイテムIDを値とした辞書 - */ -const std::map &BaseitemList::create_baseitem_index_chache() const -{ - static std::map cache; - for (const auto &baseitem : BaseitemList::get_instance()) { - if (!baseitem.is_valid()) { - continue; - } - - const auto &bi_key = baseitem.bi_key; - cache[bi_key] = baseitem.idx; - } - - return cache; -} - -/* - * @brief 特定のtvalとランダムなsvalの組み合わせからベースアイテムを選択するためのキャッシュを生成する - * @return tvalをキーに、svalのリストを値とした辞書 - */ -const std::map> &BaseitemList::create_baseitems_cache() const -{ - static std::map> cache; - for (const auto &baseitem : BaseitemList::get_instance()) { - if (!baseitem.is_valid()) { - continue; - } - - const auto &bi_key = baseitem.bi_key; - const auto tval = bi_key.tval(); - cache[tval].push_back(*bi_key.sval()); - } - - return cache; -} - -/*! - * @brief ベースアイテムキーから財宝アイテムの価値を引く - * @param finding_bi_key 探索対象のベースアイテムキー - * @return 財宝アイテムの価値番号 (大きいほど価値が高い) - * @details 同一の財宝カテゴリ内ならば常に番号が大きいほど価値も高い. - * カテゴリが異なるならば価値の大小は保証しない. 即ち「最も高い銅貨>最も安い銀貨」はあり得る. - */ -int BaseitemList::lookup_gold_offset(const BaseitemKey &finding_bi_key) const -{ - auto offset = 0; - for (const auto &pair : this->create_sorted_golds()) { - for (const auto &bi_key : pair.second) { - if (finding_bi_key == bi_key) { - return offset; - } - - offset++; - } - } - - THROW_EXCEPTION(std::runtime_error, format(INVALID_BASEITEM_KEY, enum2i(finding_bi_key.tval()), *finding_bi_key.sval())); -} - -/*! - * @brief ベースアイテム定義リストから財宝の辞書を作る (価値順) - * @return 財宝種別をキー、それに対応するベースアイテムキーの配列 (安い順にソート済)を値とした辞書 - */ -const std::map> &BaseitemList::create_sorted_golds() const -{ - static std::map> list; - if (!list.empty()) { - return list; - } - - list = this->create_unsorted_golds(); - for (auto &[money_kind, bi_keys] : list) { - std::stable_sort(bi_keys.begin(), bi_keys.end(), - [this](const auto &bi_key1, const auto &bi_key2) { - const auto &baseitem1 = this->lookup_baseitem(bi_key1); - const auto &baseitem2 = this->lookup_baseitem(bi_key2); - return baseitem1.order_cost(baseitem2); - }); - } - - return list; -} - -/*! - * @brief ベースアイテム定義リストから財宝の辞書を作る (ベースアイテムID順) - * @return 財宝種別をキー、それに対応するベースアイテムキーの配列を値とした辞書 - */ -std::map> BaseitemList::create_unsorted_golds() const -{ - std::map> list; - for (const auto &baseitem : this->baseitems) { - const auto &bi_key = baseitem.bi_key; - if (bi_key.tval() != ItemKindType::GOLD) { - continue; - } - - for (const auto money_kind : MONEY_KIND_RANGE) { - if (baseitem.name != GOLD_KINDS.at(money_kind)) { - continue; - } - - list[money_kind].push_back(bi_key); - } - } - - return list; -} - -BaseitemInfo &BaseitemList::lookup_baseitem(const BaseitemKey &bi_key) -{ - const auto bi_id = this->lookup_baseitem_id(bi_key); - return this->baseitems[bi_id]; -} - -/*! - * @brief ベースアイテムの未確定名を共通tval間でシャッフルする - * @param tval シャッフルしたいtval - * @details 巻物、各種魔道具などに利用される。 - */ -void BaseitemList::shuffle_flavors(ItemKindType tval) -{ - std::vector> flavors; - for (auto &baseitem : this->baseitems) { - if (baseitem.bi_key.tval() != tval) { - continue; - } - - if (baseitem.flavor == 0) { - continue; - } - - if (baseitem.flags.has(TR_FIXED_FLAVOR)) { - continue; - } - - flavors.push_back(baseitem.flavor); - } - - rand_shuffle(flavors.begin(), flavors.end()); -} diff --git a/src/system/baseitem-info.h b/src/system/baseitem-info.h deleted file mode 100644 index f4bfca70dc..0000000000 --- a/src/system/baseitem-info.h +++ /dev/null @@ -1,226 +0,0 @@ -#pragma once - -#include "object-enchant/tr-flags.h" -#include "object-enchant/trg-types.h" -#include "object/tval-types.h" -#include "system/angband.h" -#include "util/dice.h" -#include "util/enum-range.h" -#include "util/flag-group.h" -#include "view/display-symbol.h" -#include -#include -#include -#include -#include - -enum class MoneyKind { - COPPER, - SILVER, - GARNET, - GOLD, - OPAL, - SAPPHIRE, - RUBY, - DIAMOND, - EMERALD, - MITHRIL, - ADAMANTITE, - MAX, -}; - -constexpr EnumRange MONEY_KIND_RANGE(MoneyKind::COPPER, MoneyKind::MAX); - -class BaseitemKey { -public: - constexpr BaseitemKey() - : type_value(ItemKindType::NONE) - , subtype_value(std::nullopt) - { - } - - constexpr BaseitemKey(const ItemKindType type_value, const std::optional &subtype_value = std::nullopt) - : type_value(type_value) - , subtype_value(subtype_value) - { - } - - bool operator==(const BaseitemKey &other) const; - bool operator!=(const BaseitemKey &other) const - { - return !(*this == other); - } - - bool operator<(const BaseitemKey &other) const; - bool operator>(const BaseitemKey &other) const - { - return other < *this; - } - - bool operator<=(const BaseitemKey &other) const - { - return !(*this > other); - } - - bool operator>=(const BaseitemKey &other) const - { - return !(*this < other); - } - - ItemKindType tval() const; - std::optional sval() const; - bool is_valid() const; - bool is(ItemKindType tval) const; - ItemKindType get_arrow_kind() const; - bool is_spell_book() const; - bool is_high_level_book() const; - bool is_melee_weapon() const; - bool is_ammo() const; - bool has_unidentified_name() const; - bool can_recharge() const; - bool is_wand_rod() const; - bool is_wand_staff() const; - bool is_protector() const; - bool can_be_aura_protector() const; - bool is_wearable() const; - bool is_weapon() const; - bool is_equipement() const; - bool is_melee_ammo() const; - bool is_orthodox_melee_weapon() const; - bool is_broken_weapon() const; - bool is_throwable() const; - bool is_wieldable_in_etheir_hand() const; - bool is_rare() const; - short get_bow_energy() const; - int get_arrow_magnification() const; - bool is_aiming_rod() const; - bool is_lite_requiring_fuel() const; - bool is_junk() const; - bool is_armour() const; - bool is_cross_bow() const; - bool should_refuse_enchant() const; - bool is_convertible() const; - bool is_fuel() const; - bool is_lance() const; - bool is_readable() const; - bool is_corpse() const; - bool is_monster() const; - bool are_both_statue(const BaseitemKey &other) const; - -private: - ItemKindType type_value; - std::optional subtype_value; - - bool is_mushrooms() const; -}; - -enum class ItemKindType : short; -enum class RandomArtActType : short; -class BaseitemInfo { -public: - BaseitemInfo(); - short idx{}; - - std::string name; /*!< ベースアイテム名 */ - std::string text; /*!< 解説テキスト */ - std::string flavor_name; /*!< 未確定名 */ - - BaseitemKey bi_key; - - PARAMETER_VALUE pval{}; /*!< ベースアイテムのpval(能力修正共通値) Object extra info */ - - HIT_PROB to_h{}; /*!< ベースアイテムの命中修正値 / Bonus to hit */ - int to_d{}; /*!< ベースアイテムのダメージ修正値 / Bonus to damage */ - ARMOUR_CLASS to_a{}; /*!< ベースアイテムのAC修正値 / Bonus to armor */ - ARMOUR_CLASS ac{}; /*!< ベースアイテムのAC基本値 / Base armor */ - - Dice damage_dice{}; /*!< ダメージダイス */ - - WEIGHT weight{}; /*!< ベースアイテムの重量 / Weight */ - PRICE cost{}; /*!< ベースアイテムの基本価値 / Object "base cost" */ - TrFlags flags{}; /*!< ベースアイテムの基本特性ビット配列 / Flags */ - EnumClassFlagGroup gen_flags; /*!< ベースアイテムの生成特性ビット配列 / flags for generate */ - - DEPTH level{}; /*!< ベースアイテムの基本生成階 / Level */ - - struct alloc_table { - int level; /*!< ベースアイテムの生成階 */ - short chance; /*!< ベースアイテムの生成確率 */ - }; - - std::array alloc_tables{}; /*!< ベースアイテムの生成テーブル */ - DisplaySymbol symbol_definition; //!< 定義上のシンボル (色/文字). - bool easy_know{}; /*!< ベースアイテムが初期からベース名を判断可能かどうか / This object is always known (if aware) */ - RandomArtActType act_idx{}; /*!< 発動能力のID / Activative ability index */ - - bool is_valid() const; - std::string stripped_name() const; - bool order_cost(const BaseitemInfo &other) const; - void decide_easy_know(); - - /* @todo ここから下はBaseitemDefinitions.txt に依存しないミュータブルなフィールド群なので、将来的に分離予定 */ - - DisplaySymbol symbol_config; //!< ユーザ個別の設定シンボル (色/文字). - - IDX flavor{}; /*!< 未鑑定名の何番目を当てるか(0は未鑑定名なし) / Special object flavor (or zero) */ - bool aware{}; /*!< ベースアイテムが鑑定済かどうか / The player is "aware" of the item's effects */ - bool tried{}; /*!< ベースアイテムを未鑑定のまま試したことがあるか / The player has "tried" one of the items */ - - void mark_as_tried(); - void mark_as_aware(); -}; - -enum class MonraceId : short; -class BaseitemList { -public: - BaseitemList(BaseitemList &&) = delete; - BaseitemList(const BaseitemList &) = delete; - BaseitemList &operator=(const BaseitemList &) = delete; - BaseitemList &operator=(BaseitemList &&) = delete; - ~BaseitemList() = default; - - static BaseitemList &get_instance(); - BaseitemInfo &get_baseitem(const short bi_id); - const BaseitemInfo &get_baseitem(const short bi_id) const; - - std::vector::iterator begin(); - std::vector::const_iterator begin() const; - std::vector::iterator end(); - std::vector::const_iterator end() const; - std::vector::reverse_iterator rbegin(); - std::vector::const_reverse_iterator rbegin() const; - std::vector::reverse_iterator rend(); - std::vector::const_reverse_iterator rend() const; - size_t size() const; - bool empty() const; - void resize(size_t new_size); - void shrink_to_fit(); - - std::optional lookup_creeping_coin_drop_offset(MonraceId monrace_id) const; - short lookup_baseitem_id(const BaseitemKey &bi_key) const; - const BaseitemInfo &lookup_baseitem(const BaseitemKey &bi_key) const; - int calc_num_gold_subtypes() const; - const BaseitemInfo &lookup_gold(int target_offset) const; - int lookup_gold_offset(short bi_id) const; - - void reset_all_visuals(); - void reset_identification_flags(); - void mark_common_items_as_aware(); - void shuffle_flavors(); - -private: - BaseitemList() = default; - - static BaseitemList instance; - std::vector baseitems{}; - - short exe_lookup(const BaseitemKey &bi_key) const; - const std::map &create_baseitem_index_chache() const; - const std::map> &create_baseitems_cache() const; - int lookup_gold_offset(const BaseitemKey &finding_bi_key) const; - const std::map> &create_sorted_golds() const; - std::map> create_unsorted_golds() const; - - BaseitemInfo &lookup_baseitem(const BaseitemKey &bi_key); - void shuffle_flavors(ItemKindType tval); -}; diff --git a/src/system/baseitem/baseitem-definition.cpp b/src/system/baseitem/baseitem-definition.cpp new file mode 100644 index 0000000000..cc25464673 --- /dev/null +++ b/src/system/baseitem/baseitem-definition.cpp @@ -0,0 +1,130 @@ +/*! + * @brief ベースアイテム定義の実装 + * @date 2024/11/16 + * @author deskull, Hourier + */ + +#include "system/baseitem/baseitem-definition.h" +#include "util/string-processor.h" + +BaseitemDefinition::BaseitemDefinition() + : bi_key(ItemKindType::NONE) + , symbol_definition(DisplaySymbol(0, '\0')) + , symbol_config(DisplaySymbol(0, '\0')) +{ +} + +/*! + * @brief 正常なベースアイテムかを判定する + * @return 正常なベースアイテムか否か + * @details ID 0は「何か」という異常アイテム + * その他、ベースアイテムIDは歴史的事情により歯抜けが多数あり、それらは名前が空欄になるようにオブジェクトを生成している + * @todo v3.1以降で歯抜けを埋めるようにベースアイテムを追加していきたい (詳細未定) + */ +bool BaseitemDefinition::is_valid() const +{ + return (this->idx > 0) && !this->name.empty(); +} + +/*! + * @brief ベースアイテム名を返す + * @return ベースアイテム名 + */ +std::string BaseitemDefinition::stripped_name() const +{ + const auto tokens = str_split(this->name, ' '); + std::stringstream ss; + for (const auto &token : tokens) { + if (token == "" || token == "~" || token == "&" || token == "#") { + continue; + } + + auto offset = 0; + auto endpos = token.size(); + auto is_kanji = false; + if (token[0] == '~' || token[0] == '#') { + offset++; + } +#ifdef JP + if (token.size() > 2) { + is_kanji = iskanji(token[endpos - 2]); + } + +#endif + if (!is_kanji && (token[endpos - 1] == '~' || token[endpos - 1] == '#')) { + endpos--; + } + + ss << token.substr(offset, endpos); + } + + ss << " "; + return ss.str(); +} + +bool BaseitemDefinition::order_cost(const BaseitemDefinition &other) const +{ + return this->cost < other.cost; +} + +/*! + * @brief 最初から簡易な名称が明らかなベースアイテムにその旨のフラグを立てる + */ +void BaseitemDefinition::decide_easy_know() +{ + switch (this->bi_key.tval()) { + case ItemKindType::LIFE_BOOK: + case ItemKindType::SORCERY_BOOK: + case ItemKindType::NATURE_BOOK: + case ItemKindType::CHAOS_BOOK: + case ItemKindType::DEATH_BOOK: + case ItemKindType::TRUMP_BOOK: + case ItemKindType::ARCANE_BOOK: + case ItemKindType::CRAFT_BOOK: + case ItemKindType::DEMON_BOOK: + case ItemKindType::CRUSADE_BOOK: + case ItemKindType::MUSIC_BOOK: + case ItemKindType::HISSATSU_BOOK: + case ItemKindType::HEX_BOOK: + case ItemKindType::FLASK: + case ItemKindType::JUNK: + case ItemKindType::BOTTLE: + case ItemKindType::FLAVOR_SKELETON: + case ItemKindType::SPIKE: + case ItemKindType::WHISTLE: + case ItemKindType::FOOD: + case ItemKindType::POTION: + case ItemKindType::SCROLL: + case ItemKindType::ROD: + case ItemKindType::STATUE: + case ItemKindType::PARCHMENT: + this->easy_know = true; + return; + default: + this->easy_know = false; + return; + } +} + +/*! + * @brief 試行状態を変える + * @param state trueなら試行済、falseなら未試行に変える + */ +void BaseitemDefinition::mark_trial(bool state) +{ + this->tried = state; +} + +/*! + * @brief 鑑定状態を変える + * @param state trueなら鑑定済、falseなら未鑑定に変える + */ +void BaseitemDefinition::mark_awareness(bool state) +{ + this->aware = state; +} + +void BaseitemDefinition::reset_visual() +{ + this->symbol_config = this->symbol_definition; +} diff --git a/src/system/baseitem/baseitem-definition.h b/src/system/baseitem/baseitem-definition.h new file mode 100644 index 0000000000..6d328dd9c5 --- /dev/null +++ b/src/system/baseitem/baseitem-definition.h @@ -0,0 +1,73 @@ +/*! + * @brief ベースアイテムの定義 + * @date 2024/11/16 + * @author deskull, Hourier + */ + +#pragma once + +#include "object-enchant/tr-flags.h" +#include "object-enchant/trg-types.h" +#include "system/baseitem/baseitem-key.h" +#include "util/dice.h" +#include "util/flag-group.h" +#include "view/display-symbol.h" +#include +#include + +enum class ItemKindType : short; +enum class RandomArtActType : short; +class BaseitemDefinition { +public: + BaseitemDefinition(); + short idx{}; + + std::string name; /*!< ベースアイテム名 */ + std::string text; /*!< 解説テキスト */ + std::string flavor_name; /*!< 未確定名 */ + + BaseitemKey bi_key; + + short pval{}; /*!< ベースアイテムのpval(能力修正共通値) Object extra info */ + + short to_h{}; /*!< ベースアイテムの命中修正値 / Bonus to hit */ + int to_d{}; /*!< ベースアイテムのダメージ修正値 / Bonus to damage */ + short to_a{}; /*!< ベースアイテムのAC修正値 / Bonus to armor */ + short ac{}; /*!< ベースアイテムのAC基本値 / Base armor */ + + Dice damage_dice{}; /*!< ダメージダイス */ + + int weight{}; /*!< ベースアイテムの重量 / Weight */ + int cost{}; /*!< ベースアイテムの基本価値 / Object "base cost" */ + TrFlags flags{}; /*!< ベースアイテムの基本特性ビット配列 / Flags */ + EnumClassFlagGroup gen_flags; /*!< ベースアイテムの生成特性ビット配列 / flags for generate */ + + int level{}; /*!< ベースアイテムの基本生成階 / Level */ + + struct alloc_table { + int level; /*!< ベースアイテムの生成階 */ + short chance; /*!< ベースアイテムの生成確率 */ + }; + + std::array alloc_tables{}; /*!< ベースアイテムの生成テーブル */ + DisplaySymbol symbol_definition; //!< 定義上のシンボル (色/文字). + bool easy_know{}; /*!< ベースアイテムが初期からベース名を判断可能かどうか / This object is always known (if aware) */ + RandomArtActType act_idx{}; /*!< 発動能力のID / Activative ability index */ + + bool is_valid() const; + std::string stripped_name() const; + bool order_cost(const BaseitemDefinition &other) const; + void decide_easy_know(); + + /* @todo ここから下はBaseitemDefinitions.txt に依存しないミュータブルなフィールド群なので、将来的に分離予定 */ + + DisplaySymbol symbol_config; //!< ユーザ個別の設定シンボル (色/文字). + + short flavor{}; /*!< 未鑑定名の何番目を当てるか(0は未鑑定名なし) / Special object flavor (or zero) */ + bool aware{}; /*!< ベースアイテムが鑑定済かどうか / The player is "aware" of the item's effects */ + bool tried{}; /*!< ベースアイテムを未鑑定のまま試したことがあるか / The player has "tried" one of the items */ + + void mark_trial(bool state); + void mark_awareness(bool state); + void reset_visual(); +}; diff --git a/src/system/baseitem/baseitem-key.cpp b/src/system/baseitem/baseitem-key.cpp new file mode 100644 index 0000000000..7bc5e333d7 --- /dev/null +++ b/src/system/baseitem/baseitem-key.cpp @@ -0,0 +1,619 @@ +/*! + * @brief ベースアイテムキー (IDと1対1対応するアイテム種別)実装 + * @author Hourier + * @date 2024/11/16 + */ + +#include "system/baseitem/baseitem-key.h" +#include "object/tval-types.h" +#include "sv-definition/sv-armor-types.h" +#include "sv-definition/sv-bow-types.h" +#include "sv-definition/sv-food-types.h" +#include "sv-definition/sv-lite-types.h" +#include "sv-definition/sv-other-types.h" +#include "sv-definition/sv-potion-types.h" +#include "sv-definition/sv-protector-types.h" +#include "sv-definition/sv-rod-types.h" +#include "sv-definition/sv-staff-types.h" +#include "sv-definition/sv-weapon-types.h" +#include "system/angband-exceptions.h" +#include +#include + +constexpr auto ITEM_NOT_BOW = "This item is not a bow!"; +constexpr auto ITEM_NOT_ROD = "This item is not a rod!"; +constexpr auto ITEM_NOT_LITE = "This item is not a lite!"; + +bool BaseitemKey::operator==(const BaseitemKey &other) const +{ + return (this->type_value == other.type_value) && (this->subtype_value == other.subtype_value); +} + +// @details type_valueに大小があればそれを判定し、同一ならばsubtype_valueの大小を判定する. +bool BaseitemKey::operator<(const BaseitemKey &other) const +{ + if (this->type_value < other.type_value) { + return true; + } + + if (this->type_value > other.type_value) { + return false; + } + + return this->subtype_value < other.subtype_value; +} + +ItemKindType BaseitemKey::tval() const +{ + return this->type_value; +} + +std::optional BaseitemKey::sval() const +{ + return this->subtype_value; +} + +bool BaseitemKey::is_valid() const +{ + return (this->type_value > ItemKindType::NONE) && this->subtype_value.has_value(); +} + +bool BaseitemKey::is(ItemKindType tval) const +{ + return this->type_value == tval; +} + +/*! + * @brief 射撃武器に対応する矢/弾薬のベースアイテムIDを返す + * @return 対応する矢/弾薬のベースアイテムID + */ +ItemKindType BaseitemKey::get_arrow_kind() const +{ + if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) { + THROW_EXCEPTION(std::logic_error, ITEM_NOT_BOW); + } + + switch (*this->subtype_value) { + case SV_SLING: + return ItemKindType::SHOT; + case SV_SHORT_BOW: + case SV_LONG_BOW: + case SV_NAMAKE_BOW: + return ItemKindType::ARROW; + case SV_LIGHT_XBOW: + case SV_HEAVY_XBOW: + return ItemKindType::BOLT; + case SV_CRIMSON: + case SV_HARP: + return ItemKindType::NO_AMMO; + default: + return ItemKindType::NONE; + } +} + +bool BaseitemKey::is_spell_book() const +{ + switch (this->type_value) { + case ItemKindType::LIFE_BOOK: + case ItemKindType::SORCERY_BOOK: + case ItemKindType::NATURE_BOOK: + case ItemKindType::CHAOS_BOOK: + case ItemKindType::DEATH_BOOK: + case ItemKindType::TRUMP_BOOK: + case ItemKindType::ARCANE_BOOK: + case ItemKindType::CRAFT_BOOK: + case ItemKindType::DEMON_BOOK: + case ItemKindType::CRUSADE_BOOK: + case ItemKindType::MUSIC_BOOK: + case ItemKindType::HISSATSU_BOOK: + case ItemKindType::HEX_BOOK: + return true; + default: + return false; + } +} + +bool BaseitemKey::is_high_level_book() const +{ + if (!this->is_spell_book()) { + return false; + } + + if (this->type_value == ItemKindType::ARCANE_BOOK) { + return false; + } + + return this->subtype_value >= 2; +} + +bool BaseitemKey::is_melee_weapon() const +{ + switch (this->type_value) { + case ItemKindType::POLEARM: + case ItemKindType::SWORD: + case ItemKindType::DIGGING: + case ItemKindType::HAFTED: + return true; + default: + return false; + } +} + +bool BaseitemKey::is_ammo() const +{ + switch (this->type_value) { + case ItemKindType::SHOT: + case ItemKindType::ARROW: + case ItemKindType::BOLT: + return true; + default: + return false; + } +} + +/* + * @brief 未鑑定名を持つか否かの判定 + * @details FOODはキノコが該当する + */ +bool BaseitemKey::has_unidentified_name() const +{ + switch (this->type_value) { + case ItemKindType::AMULET: + case ItemKindType::RING: + case ItemKindType::STAFF: + case ItemKindType::WAND: + case ItemKindType::ROD: + case ItemKindType::SCROLL: + case ItemKindType::POTION: + return true; + case ItemKindType::FOOD: + return this->is_mushrooms(); + default: + return false; + } +} + +bool BaseitemKey::can_recharge() const +{ + switch (this->type_value) { + case ItemKindType::STAFF: + case ItemKindType::WAND: + case ItemKindType::ROD: + return true; + default: + return false; + } +} + +bool BaseitemKey::is_wand_rod() const +{ + switch (this->type_value) { + case ItemKindType::WAND: + case ItemKindType::ROD: + return true; + default: + return false; + } +} + +bool BaseitemKey::is_wand_staff() const +{ + switch (this->type_value) { + case ItemKindType::WAND: + case ItemKindType::STAFF: + return true; + default: + return false; + } +} + +bool BaseitemKey::is_protector() const +{ + switch (this->type_value) { + case ItemKindType::BOOTS: + case ItemKindType::GLOVES: + case ItemKindType::HELM: + case ItemKindType::CROWN: + case ItemKindType::SHIELD: + case ItemKindType::CLOAK: + case ItemKindType::SOFT_ARMOR: + case ItemKindType::HARD_ARMOR: + case ItemKindType::DRAG_ARMOR: + return true; + default: + return false; + } +} + +bool BaseitemKey::can_be_aura_protector() const +{ + switch (this->type_value) { + case ItemKindType::CLOAK: + case ItemKindType::SOFT_ARMOR: + case ItemKindType::HARD_ARMOR: + return true; + default: + return false; + } +} + +bool BaseitemKey::is_wearable() const +{ + switch (this->type_value) { + case ItemKindType::BOW: + case ItemKindType::DIGGING: + case ItemKindType::HAFTED: + case ItemKindType::POLEARM: + case ItemKindType::SWORD: + case ItemKindType::BOOTS: + case ItemKindType::GLOVES: + case ItemKindType::HELM: + case ItemKindType::CROWN: + case ItemKindType::SHIELD: + case ItemKindType::CLOAK: + case ItemKindType::SOFT_ARMOR: + case ItemKindType::HARD_ARMOR: + case ItemKindType::DRAG_ARMOR: + case ItemKindType::LITE: + case ItemKindType::AMULET: + case ItemKindType::RING: + case ItemKindType::CARD: + return true; + default: + return false; + } +} + +bool BaseitemKey::is_weapon() const +{ + switch (this->type_value) { + case ItemKindType::BOW: + case ItemKindType::DIGGING: + case ItemKindType::HAFTED: + case ItemKindType::POLEARM: + case ItemKindType::SWORD: + return true; + default: + return false; + } +} + +bool BaseitemKey::is_equipement() const +{ + return this->is_wearable() || this->is_ammo(); +} + +bool BaseitemKey::is_melee_ammo() const +{ + switch (this->type_value) { + case ItemKindType::HAFTED: + case ItemKindType::POLEARM: + case ItemKindType::DIGGING: + case ItemKindType::BOLT: + case ItemKindType::ARROW: + case ItemKindType::SHOT: + return true; + case ItemKindType::SWORD: + return this->subtype_value != SV_POISON_NEEDLE; + default: + return false; + } +} + +bool BaseitemKey::is_orthodox_melee_weapon() const +{ + switch (this->type_value) { + case ItemKindType::HAFTED: + case ItemKindType::POLEARM: + case ItemKindType::DIGGING: + return true; + case ItemKindType::SWORD: + return this->subtype_value != SV_POISON_NEEDLE; + default: + return false; + } +} + +bool BaseitemKey::is_broken_weapon() const +{ + if (this->type_value != ItemKindType::SWORD) { + return false; + } + + if (!this->subtype_value) { + return false; + } + + switch (*this->subtype_value) { + case SV_BROKEN_DAGGER: + case SV_BROKEN_SWORD: + return true; + default: + return false; + } +} + +bool BaseitemKey::is_throwable() const +{ + switch (this->type_value) { + case ItemKindType::DIGGING: + case ItemKindType::HAFTED: + case ItemKindType::POLEARM: + case ItemKindType::SWORD: + return true; + default: + return false; + } +} + +bool BaseitemKey::is_wieldable_in_etheir_hand() const +{ + switch (this->type_value) { + case ItemKindType::DIGGING: + case ItemKindType::HAFTED: + case ItemKindType::POLEARM: + case ItemKindType::SWORD: + case ItemKindType::SHIELD: + case ItemKindType::CAPTURE: + case ItemKindType::CARD: + return true; + default: + return false; + } +} + +bool BaseitemKey::is_rare() const +{ + static const std::unordered_map> rare_table = { + { ItemKindType::HAFTED, { SV_MACE_OF_DISRUPTION, SV_WIZSTAFF } }, + { ItemKindType::POLEARM, { SV_SCYTHE_OF_SLICING, SV_DEATH_SCYTHE } }, + { ItemKindType::SWORD, { SV_BLADE_OF_CHAOS, SV_DIAMOND_EDGE, SV_POISON_NEEDLE, SV_HAYABUSA } }, + { ItemKindType::SHIELD, { SV_DRAGON_SHIELD, SV_MIRROR_SHIELD } }, + { ItemKindType::HELM, { SV_DRAGON_HELM } }, + { ItemKindType::BOOTS, { SV_PAIR_OF_DRAGON_GREAVE } }, + { ItemKindType::CLOAK, { SV_ELVEN_CLOAK, SV_ETHEREAL_CLOAK, SV_SHADOW_CLOAK, SV_MAGIC_RESISTANCE_CLOAK } }, + { ItemKindType::GLOVES, { SV_SET_OF_DRAGON_GLOVES } }, + { ItemKindType::SOFT_ARMOR, { SV_KUROSHOUZOKU, SV_ABUNAI_MIZUGI } }, + { ItemKindType::HARD_ARMOR, { SV_MITHRIL_CHAIN_MAIL, SV_MITHRIL_PLATE_MAIL, SV_ADAMANTITE_PLATE_MAIL } }, + { ItemKindType::DRAG_ARMOR, { /* Any */ } }, + }; + + if (!this->subtype_value) { + return false; + } + + if (auto it = rare_table.find(this->type_value); it != rare_table.end()) { + const auto &svals = it->second; + return svals.empty() || (svals.find(*this->subtype_value) != svals.end()); + } + + return false; +} + +short BaseitemKey::get_bow_energy() const +{ + if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) { + THROW_EXCEPTION(std::logic_error, ITEM_NOT_BOW); + } + + switch (*this->subtype_value) { + case SV_SLING: + return 8000; + case SV_NAMAKE_BOW: + return 7777; + case SV_LIGHT_XBOW: + return 12000; + case SV_HEAVY_XBOW: + return 13333; + default: + return 10000; + } +} + +int BaseitemKey::get_arrow_magnification() const +{ + if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) { + THROW_EXCEPTION(std::logic_error, ITEM_NOT_BOW); + } + + switch (*this->subtype_value) { + case SV_SLING: + case SV_SHORT_BOW: + return 2; + case SV_LONG_BOW: + case SV_NAMAKE_BOW: + case SV_LIGHT_XBOW: + return 3; + case SV_HEAVY_XBOW: + return 4; + default: + return 0; + } +} + +bool BaseitemKey::is_aiming_rod() const +{ + if ((this->type_value != ItemKindType::ROD) || !this->subtype_value) { + THROW_EXCEPTION(std::logic_error, ITEM_NOT_ROD); + } + + switch (*this->subtype_value) { + case SV_ROD_TELEPORT_AWAY: + case SV_ROD_DISARMING: + case SV_ROD_LITE: + case SV_ROD_SLEEP_MONSTER: + case SV_ROD_SLOW_MONSTER: + case SV_ROD_HYPODYNAMIA: + case SV_ROD_POLYMORPH: + case SV_ROD_ACID_BOLT: + case SV_ROD_ELEC_BOLT: + case SV_ROD_FIRE_BOLT: + case SV_ROD_COLD_BOLT: + case SV_ROD_ACID_BALL: + case SV_ROD_ELEC_BALL: + case SV_ROD_FIRE_BALL: + case SV_ROD_COLD_BALL: + case SV_ROD_STONE_TO_MUD: + return true; + default: + return false; + } +} + +bool BaseitemKey::is_lite_requiring_fuel() const +{ + if ((this->type_value != ItemKindType::LITE) || !this->subtype_value) { + THROW_EXCEPTION(std::logic_error, ITEM_NOT_LITE); + } + + switch (*this->subtype_value) { + case SV_LITE_TORCH: + case SV_LITE_LANTERN: + return true; + default: + return false; + } +} + +bool BaseitemKey::is_junk() const +{ + switch (this->type_value) { + case ItemKindType::FLAVOR_SKELETON: + case ItemKindType::BOTTLE: + case ItemKindType::JUNK: + case ItemKindType::STATUE: + return true; + default: + return false; + } +} + +bool BaseitemKey::is_armour() const +{ + switch (this->type_value) { + case ItemKindType::SOFT_ARMOR: + case ItemKindType::HARD_ARMOR: + case ItemKindType::DRAG_ARMOR: + return true; + default: + return false; + } +} + +bool BaseitemKey::is_cross_bow() const +{ + if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) { + return false; + } + + switch (*this->subtype_value) { + case SV_LIGHT_XBOW: + case SV_HEAVY_XBOW: + return true; + default: + return false; + } +} + +bool BaseitemKey::should_refuse_enchant() const +{ + return *this == BaseitemKey(ItemKindType::SWORD, SV_POISON_NEEDLE); +} + +bool BaseitemKey::is_convertible() const +{ + auto is_convertible = this->is(ItemKindType::JUNK) || this->is(ItemKindType::FLAVOR_SKELETON); + is_convertible |= *this == BaseitemKey(ItemKindType::MONSTER_REMAINS, SV_SKELETON); + return is_convertible; +} + +bool BaseitemKey::is_fuel() const +{ + auto is_fuel = *this == BaseitemKey(ItemKindType::LITE, SV_LITE_TORCH); + is_fuel |= *this == BaseitemKey(ItemKindType::LITE, SV_LITE_LANTERN); + is_fuel |= *this == BaseitemKey(ItemKindType::FLASK, SV_FLASK_OIL); + return is_fuel; +} + +bool BaseitemKey::is_lance() const +{ + auto is_lance = *this == BaseitemKey(ItemKindType::POLEARM, SV_LANCE); + is_lance |= *this == BaseitemKey(ItemKindType::POLEARM, SV_HEAVY_LANCE); + return is_lance; +} + +bool BaseitemKey::is_readable() const +{ + auto can_read = this->is(ItemKindType::SCROLL); + can_read |= this->is(ItemKindType::PARCHMENT); + return can_read; +} + +bool BaseitemKey::is_corpse() const +{ + return *this == BaseitemKey(ItemKindType::MONSTER_REMAINS, SV_CORPSE); +} + +bool BaseitemKey::is_monster() const +{ + switch (this->type_value) { + case ItemKindType::FIGURINE: + case ItemKindType::STATUE: + case ItemKindType::MONSTER_REMAINS: + case ItemKindType::CAPTURE: + return true; + default: + return false; + } +} + +/*! + * @brief 2つのアイテムが同時に「普通の」像であることを示す + * @param チェック対象のベースアイテムキー + * @return 両方が写真の時だけfalse、少なくとも片方が「普通の」像ならばtrue、像ですらないならば例外 + */ +bool BaseitemKey::are_both_statue(const BaseitemKey &other) const +{ + if ((this->type_value != ItemKindType::STATUE)) { + THROW_EXCEPTION(std::logic_error, "This item is not a statue!"); + } + + if (other.type_value != ItemKindType::STATUE) { + THROW_EXCEPTION(std::logic_error, "The other item is not a statue!"); + } + + return (this->subtype_value != SV_PHOTO) || (other.subtype_value != SV_PHOTO); +} + +bool BaseitemKey::is_mushrooms() const +{ + if (!this->subtype_value) { + return false; + } + + switch (*this->subtype_value) { + case SV_FOOD_POISON: + case SV_FOOD_BLINDNESS: + case SV_FOOD_PARANOIA: + case SV_FOOD_CONFUSION: + case SV_FOOD_HALLUCINATION: + case SV_FOOD_PARALYSIS: + case SV_FOOD_WEAKNESS: + case SV_FOOD_SICKNESS: + case SV_FOOD_STUPIDITY: + case SV_FOOD_NAIVETY: + case SV_FOOD_UNHEALTH: + case SV_FOOD_DISEASE: + case SV_FOOD_CURE_POISON: + case SV_FOOD_CURE_BLINDNESS: + case SV_FOOD_CURE_PARANOIA: + case SV_FOOD_CURE_CONFUSION: + case SV_FOOD_CURE_SERIOUS: + case SV_FOOD_RESTORE_STR: + case SV_FOOD_RESTORE_CON: + case SV_FOOD_RESTORING: + return true; + default: + return false; + } +} diff --git a/src/system/baseitem/baseitem-key.h b/src/system/baseitem/baseitem-key.h new file mode 100644 index 0000000000..b42a7185fa --- /dev/null +++ b/src/system/baseitem/baseitem-key.h @@ -0,0 +1,94 @@ +/*! + * @brief ベースアイテムキー (IDと1対1対応するアイテム種別)定義 + * @author Hourier + * @date 2024/11/16 + */ + +#pragma once + +#include "object/tval-types.h" +#include + +enum class ItemKindType : short; +class BaseitemKey { +public: + constexpr BaseitemKey() + : type_value(ItemKindType::NONE) + , subtype_value(std::nullopt) + { + } + + constexpr BaseitemKey(const ItemKindType type_value, const std::optional &subtype_value = std::nullopt) + : type_value(type_value) + , subtype_value(subtype_value) + { + } + + bool operator==(const BaseitemKey &other) const; + bool operator!=(const BaseitemKey &other) const + { + return !(*this == other); + } + + bool operator<(const BaseitemKey &other) const; + bool operator>(const BaseitemKey &other) const + { + return other < *this; + } + + bool operator<=(const BaseitemKey &other) const + { + return !(*this > other); + } + + bool operator>=(const BaseitemKey &other) const + { + return !(*this < other); + } + + ItemKindType tval() const; + std::optional sval() const; + bool is_valid() const; + bool is(ItemKindType tval) const; + ItemKindType get_arrow_kind() const; + bool is_spell_book() const; + bool is_high_level_book() const; + bool is_melee_weapon() const; + bool is_ammo() const; + bool has_unidentified_name() const; + bool can_recharge() const; + bool is_wand_rod() const; + bool is_wand_staff() const; + bool is_protector() const; + bool can_be_aura_protector() const; + bool is_wearable() const; + bool is_weapon() const; + bool is_equipement() const; + bool is_melee_ammo() const; + bool is_orthodox_melee_weapon() const; + bool is_broken_weapon() const; + bool is_throwable() const; + bool is_wieldable_in_etheir_hand() const; + bool is_rare() const; + short get_bow_energy() const; + int get_arrow_magnification() const; + bool is_aiming_rod() const; + bool is_lite_requiring_fuel() const; + bool is_junk() const; + bool is_armour() const; + bool is_cross_bow() const; + bool should_refuse_enchant() const; + bool is_convertible() const; + bool is_fuel() const; + bool is_lance() const; + bool is_readable() const; + bool is_corpse() const; + bool is_monster() const; + bool are_both_statue(const BaseitemKey &other) const; + +private: + ItemKindType type_value; + std::optional subtype_value; + + bool is_mushrooms() const; +}; diff --git a/src/system/baseitem/baseitem-list.cpp b/src/system/baseitem/baseitem-list.cpp new file mode 100644 index 0000000000..9c93b4e114 --- /dev/null +++ b/src/system/baseitem/baseitem-list.cpp @@ -0,0 +1,437 @@ +/*! + * @brief ベースアイテムの集合論的処理実装 + * @author Hourier + * @date 2024/11/16 + */ + +#include "system/baseitem/baseitem-list.h" +#include "object/tval-types.h" +#include "sv-definition/sv-potion-types.h" +#include "sv-definition/sv-staff-types.h" +#include "system/angband-exceptions.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-key.h" +#include "system/enums/monrace/monrace-id.h" +#include "util/enum-converter.h" +#include "util/enum-range.h" +#include "util/string-processor.h" +#include +#include +#include + +namespace { +constexpr auto INVALID_BI_ID_FORMAT = "Invalid Baseitem ID is specified! %d"; +constexpr auto INVALID_BASEITEM_KEY = "Invalid Baseitem Key is specified! Type: %d, Subtype: %d"; +constexpr EnumRange MONEY_KIND_RANGE(MoneyKind::COPPER, MoneyKind::MAX); +const std::map GOLD_KINDS = { + { MoneyKind::COPPER, _("銅塊", "copper") }, + { MoneyKind::SILVER, _("銀塊", "silver") }, + { MoneyKind::GARNET, _("ガーネット", "garnets") }, + { MoneyKind::GOLD, _("金塊", "gold") }, + { MoneyKind::OPAL, _("オパール", "opals") }, + { MoneyKind::SAPPHIRE, _("サファイア", "sapphires") }, + { MoneyKind::RUBY, _("ルビー", "rubies") }, + { MoneyKind::DIAMOND, _("ダイヤモンド", "diamonds") }, + { MoneyKind::EMERALD, _("エメラルド", "emeralds") }, + { MoneyKind::MITHRIL, _("ミスリル", "mithril") }, + { MoneyKind::ADAMANTITE, _("アダマンタイト", "adamantite") }, +}; +const std::map CREEPING_COIN_DROPS = { + { MonraceId::COPPER_COINS, { ItemKindType::GOLD, 3 } }, + { MonraceId::SILVER_COINS, { ItemKindType::GOLD, 6 } }, + { MonraceId::GOLD_COINS, { ItemKindType::GOLD, 11 } }, + { MonraceId::MITHRIL_COINS, { ItemKindType::GOLD, 17 } }, + { MonraceId::MITHRIL_GOLEM, { ItemKindType::GOLD, 17 } }, + { MonraceId::ADAMANT_COINS, { ItemKindType::GOLD, 18 } }, +}; +} + +BaseitemList BaseitemList::instance{}; + +BaseitemList &BaseitemList::get_instance() +{ + return instance; +} + +BaseitemDefinition &BaseitemList::get_baseitem(const short bi_id) +{ + if ((bi_id < 0) || (bi_id >= static_cast(this->baseitems.size()))) { + THROW_EXCEPTION(std::logic_error, format(INVALID_BI_ID_FORMAT, bi_id)); + } + + return this->baseitems[bi_id]; +} + +const BaseitemDefinition &BaseitemList::get_baseitem(const short bi_id) const +{ + if ((bi_id < 0) || (bi_id >= static_cast(this->baseitems.size()))) { + THROW_EXCEPTION(std::logic_error, format(INVALID_BI_ID_FORMAT, bi_id)); + } + + return this->baseitems[bi_id]; +} + +std::vector::iterator BaseitemList::begin() +{ + return this->baseitems.begin(); +} + +std::vector::const_iterator BaseitemList::begin() const +{ + return this->baseitems.begin(); +} + +std::vector::iterator BaseitemList::end() +{ + return this->baseitems.end(); +} + +std::vector::const_iterator BaseitemList::end() const +{ + return this->baseitems.end(); +} + +std::vector::reverse_iterator BaseitemList::rbegin() +{ + return this->baseitems.rbegin(); +} + +std::vector::const_reverse_iterator BaseitemList::rbegin() const +{ + return this->baseitems.rbegin(); +} + +std::vector::reverse_iterator BaseitemList::rend() +{ + return this->baseitems.rend(); +} + +std::vector::const_reverse_iterator BaseitemList::rend() const +{ + return this->baseitems.rend(); +} + +size_t BaseitemList::size() const +{ + return this->baseitems.size(); +} + +bool BaseitemList::empty() const +{ + return this->baseitems.empty(); +} + +void BaseitemList::resize(size_t new_size) +{ + this->baseitems.resize(new_size); +} + +void BaseitemList::shrink_to_fit() +{ + this->baseitems.shrink_to_fit(); +} + +/*! + * @brief ベースアイテムキーからIDを引いて返す + * @param key ベースアイテムキー、但しsvalはランダム(nullopt) の可能性がある + * @return ベースアイテムID + * @details ベースアイテムIDが存在しなければ例外 + */ +short BaseitemList::lookup_baseitem_id(const BaseitemKey &bi_key) const +{ + const auto sval = bi_key.sval(); + if (sval) { + return exe_lookup(bi_key); + } + + static const auto &cache = this->create_baseitem_subtypes_cache(); + const auto it = cache.find(bi_key.tval()); + if (it == cache.end()) { + constexpr auto fmt = "Specified ItemKindType has no subtype! %d"; + THROW_EXCEPTION(std::runtime_error, format(fmt, enum2i(bi_key.tval()))); + } + + const auto &svals = it->second; + return exe_lookup({ bi_key.tval(), rand_choice(svals) }); +} + +const BaseitemDefinition &BaseitemList::lookup_baseitem(const BaseitemKey &bi_key) const +{ + const auto bi_id = this->lookup_baseitem_id(bi_key); + return this->baseitems[bi_id]; +} + +/*! + * @brief モンスター種族IDから財宝アイテムの価値を引く + * @param monrace_id モンスター種族ID + * @return 特定の財宝を落とすならそのアイテムの価値オフセット、一般的な財宝ドロップならばnullopt + */ +std::optional BaseitemList::lookup_creeping_coin_drop_offset(MonraceId monrace_id) const +{ + const auto it = CREEPING_COIN_DROPS.find(monrace_id); + if (it == CREEPING_COIN_DROPS.end()) { + return std::nullopt; + } + + return this->lookup_gold_offset(it->second); +} + +/*! + * @brief ベースアイテム定義群から財宝アイテムの数を計算する + * @return 財宝を示すベースアイテム数 + */ +int BaseitemList::calc_num_gold_subtypes() const +{ + static const auto &golds = this->create_sorted_golds(); + static const auto sum = std::accumulate(golds.begin(), golds.end(), 0, + [](int count, const auto &pair) { + return count + pair.second.size(); + }); + return sum; +} + +/*! + * @brief 財宝アイテムの価値からベースアイテムを引く + * @param target_offset 財宝アイテムの価値 + * @return ベースアイテムID + * @details 同一の財宝カテゴリ内ならば常に大きいほど価値が高い. + * カテゴリが異なるならば価値の大小は保証しない. 即ち「最も高い銅貨>最も安い銀貨」はあり得る. + */ +const BaseitemDefinition &BaseitemList::lookup_gold(int target_offset) const +{ + auto offset = 0; + for (const auto &pair : this->create_sorted_golds()) { + for (const auto &bi_key : pair.second) { + if (offset == target_offset) { + return this->get_baseitem(this->exe_lookup(bi_key)); + } + + offset++; + } + } + + THROW_EXCEPTION(std::runtime_error, format("Invalid gold offset is specified! %d", target_offset)); +} + +/*! + * @brief ベースアイテムIDから財宝アイテムの価値を引く + * @param bi_id ベースアイテムID + * @return 財宝アイテムの価値オフセット + * @details 同一の財宝カテゴリ内ならば常に大きいほど価値が高い. + * カテゴリが異なるならば価値の大小は保証しない. 即ち「最も高い銅貨>最も安い銀貨」はあり得る. + */ +int BaseitemList::lookup_gold_offset(short bi_id) const +{ + auto offset = 0; + for (const auto &pair : this->create_sorted_golds()) { + for (const auto &bi_key : pair.second) { + if (bi_id == this->exe_lookup(bi_key)) { + return offset; + } + + offset++; + } + } + + THROW_EXCEPTION(std::runtime_error, format(INVALID_BI_ID_FORMAT, bi_id)); +} + +void BaseitemList::reset_all_visuals() +{ + for (auto &baseitem : this->baseitems) { + baseitem.reset_visual(); + } +} + +/*! + * @brief ベースアイテムの鑑定済みフラグをリセットする + * @details 不具合対策で0からリセットする(セーブは0から) + */ +void BaseitemList::reset_identification_flags() +{ + for (auto &baseitem : this->baseitems) { + baseitem.mark_trial(false); + baseitem.mark_awareness(false); + } +} + +/*! + * @brief 未鑑定アイテム種別の内、ゲーム開始時から鑑定済とするアイテムの鑑定済フラグをONにする + * @todo 食料用の杖は該当種族 (ゴーレム/骸骨/ゾンビ/幽霊)では鑑定済だが、本来はこのメソッドで鑑定済にすべき. + */ +void BaseitemList::mark_common_items_as_aware() +{ + std::vector bi_keys; + bi_keys.emplace_back(ItemKindType::POTION, SV_POTION_WATER); + bi_keys.emplace_back(ItemKindType::STAFF, SV_STAFF_NOTHING); + for (const auto &bi_key : bi_keys) { + this->lookup_baseitem(bi_key).mark_awareness(true); + } +} + +void BaseitemList::shuffle_flavors() +{ + this->shuffle_flavors(ItemKindType::RING); + this->shuffle_flavors(ItemKindType::AMULET); + this->shuffle_flavors(ItemKindType::STAFF); + this->shuffle_flavors(ItemKindType::WAND); + this->shuffle_flavors(ItemKindType::ROD); + this->shuffle_flavors(ItemKindType::FOOD); + this->shuffle_flavors(ItemKindType::POTION); + this->shuffle_flavors(ItemKindType::SCROLL); +} + +/*! + * @brief ベースアイテムキーに対応するベースアイテムのIDを検索する + * @param key 検索したいベースアイテムキー + * @return ベースアイテムID + * @details ベースアイテムIDが存在しなければ例外 + */ +short BaseitemList::exe_lookup(const BaseitemKey &bi_key) const +{ + static const auto &cache = this->create_baseitem_keys_cache(); + const auto it = cache.find(bi_key); + if (it == cache.end()) { + THROW_EXCEPTION(std::runtime_error, format(INVALID_BASEITEM_KEY, enum2i(bi_key.tval()), *bi_key.sval())); + } + + return it->second; +} + +/* + * @brief tvalとbi_key.svalに対応する、BaseitenDefinitions のIDを返すためのキャッシュを生成する + * @return tvalと(実在する)svalの組み合わせをキーに、ベースアイテムIDを値とした辞書 + */ +const std::map &BaseitemList::create_baseitem_keys_cache() const +{ + static std::map cache; + for (const auto &baseitem : this->baseitems) { + if (baseitem.is_valid()) { + const auto &bi_key = baseitem.bi_key; + cache[bi_key] = baseitem.idx; + } + } + + return cache; +} + +/* + * @brief 特定のtvalとランダムなsvalの組み合わせからベースアイテムを選択するためのキャッシュを生成する + * @return tvalをキーに、svalのリストを値とした辞書 + */ +const std::map> &BaseitemList::create_baseitem_subtypes_cache() const +{ + static std::map> cache; + for (const auto &baseitem : this->baseitems) { + if (baseitem.is_valid()) { + const auto &bi_key = baseitem.bi_key; + const auto tval = bi_key.tval(); + cache[tval].push_back(*bi_key.sval()); + } + } + + return cache; +} + +/*! + * @brief ベースアイテムキーから財宝アイテムの価値を引く + * @param finding_bi_key 探索対象のベースアイテムキー + * @return 財宝アイテムの価値番号 (大きいほど価値が高い) + * @details 同一の財宝カテゴリ内ならば常に番号が大きいほど価値も高い. + * カテゴリが異なるならば価値の大小は保証しない. 即ち「最も高い銅貨>最も安い銀貨」はあり得る. + */ +int BaseitemList::lookup_gold_offset(const BaseitemKey &finding_bi_key) const +{ + auto offset = 0; + for (const auto &pair : this->create_sorted_golds()) { + for (const auto &bi_key : pair.second) { + if (finding_bi_key == bi_key) { + return offset; + } + + offset++; + } + } + + THROW_EXCEPTION(std::runtime_error, format(INVALID_BASEITEM_KEY, enum2i(finding_bi_key.tval()), *finding_bi_key.sval())); +} + +/*! + * @brief ベースアイテム定義リストから財宝の辞書を作る (価値順) + * @return 財宝種別をキー、それに対応するベースアイテムキーの配列 (安い順にソート済)を値とした辞書 + */ +const std::map> &BaseitemList::create_sorted_golds() const +{ + static std::map> list; + if (!list.empty()) { + return list; + } + + list = this->create_unsorted_golds(); + for (auto &[money_kind, bi_keys] : list) { + std::stable_sort(bi_keys.begin(), bi_keys.end(), + [this](const auto &bi_key1, const auto &bi_key2) { + const auto &baseitem1 = this->lookup_baseitem(bi_key1); + const auto &baseitem2 = this->lookup_baseitem(bi_key2); + return baseitem1.order_cost(baseitem2); + }); + } + + return list; +} + +/*! + * @brief ベースアイテム定義リストから財宝の辞書を作る (ベースアイテムID順) + * @return 財宝種別をキー、それに対応するベースアイテムキーの配列を値とした辞書 + */ +std::map> BaseitemList::create_unsorted_golds() const +{ + std::map> list; + for (const auto &baseitem : this->baseitems) { + const auto &bi_key = baseitem.bi_key; + if (bi_key.tval() != ItemKindType::GOLD) { + continue; + } + + for (const auto money_kind : MONEY_KIND_RANGE) { + if (baseitem.name == GOLD_KINDS.at(money_kind)) { + list[money_kind].push_back(bi_key); + } + } + } + + return list; +} + +BaseitemDefinition &BaseitemList::lookup_baseitem(const BaseitemKey &bi_key) +{ + const auto bi_id = this->lookup_baseitem_id(bi_key); + return this->baseitems[bi_id]; +} + +/*! + * @brief ベースアイテムの未確定名を共通tval間でシャッフルする + * @param tval シャッフルしたいtval + * @details 巻物、各種魔道具などに利用される。 + */ +void BaseitemList::shuffle_flavors(ItemKindType tval) +{ + std::vector> flavors; + for (auto &baseitem : this->baseitems) { + if (baseitem.bi_key.tval() != tval) { + continue; + } + + if (baseitem.flavor == 0) { + continue; + } + + if (baseitem.flags.has(TR_FIXED_FLAVOR)) { + continue; + } + + flavors.push_back(baseitem.flavor); + } + + rand_shuffle(flavors.begin(), flavors.end()); +} diff --git a/src/system/baseitem/baseitem-list.h b/src/system/baseitem/baseitem-list.h new file mode 100644 index 0000000000..5286c8552d --- /dev/null +++ b/src/system/baseitem/baseitem-list.h @@ -0,0 +1,84 @@ +/*! + * @brief ベースアイテムの集合論的処理定義 + * @author Hourier + * @date 2024/11/16 + */ + +#pragma once + +#include +#include +#include + +enum class MoneyKind { + COPPER, + SILVER, + GARNET, + GOLD, + OPAL, + SAPPHIRE, + RUBY, + DIAMOND, + EMERALD, + MITHRIL, + ADAMANTITE, + MAX, +}; + +enum class ItemKindType : short; +enum class MonraceId : short; +class BaseitemDefinition; +class BaseitemKey; +class BaseitemList { +public: + BaseitemList(BaseitemList &&) = delete; + BaseitemList(const BaseitemList &) = delete; + BaseitemList &operator=(const BaseitemList &) = delete; + BaseitemList &operator=(BaseitemList &&) = delete; + ~BaseitemList() = default; + + static BaseitemList &get_instance(); + BaseitemDefinition &get_baseitem(const short bi_id); + const BaseitemDefinition &get_baseitem(const short bi_id) const; + + std::vector::iterator begin(); + std::vector::const_iterator begin() const; + std::vector::iterator end(); + std::vector::const_iterator end() const; + std::vector::reverse_iterator rbegin(); + std::vector::const_reverse_iterator rbegin() const; + std::vector::reverse_iterator rend(); + std::vector::const_reverse_iterator rend() const; + size_t size() const; + bool empty() const; + void resize(size_t new_size); + void shrink_to_fit(); + + std::optional lookup_creeping_coin_drop_offset(MonraceId monrace_id) const; + short lookup_baseitem_id(const BaseitemKey &bi_key) const; + const BaseitemDefinition &lookup_baseitem(const BaseitemKey &bi_key) const; + int calc_num_gold_subtypes() const; + const BaseitemDefinition &lookup_gold(int target_offset) const; + int lookup_gold_offset(short bi_id) const; + + void reset_all_visuals(); + void reset_identification_flags(); + void mark_common_items_as_aware(); + void shuffle_flavors(); + +private: + BaseitemList() = default; + + static BaseitemList instance; + std::vector baseitems{}; + + short exe_lookup(const BaseitemKey &bi_key) const; + const std::map &create_baseitem_keys_cache() const; + const std::map> &create_baseitem_subtypes_cache() const; + int lookup_gold_offset(const BaseitemKey &finding_bi_key) const; + const std::map> &create_sorted_golds() const; + std::map> create_unsorted_golds() const; + + BaseitemDefinition &lookup_baseitem(const BaseitemKey &bi_key); + void shuffle_flavors(ItemKindType tval); +}; diff --git a/src/system/floor-type-definition.cpp b/src/system/floor-type-definition.cpp index 4dc1fe3aee..731136f94a 100644 --- a/src/system/floor-type-definition.cpp +++ b/src/system/floor-type-definition.cpp @@ -5,6 +5,8 @@ #include "monster/monster-timed-effects.h" #include "system/angband-system.h" #include "system/artifact-type-definition.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/dungeon-info.h" #include "system/enums/grid-count-kind.h" #include "system/gamevalue.h" diff --git a/src/system/grid-type-definition.cpp b/src/system/grid-type-definition.cpp index 60532272e7..546428ea34 100644 --- a/src/system/grid-type-definition.cpp +++ b/src/system/grid-type-definition.cpp @@ -101,6 +101,16 @@ bool Grid::is_rune_explosion() const return this->is_object() && TerrainList::get_instance().get_terrain(this->mimic).flags.has(TerrainCharacteristics::RUNE_EXPLOSION); } +/*! + * @brief マスに隠されたドアがあるかの判定 + * @return 隠されたドアがあるか否か + */ +bool Grid::is_hidden_door() const +{ + const auto is_secret = (this->mimic > 0) || this->cave_has_flag(TerrainCharacteristics::SECRET); + return is_secret && this->get_terrain().is_closed_door(); +} + bool Grid::has_monster() const { return is_monster(this->m_idx); diff --git a/src/system/grid-type-definition.h b/src/system/grid-type-definition.h index e0845a7312..916c3f466d 100644 --- a/src/system/grid-type-definition.h +++ b/src/system/grid-type-definition.h @@ -79,6 +79,7 @@ class Grid { bool is_mirror() const; bool is_rune_protection() const; bool is_rune_explosion() const; + bool is_hidden_door() const; bool has_monster() const; uint8_t get_cost(GridFlow gf) const; uint8_t get_distance(GridFlow gf) const; diff --git a/src/system/item-entity.cpp b/src/system/item-entity.cpp index 76b5e0af91..c0e9821cdd 100644 --- a/src/system/item-entity.cpp +++ b/src/system/item-entity.cpp @@ -25,7 +25,9 @@ #include "sv-definition/sv-ring-types.h" #include "sv-definition/sv-weapon-types.h" #include "system/artifact-type-definition.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" +#include "system/enums/monrace/monrace-id.h" #include "system/monster-race-info.h" #include "term/term-color-types.h" #include "tracking/baseitem-tracker.h" @@ -101,7 +103,7 @@ void ItemEntity::generate(short new_bi_id) this->activation_id = baseitem.act_idx; } - if (this->get_baseitem().cost <= 0) { + if (this->is_worthless()) { this->ident |= (IDENT_BROKEN); } @@ -820,7 +822,7 @@ bool ItemEntity::is_target_of(QuestId quest_id) const return this->bi_key == artifact.bi_key; } -BaseitemInfo &ItemEntity::get_baseitem() const +BaseitemDefinition &ItemEntity::get_baseitem() const { return BaseitemList::get_instance().get_baseitem(this->bi_id); } @@ -1200,6 +1202,26 @@ bool ItemEntity::is_similar_for_store(const ItemEntity &other) const return true; } +int ItemEntity::get_baseitem_level() const +{ + return this->get_baseitem().level; +} + +short ItemEntity::get_baseitem_pval() const +{ + return this->get_baseitem().pval; +} + +bool ItemEntity::is_worthless() const +{ + return this->get_baseitem().cost <= 0; +} + +int ItemEntity::get_baseitem_cost() const +{ + return this->get_baseitem().cost; +} + std::string ItemEntity::build_timeout_description(const ActivationType &act) const { const auto description = act.build_timeout_description(); @@ -1258,7 +1280,7 @@ void ItemEntity::mark_as_known() */ void ItemEntity::mark_as_tried() const { - this->get_baseitem().mark_as_tried(); + this->get_baseitem().mark_trial(true); } /*! diff --git a/src/system/item-entity.h b/src/system/item-entity.h index 6d2bf5af68..85a37093b9 100644 --- a/src/system/item-entity.h +++ b/src/system/item-entity.h @@ -12,7 +12,7 @@ #include "object-enchant/trc-types.h" #include "object/object-mark-types.h" #include "system/angband.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-key.h" #include "system/system-variables.h" #include "util/dice.h" #include "util/flag-group.h" @@ -29,7 +29,7 @@ enum class RandomArtActType : short; enum class SmithEffectType : short; class ActivationType; class ArtifactType; -class BaseitemInfo; +class BaseitemDefinition; class DisplaySymbol; class EgoItemDefinition; class MonraceDefinition; @@ -151,7 +151,7 @@ class ItemEntity { bool has_bias() const; bool is_bounty() const; bool is_target_of(QuestId quest_id) const; - BaseitemInfo &get_baseitem() const; + BaseitemDefinition &get_baseitem() const; EgoItemDefinition &get_ego() const; ArtifactType &get_fixed_artifact() const; TrFlags get_flags() const; @@ -163,6 +163,10 @@ class ItemEntity { bool is_similar(const ItemEntity &other) const; int is_similar_part(const ItemEntity &other) const; bool is_similar_for_store(const ItemEntity &other) const; + int get_baseitem_level() const; + short get_baseitem_pval() const; + bool is_worthless() const; + int get_baseitem_cost() const; void mark_as_known(); void mark_as_tried() const; diff --git a/src/view/display-inventory.cpp b/src/view/display-inventory.cpp index 77a9a31249..b70b277683 100644 --- a/src/view/display-inventory.cpp +++ b/src/view/display-inventory.cpp @@ -9,7 +9,7 @@ #include "object/item-tester-hooker.h" #include "object/item-use-flags.h" #include "object/object-info.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "term/gameterm.h" diff --git a/src/view/display-map.cpp b/src/view/display-map.cpp index f3c7839f89..2f236ec1f5 100644 --- a/src/view/display-map.cpp +++ b/src/view/display-map.cpp @@ -11,7 +11,8 @@ #include "object/object-info.h" #include "object/object-mark-types.h" #include "player/player-status.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/floor-type-definition.h" #include "system/grid-type-definition.h" #include "system/item-entity.h" diff --git a/src/view/display-player-stat-info.cpp b/src/view/display-player-stat-info.cpp index 9304e51b93..260454a8b8 100644 --- a/src/view/display-player-stat-info.cpp +++ b/src/view/display-player-stat-info.cpp @@ -23,6 +23,7 @@ #include "term/term-color-types.h" #include "term/z-form.h" #include "util/bit-flags-calculator.h" +#include "view/display-symbol.h" /*! * @brief プレイヤーのパラメータ基礎値 (腕力等)を18以下になるようにして返す diff --git a/src/view/display-player.cpp b/src/view/display-player.cpp index 1d37a40e14..646f941807 100644 --- a/src/view/display-player.cpp +++ b/src/view/display-player.cpp @@ -28,7 +28,7 @@ #include "player/player-status-flags.h" #include "player/player-status-table.h" #include "player/player-status.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" #include "system/floor-type-definition.h" #include "system/item-entity.h" #include "system/player-type-definition.h" diff --git a/src/view/display-store.cpp b/src/view/display-store.cpp index cc36436f3b..8747c64ced 100644 --- a/src/view/display-store.cpp +++ b/src/view/display-store.cpp @@ -11,7 +11,7 @@ #include "store/store-owners.h" #include "store/store-util.h" #include "store/store.h" //!< @todo 相互依存している、こっちは残す?. -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-key.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "system/terrain-type-definition.h" diff --git a/src/window/main-window-equipments.cpp b/src/window/main-window-equipments.cpp index d89247aa7c..6e28284013 100644 --- a/src/window/main-window-equipments.cpp +++ b/src/window/main-window-equipments.cpp @@ -11,7 +11,6 @@ #include "object/item-use-flags.h" #include "object/object-info.h" #include "player/player-status-flags.h" -#include "system/baseitem-info.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "term/gameterm.h" @@ -20,6 +19,7 @@ #include "term/z-form.h" #include "util/bit-flags-calculator.h" #include "util/string-processor.h" +#include "view/display-symbol.h" #include #include diff --git a/src/wizard/items-spoiler.cpp b/src/wizard/items-spoiler.cpp index 84ae00f1c0..bc34e3f18a 100644 --- a/src/wizard/items-spoiler.cpp +++ b/src/wizard/items-spoiler.cpp @@ -6,7 +6,8 @@ #include "object-enchant/trg-types.h" #include "object/object-value.h" #include "system/angband-system.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/item-entity.h" #include "system/player-type-definition.h" #include "term/z-form.h" @@ -24,7 +25,7 @@ */ static std::pair get_info(const ItemEntity &item) { - const auto level = item.get_baseitem().level; + const auto level = item.get_baseitem_level(); const auto price = item.calc_price(); return { level, price }; } diff --git a/src/wizard/wizard-item-modifier.cpp b/src/wizard/wizard-item-modifier.cpp index 4c6dd0f88e..661681ad5d 100644 --- a/src/wizard/wizard-item-modifier.cpp +++ b/src/wizard/wizard-item-modifier.cpp @@ -27,6 +27,8 @@ #include "spell/spells-object.h" #include "system/alloc-entries.h" #include "system/artifact-type-definition.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/floor-type-definition.h" #include "system/item-entity.h" #include "system/player-type-definition.h" @@ -276,7 +278,7 @@ void wiz_identify_full_inventory(PlayerType *player_ptr) } auto &baseitem = o_ptr->get_baseitem(); - baseitem.mark_as_aware(); //!< @note 記録には残さないためTRUEを立てるのみ + baseitem.mark_awareness(true); //!< @note 記録には残さない. set_bits(o_ptr->ident, IDENT_KNOWN | IDENT_FULL_KNOWN); o_ptr->marked.set(OmType::TOUCHED); } @@ -398,7 +400,7 @@ static void wiz_display_item(PlayerType *player_ptr, ItemEntity *o_ptr) auto line = 4; const auto &bi_key = o_ptr->bi_key; - const auto item_level = o_ptr->get_baseitem().level; + const auto item_level = o_ptr->get_baseitem_level(); prt(format("kind = %-5d level = %-4d tval = %-5d sval = %-5d", o_ptr->bi_id, item_level, enum2i(bi_key.tval()), *bi_key.sval()), line, j); prt(format("number = %-3d wgt = %-6d ac = %-5d damage = %s", o_ptr->number, o_ptr->weight, o_ptr->ac, o_ptr->damage_dice.to_string().data()), ++line, j); prt(format("pval = %-5d toac = %-5d tohit = %-4d todam = %-4d", o_ptr->pval, o_ptr->to_a, o_ptr->to_h, o_ptr->to_d), ++line, j); diff --git a/src/wizard/wizard-special-process.cpp b/src/wizard/wizard-special-process.cpp index dda669aab9..e60d75b1a1 100644 --- a/src/wizard/wizard-special-process.cpp +++ b/src/wizard/wizard-special-process.cpp @@ -79,7 +79,8 @@ #include "system/angband-system.h" #include "system/angband-version.h" #include "system/artifact-type-definition.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" +#include "system/baseitem/baseitem-list.h" #include "system/dungeon-info.h" #include "system/floor-type-definition.h" #include "system/grid-type-definition.h" diff --git a/src/world/world-object.cpp b/src/world/world-object.cpp index c26b558439..0ddbaa993d 100644 --- a/src/world/world-object.cpp +++ b/src/world/world-object.cpp @@ -3,7 +3,7 @@ #include "object-enchant/item-apply-magic.h" #include "object/tval-types.h" #include "system/alloc-entries.h" -#include "system/baseitem-info.h" +#include "system/baseitem/baseitem-definition.h" #include "system/dungeon-info.h" #include "system/floor-type-definition.h" #include "system/item-entity.h"