Replace most collections with Arbutils collections for more safety.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-03-22 19:21:40 +01:00
parent f190121e74
commit 27288563cd
40 changed files with 234 additions and 226 deletions

View File

@@ -1,6 +1,7 @@
#ifndef CREATURELIB_BATTLECREATURE_HPP
#define CREATURELIB_BATTLECREATURE_HPP
#include <Arbutils/Collections/List.hpp>
#include "../../Library/CreatureData/CreatureSpecies.hpp"
#include "../../Library/Items/Item.hpp"
#include "../ScriptHandling/ScriptAggregator.hpp"
@@ -9,6 +10,8 @@
#include "DamageSource.hpp"
#include "LearnedAttack.hpp"
using namespace Arbutils::Collections;
namespace CreatureLib::Battling {
// Forward declare battle class
class Battle;
@@ -49,7 +52,7 @@ namespace CreatureLib::Battling {
ConstString _overridenTalentName = ""_cnc;
std::unordered_set<Creature*> _seenOpponents = {};
std::vector<LearnedAttack*> _attacks;
List<LearnedAttack*> _attacks;
Script* _status = nullptr;
ScriptSet _volatile = {};
@@ -61,7 +64,7 @@ namespace CreatureLib::Battling {
Creature(const BattleLibrary* library, const Library::CreatureSpecies* species,
const Library::SpeciesVariant* variant, uint8_t level, uint32_t experience, uint32_t uid,
Library::Gender gender, uint8_t coloring, const Library::Item* heldItem, std::string nickname,
const Library::TalentIndex& talent, std::vector<LearnedAttack*> attacks);
const Library::TalentIndex& talent, List<LearnedAttack*> attacks);
virtual ~Creature() {
for (auto attack : _attacks) {
@@ -105,7 +108,7 @@ namespace CreatureLib::Battling {
const ConstString& GetActiveTalent() const;
[[nodiscard]] bool IsFainted() const noexcept;
[[nodiscard]] const std::vector<uint8_t>& GetTypes() const noexcept;
[[nodiscard]] const List<uint8_t>& GetTypes() const noexcept;
[[nodiscard]] bool HasType(uint8_t type) const noexcept;
uint32_t GetMaxHealth() const noexcept { return _boostedStats.GetHealth(); }
@@ -118,7 +121,7 @@ namespace CreatureLib::Battling {
void MarkOpponentAsSeen(Creature* creature) { _seenOpponents.insert(creature); }
const std::unordered_set<Creature*>& GetSeenOpponents() const { return _seenOpponents; }
void GetActiveScripts(std::vector<ScriptWrapper>& scripts) override;
void GetActiveScripts(Arbutils::Collections::List<ScriptWrapper>& scripts) override;
void ClearVolatileScripts();
void AddVolatileScript(const ConstString& name);
void AddVolatileScript(Script* script);
@@ -126,7 +129,7 @@ namespace CreatureLib::Battling {
void RemoveVolatileScript(Script* script);
bool HasVolatileScript(const ConstString& name) const;
std::vector<LearnedAttack*>& GetAttacks() { return _attacks; }
List<LearnedAttack*>& GetAttacks() { return _attacks; }
const Library::CreatureSpecies* GetDisplaySpecies() const;
const Library::SpeciesVariant* GetDisplayVariant() const;