CreatureLib/src/Battling/Models/LearnedAttack.cpp

36 lines
1.5 KiB
C++

#include "LearnedAttack.hpp"
CreatureLib::Battling::LearnedAttack::LearnedAttack(
const ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData>& attack, u8 maxUses, AttackLearnMethod learnMethod)
: _attack(attack), _maxUses(maxUses), _remainingUses(maxUses), _learnMethod(learnMethod) {}
CreatureLib::Battling::LearnedAttack::LearnedAttack(
const ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData>& attack, AttackLearnMethod learnMethod)
: _attack(attack), _maxUses(attack->GetBaseUsages()), _remainingUses(_maxUses), _learnMethod(learnMethod) {}
const ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData>&
CreatureLib::Battling::LearnedAttack::GetAttack() const noexcept {
return _attack;
}
u8 CreatureLib::Battling::LearnedAttack::GetMaxUses() const noexcept { return _maxUses; }
u8 CreatureLib::Battling::LearnedAttack::GetRemainingUses() const noexcept { return _remainingUses; }
CreatureLib::Battling::AttackLearnMethod CreatureLib::Battling::LearnedAttack::GetLearnMethod() const noexcept {
return _learnMethod;
}
bool CreatureLib::Battling::LearnedAttack::TryUse(u8 uses) noexcept {
if (uses > _remainingUses)
return false;
_remainingUses -= uses;
return true;
}
void CreatureLib::Battling::LearnedAttack::DecreaseUses(u8 amount) noexcept { _remainingUses -= amount; }
void CreatureLib::Battling::LearnedAttack::RestoreUses(u8 amount) noexcept { _remainingUses += amount; }
void CreatureLib::Battling::LearnedAttack::RestoreAllUses() noexcept { _remainingUses = _maxUses; }