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) { export uint8_t CreatureLib_Creature_Heal(Creature* p, uint32_t health, bool canRevive) {
Try(p->Heal(health, 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) { export uint8_t CreatureLib_Creature_GetActiveTalent(const Creature* p, const char*& out) {
Try(out = p->GetActiveTalent().c_str();) Try(out = p->GetActiveTalent().c_str();)
} }

View File

@ -171,6 +171,14 @@ void Battling::Creature::Heal(uint32_t amount, bool canRevive) {
_currentHealth = newHealth; _currentHealth = newHealth;
} }
void Battling::Creature::RestoreAllAttackUses() noexcept {
for (auto& a : _attacks) {
if (a != nullptr) {
a->RestoreAllUses();
}
}
}
void Battling::Creature::OverrideActiveTalent(const ArbUt::StringView& talent) { void Battling::Creature::OverrideActiveTalent(const ArbUt::StringView& talent) {
_hasOverridenTalent = true; _hasOverridenTalent = true;
if (_activeTalent != nullptr) { if (_activeTalent != nullptr) {
@ -262,4 +270,4 @@ void Battling::Creature::AddVolatileScript(const ArbUt::StringView& name) {
void Battling::Creature::AddVolatileScript(Script* script) { _volatile.Add(script); } void Battling::Creature::AddVolatileScript(Script* script) { _volatile.Add(script); }
void Battling::Creature::RemoveVolatileScript(const ArbUt::BasicStringView& name) { _volatile.Remove(name); } void Battling::Creature::RemoveVolatileScript(const ArbUt::BasicStringView& name) { _volatile.Remove(name); }
void Battling::Creature::RemoveVolatileScript(Battling::Script* script) { _volatile.Remove(script->GetName()); } void Battling::Creature::RemoveVolatileScript(Battling::Script* script) { _volatile.Remove(script->GetName()); }
bool Battling::Creature::HasVolatileScript(const ArbUt::BasicStringView& name) const { return _volatile.Has(name); } bool Battling::Creature::HasVolatileScript(const ArbUt::BasicStringView& name) const { return _volatile.Has(name); }

View File

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