diff --git a/Source/items.cpp b/Source/items.cpp index f085bda23..25c551d5c 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -510,24 +510,10 @@ void CalcSelfItems(Player &player) } while (changeflag); } -bool ItemMinStats(const Player &player, Item &x) -{ - if (player._pMagic < x._iMinMag) - return false; - - if (player._pStrength < x._iMinStr) - return false; - - if (player._pDexterity < x._iMinDex) - return false; - - return true; -} - void CalcPlrItemMin(Player &player) { for (Item &item : InventoryAndBeltPlayerItemsRange { player }) { - item._iStatFlag = ItemMinStats(player, item); + item._iStatFlag = player.CanUseItem(item); } } @@ -583,7 +569,7 @@ void CalcPlrBookVals(Player &player) spellLevel = 0; } } - item._iStatFlag = ItemMinStats(player, item); + item._iStatFlag = player.CanUseItem(item); } } } diff --git a/Source/player.h b/Source/player.h index c6e43cfe6..d47bd02cf 100644 --- a/Source/player.h +++ b/Source/player.h @@ -299,6 +299,13 @@ struct Player { void CalcScrolls(); + bool CanUseItem(const Item &item) const + { + return _pStrength >= item._iMinStr + && _pMagic >= item._iMinMag + && _pDexterity >= item._iMinDex; + } + bool HasItem(int item, int *idx = nullptr) const; /**