Helper method to restore all attack uses on a Creature.
continuous-integration/drone/push Build is passing Details

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
Deukhoofd 2020-08-08 11:32:25 +02:00
parent 3d21b7c42d
commit 4ef24dd122
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
3 changed files with 11 additions and 1 deletions

View File

@ -57,6 +57,7 @@ export uint8_t CreatureLib_Creature_Damage(Creature* p, uint32_t damage, DamageS
export uint8_t CreatureLib_Creature_Heal(Creature* p, uint32_t health, bool canRevive) {
Try(p->Heal(health, canRevive);)
}
export uint8_t CreatureLib_Creature_RestoreAllAttackUses(Creature* p) { Try(p->RestoreAllAttackUses();) }
export uint8_t CreatureLib_Creature_GetActiveTalent(const Creature* p, const char*& out) {
Try(out = p->GetActiveTalent().c_str();)
}

View File

@ -171,6 +171,14 @@ void Battling::Creature::Heal(uint32_t amount, bool canRevive) {
_currentHealth = newHealth;
}
void Battling::Creature::RestoreAllAttackUses() noexcept {
for (auto& a : _attacks) {
if (a != nullptr) {
a->RestoreAllUses();
}
}
}
void Battling::Creature::OverrideActiveTalent(const ArbUt::StringView& talent) {
_hasOverridenTalent = true;
if (_activeTalent != nullptr) {

View File

@ -120,6 +120,7 @@ namespace CreatureLib::Battling {
void ChangeLevelBy(int8_t amount);
void Damage(uint32_t damage, DamageSource source);
void Heal(uint32_t amount, bool canRevive = false);
void RestoreAllAttackUses () noexcept;
void OverrideActiveTalent(const ArbUt::StringView& talent);
void AddExperience(uint32_t amount);