Documents LearnableAttacks
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
2020-09-27 11:17:13 +02:00
parent 4006d63872
commit e14f747d48
2 changed files with 33 additions and 12 deletions

View File

@@ -3,13 +3,13 @@
namespace CreatureLib::Library {
struct LearnableAttacks::impl {
private:
ArbUt::Dictionary<uint8_t, ArbUt::List<ArbUt::BorrowedPtr<const AttackData>>> _learnedByLevel;
ArbUt::Dictionary<level_int_t, ArbUt::List<ArbUt::BorrowedPtr<const AttackData>>> _learnedByLevel;
ArbUt::List<ArbUt::BorrowedPtr<const AttackData>> _distinctLevelAttacks;
public:
explicit impl(size_t levelAttackCapacity)
: _learnedByLevel(
ArbUt::Dictionary<uint8_t, ArbUt::List<ArbUt::BorrowedPtr<const AttackData>>>(levelAttackCapacity)) {}
explicit impl(level_int_t levelAttackCapacity)
: _learnedByLevel(ArbUt::Dictionary<level_int_t, ArbUt::List<ArbUt::BorrowedPtr<const AttackData>>>(
levelAttackCapacity)) {}
~impl() = default;
@@ -24,8 +24,8 @@ namespace CreatureLib::Library {
}
}
inline bool HasAttacksForLevel(uint8_t level) const noexcept { return _learnedByLevel.Has(level); }
inline const ArbUt::List<ArbUt::BorrowedPtr<const AttackData>>& GetAttacksForLevel(uint8_t level) const {
inline bool HasAttacksForLevel(level_int_t level) const noexcept { return _learnedByLevel.Has(level); }
inline const ArbUt::List<ArbUt::BorrowedPtr<const AttackData>>& GetAttacksForLevel(level_int_t level) const {
if (!_learnedByLevel.Has(level)) {
THROW("No attacks found for level " << (uint32_t)level << ".");
}
@@ -47,14 +47,17 @@ namespace CreatureLib::Library {
}
};
LearnableAttacks::LearnableAttacks(size_t levelAttackCapacity) : _impl(new impl(levelAttackCapacity)) {}
LearnableAttacks::LearnableAttacks(level_int_t levelAttackCapacity) : _impl(new impl(levelAttackCapacity)) {}
LearnableAttacks::~LearnableAttacks() = default;
void LearnableAttacks::AddLevelAttack(level_int_t level, ArbUt::BorrowedPtr<const AttackData> attack) {
_impl->AddLevelAttack(level, attack);
}
bool LearnableAttacks::HasAttacksForLevel(uint8_t level) const noexcept { return _impl->HasAttacksForLevel(level); }
const ArbUt::List<ArbUt::BorrowedPtr<const AttackData>>& LearnableAttacks::GetAttacksForLevel(uint8_t level) const {
bool LearnableAttacks::HasAttacksForLevel(level_int_t level) const noexcept {
return _impl->HasAttacksForLevel(level);
}
const ArbUt::List<ArbUt::BorrowedPtr<const AttackData>>&
LearnableAttacks::GetAttacksForLevel(level_int_t level) const {
return _impl->GetAttacksForLevel(level);
}
const ArbUt::List<ArbUt::BorrowedPtr<const AttackData>>&