Added Creature C Interface, misc fixes and changes for Creature.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-03-05 11:25:41 +01:00
parent 985c2720c5
commit e990c13109
6 changed files with 153 additions and 26 deletions

View File

@@ -9,7 +9,8 @@ using namespace CreatureLib;
Battling::Creature::Creature(const BattleLibrary* library, const Library::CreatureSpecies* species,
const Library::SpeciesVariant* variant, uint8_t level, uint32_t experience, uint32_t uid,
Library::Gender gender, uint8_t coloring, const Library::Item* heldItem,
std::string nickname, const TalentIndex& talent, std::vector<LearnedAttack*> attacks)
std::string nickname, const Library::TalentIndex& talent,
std::vector<LearnedAttack*> attacks)
: _library(library), _species(species), _variant(variant), _level(level), _experience(experience),
_uniqueIdentifier(uid), _gender(gender), _coloring(coloring), _heldItem(heldItem), _nickname(std::move(nickname)),
_talentIndex(talent), _hasOverridenTalent(false), _attacks(std::move(attacks)) {
@@ -20,8 +21,9 @@ Battling::Creature::Creature(const BattleLibrary* library, const Library::Creatu
}
}
void Battling::Creature::ChangeLevel(int8_t amount) {
void Battling::Creature::ChangeLevelBy(int8_t amount) {
this->_level += amount;
_experience = _library->GetGrowthRateLibrary()->CalculateExperience(_species->GetGrowthRate(), _level);
RecalculateFlatStats();
}
@@ -176,13 +178,21 @@ const Library::SpeciesVariant* Battling::Creature::GetDisplayVariant() const {
variant = _variant;
return variant;
}
void Battling::Creature::SetHeldItem(const Arbutils::CaseInsensitiveConstString& itemName) {
void Battling::Creature::SetHeldItem(const ConstString& itemName) {
const Library::Item* item;
if (!_library->GetItemLibrary()->TryGet(itemName, item)) {
throw CreatureException("Item not found.");
}
_heldItem = item;
}
void Battling::Creature::SetHeldItem(uint32_t itemNameHash) {
const Library::Item* item;
if (!_library->GetItemLibrary()->TryGet(itemNameHash, item)) {
throw CreatureException("Item not found.");
}
_heldItem = item;
}
void Battling::Creature::AddVolatileScript(const ConstString& name) {
auto script = _volatile.Get(name);
if (script != nullptr) {
@@ -196,4 +206,4 @@ void Battling::Creature::AddVolatileScript(const ConstString& name) {
void Battling::Creature::AddVolatileScript(Script* script) { _volatile.Add(script); }
void Battling::Creature::RemoveVolatileScript(const ConstString& name) { _volatile.Remove(name); }
void Battling::Creature::RemoveVolatileScript(Battling::Script* script) { _volatile.Remove(script->GetName()); }
void Battling::Creature::HasVolatileScript(const ConstString& name) const { _volatile.Has(name); }
bool Battling::Creature::HasVolatileScript(const ConstString& name) const { return _volatile.Has(name); }