1 #include "object-hook/hook-weapon.h"
2 #include "object-enchant/tr-types.h"
3 #include "object-hook/hook-armor.h"
4 #include "object/object-flags.h"
5 #include "player/player-skill.h"
6 #include "sv-definition/sv-weapon-types.h"
7 #include "system/object-type-definition.h"
8 #include "system/player-type-definition.h"
9 #include "util/bit-flags-calculator.h"
12 * @brief オブジェクトがプレイヤーの職業に応じた適正武器か否かを返す / Favorite weapons
13 * @param o_ptr 対象のオブジェクト構造体ポインタ
14 * @return オブジェクトが適正武器ならばTRUEを返す
16 bool object_is_favorite(player_type *player_ptr, const object_type *o_ptr)
18 /* Only melee weapons match */
19 if (!(o_ptr->tval == ItemKindType::POLEARM || o_ptr->tval == ItemKindType::SWORD || o_ptr->tval == ItemKindType::DIGGING || o_ptr->tval == ItemKindType::HAFTED)) {
23 /* Favorite weapons are varied depend on the class */
24 switch (player_ptr->pclass) {
26 auto flgs = object_flags_known(o_ptr);
28 if (flgs.has_not(TR_BLESSED) && !(o_ptr->tval == ItemKindType::HAFTED))
34 case CLASS_FORCETRAINER:
36 if (!(s_info[player_ptr->pclass].w_max[enum2i(o_ptr->tval) - enum2i(TV_WEAPON_BEGIN)][o_ptr->sval]))
40 case CLASS_BEASTMASTER:
42 auto flgs = object_flags_known(o_ptr);
44 /* Is it known to be suitable to using while riding? */
45 if (flgs.has_not(TR_RIDING))
52 if (s_info[player_ptr->pclass].w_max[enum2i(o_ptr->tval) - enum2i(TV_WEAPON_BEGIN)][o_ptr->sval] < WEAPON_EXP_MASTER)
58 if (s_info[player_ptr->pclass].w_max[enum2i(o_ptr->tval) - enum2i(TV_WEAPON_BEGIN)][o_ptr->sval] <= WEAPON_EXP_BEGINNER)
63 /* All weapons are okay for non-special classes */