Browse Source

Move ItemMinStats to a member function on Player

pull/3752/head
ephphatha 5 years ago committed by Anders Jenbo
parent
commit
6e2751649a
  1. 18
      Source/items.cpp
  2. 7
      Source/player.h

18
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);
}
}
}

7
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;
/**

Loading…
Cancel
Save