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 auto short_pclass = enum2i(player_ptr->pclass);
25 switch (player_ptr->pclass) {
26 case PlayerClassType::PRIEST: {
27 auto flgs = object_flags_known(o_ptr);
29 if (flgs.has_not(TR_BLESSED) && !(o_ptr->tval == ItemKindType::HAFTED))
34 case PlayerClassType::MONK:
35 case PlayerClassType::FORCETRAINER:
37 if (!(s_info[short_pclass].w_max[o_ptr->tval][o_ptr->sval]))
41 case PlayerClassType::BEASTMASTER:
42 case PlayerClassType::CAVALRY: {
43 auto flgs = object_flags_known(o_ptr);
45 /* Is it known to be suitable to using while riding? */
46 if (flgs.has_not(TR_RIDING))
52 case PlayerClassType::SORCERER:
53 if (s_info[short_pclass].w_max[o_ptr->tval][o_ptr->sval] < PlayerSkill::weapon_exp_at(EXP_LEVEL_MASTER))
57 case PlayerClassType::NINJA:
59 if (s_info[short_pclass].w_max[o_ptr->tval][o_ptr->sval] <= PlayerSkill::weapon_exp_at(EXP_LEVEL_BEGINNER))
64 /* All weapons are okay for non-special classes */