From 6e2751649a110f80847a085d80571aa0be39ebdd Mon Sep 17 00:00:00 2001 From: ephphatha Date: Wed, 29 Sep 2021 23:04:45 +1000 Subject: [PATCH] Move ItemMinStats to a member function on Player --- Source/items.cpp | 18 ++---------------- Source/player.h | 7 +++++++ 2 files changed, 9 insertions(+), 16 deletions(-) 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; /**