Functions to set Creature Held Item, and helper function to check whether Creature is holding a specific held item.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-02-17 17:16:28 +01:00
parent 75bce0e329
commit ce31309b2a
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 13 additions and 0 deletions

View File

@ -178,3 +178,10 @@ const Library::SpeciesVariant* Battling::Creature::GetDisplayVariant() const {
variant = _variant; variant = _variant;
return variant; return variant;
} }
void Battling::Creature::SetHeldItem(const std::string& itemName) {
const Library::Item* item;
if (!_library->GetItemLibrary()->TryGet(itemName, item)) {
throw CreatureException("Item not found.");
}
_heldItem = item;
}

View File

@ -82,7 +82,13 @@ namespace CreatureLib::Battling {
inline uint32_t GetExperience() const { return _experience; } inline uint32_t GetExperience() const { return _experience; }
inline Library::Gender GetGender() const { return _gender; } inline Library::Gender GetGender() const { return _gender; }
inline uint8_t GetColoring() const { return _coloring; } inline uint8_t GetColoring() const { return _coloring; }
inline const bool HasHeldItem(const std::string& name) const {
return _heldItem != nullptr && _heldItem->GetName() == name;
}
inline const Library::Item* GetHeldItem() const { return _heldItem; } inline const Library::Item* GetHeldItem() const { return _heldItem; }
void SetHeldItem(const std::string& itemName);
inline void SetHeldItem(Library::Item* item) { _heldItem = item; };
inline uint32_t GetCurrentHealth() const { return _currentHealth; } inline uint32_t GetCurrentHealth() const { return _currentHealth; }
void SetBattleData(Battle* battle, BattleSide* side); void SetBattleData(Battle* battle, BattleSide* side);