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

@@ -5,19 +5,37 @@
#include "../Attacks/AttackData.hpp"
namespace CreatureLib::Library {
/// @brief Data class for holding the different attacks a creature can learn.
class LearnableAttacks {
private:
struct impl;
std::unique_ptr<impl> _impl;
public:
explicit LearnableAttacks(size_t levelAttackCapacity);
/// @brief Initialise the class using the maximum level a creature can reach.
/// @param levelAttackCapacity The maximum level a creature can reach
explicit LearnableAttacks(level_int_t levelAttackCapacity);
virtual ~LearnableAttacks();
/// @brief Add an attack that can be learned at a certain level.
/// @param level The level the attack can be learned at.
/// @param attack A pointer to the attack data that can be learned/
void AddLevelAttack(level_int_t level, ArbUt::BorrowedPtr<const AttackData> attack);
bool HasAttacksForLevel(uint8_t level) const noexcept;
const ArbUt::List<ArbUt::BorrowedPtr<const AttackData>>& GetAttacksForLevel(uint8_t level) const;
/// @brief Returns whether or not a specific level has learnable attacks.
/// @param level The level to check for.
/// @return Whether or not a specific level has learnable attacks.
bool HasAttacksForLevel(level_int_t level) const noexcept;
/// @brief Returns a list of the attacks that can be learned at a specific level.
/// @param level The level to get the attacks from.
/// @return A list of the attacks that can be learned at a specific level.
/// @warning Note that this will throw if the level has no learnable attacks. Use HasAttacksForLevel first.
const ArbUt::List<ArbUt::BorrowedPtr<const AttackData>>& GetAttacksForLevel(level_int_t level) const;
/// @brief Returns a list of distinct attacks that can be learned through levelling up.
/// @return A list of distinct attacks that can be learned through levelling up.
const ArbUt::List<ArbUt::BorrowedPtr<const AttackData>>& GetDistinctLevelAttacks() const noexcept;
/// @brief Returns a random attack that can be learned.
/// @param rand A random number generator.
/// @return A random attack that can be learned.
virtual ArbUt::BorrowedPtr<const AttackData> GetRandomAttack(ArbUt::Random& rand) const;
};
}