2019-10-24 11:37:55 +00:00
|
|
|
#include "LearnedAttack.hpp"
|
2020-03-22 12:42:26 +00:00
|
|
|
#include <Arbutils/Assert.hpp>
|
2019-11-28 11:55:22 +00:00
|
|
|
CreatureLib::Battling::LearnedAttack::LearnedAttack(CreatureLib::Library::AttackData* attack, uint8_t maxUses,
|
|
|
|
AttackLearnMethod learnMethod)
|
2020-03-22 12:42:26 +00:00
|
|
|
: _attack(attack), _maxUses(maxUses), _remainingUses(maxUses), _learnMethod(learnMethod) {
|
|
|
|
AssertNotNull(_attack)
|
|
|
|
}
|
2019-10-25 18:08:25 +00:00
|
|
|
|
2019-11-28 11:55:22 +00:00
|
|
|
CreatureLib::Battling::LearnedAttack::LearnedAttack(const CreatureLib::Library::AttackData* attack,
|
|
|
|
AttackLearnMethod learnMethod)
|
|
|
|
: _attack(attack), _maxUses(attack->GetBaseUsages()), _remainingUses(_maxUses), _learnMethod(learnMethod) {}
|
2019-10-25 18:08:25 +00:00
|
|
|
|
2019-11-28 11:55:22 +00:00
|
|
|
const CreatureLib::Library::AttackData* CreatureLib::Battling::LearnedAttack::GetAttack() const { return _attack; }
|
2019-10-24 11:37:55 +00:00
|
|
|
|
2019-11-28 11:55:22 +00:00
|
|
|
uint8_t CreatureLib::Battling::LearnedAttack::GetMaxUses() const { return _maxUses; }
|
2019-10-24 11:37:55 +00:00
|
|
|
|
2019-11-28 11:55:22 +00:00
|
|
|
uint8_t CreatureLib::Battling::LearnedAttack::GetRemainingUses() const { return _remainingUses; }
|
2019-10-24 11:37:55 +00:00
|
|
|
|
|
|
|
CreatureLib::Battling::AttackLearnMethod CreatureLib::Battling::LearnedAttack::GetLearnMethod() const {
|
|
|
|
return _learnMethod;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CreatureLib::Battling::LearnedAttack::TryUse(uint8_t uses) {
|
2019-11-28 11:55:22 +00:00
|
|
|
if (uses > _remainingUses)
|
|
|
|
return false;
|
2019-10-24 11:37:55 +00:00
|
|
|
_remainingUses -= uses;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-11-28 11:55:22 +00:00
|
|
|
void CreatureLib::Battling::LearnedAttack::DecreaseUses(uint8_t amount) { _remainingUses -= amount; }
|
2019-10-24 11:37:55 +00:00
|
|
|
|
2019-11-28 11:55:22 +00:00
|
|
|
void CreatureLib::Battling::LearnedAttack::RestoreUses(uint8_t amount) { _remainingUses += amount; }
|
2019-10-24 11:37:55 +00:00
|
|
|
|
2019-11-28 11:55:22 +00:00
|
|
|
void CreatureLib::Battling::LearnedAttack::RestoreUses() { _remainingUses = _maxUses; }
|