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

@@ -2,17 +2,20 @@
#define CREATURELIB_BATTLESIDE_HPP
#include <Arbutils/Assert.hpp>
#include <Arbutils/Collections/List.hpp>
#include <vector>
#include "../TurnChoices/BaseTurnChoice.hpp"
#include "Creature.hpp"
using namespace Arbutils::Collections;
namespace CreatureLib::Battling {
class BattleSide : public ScriptSource {
uint8_t _index;
uint8_t _creaturesPerSide;
std::vector<Creature*> _creatures;
std::vector<BaseTurnChoice*> _choices;
std::vector<bool> _fillableSlots;
List<Creature*> _creatures;
List<BaseTurnChoice*> _choices;
List<bool> _fillableSlots;
uint8_t _choicesSet = 0;
ScriptSet _volatile;
Battle* _battle;
@@ -33,7 +36,7 @@ namespace CreatureLib::Battling {
virtual ~BattleSide() = default;
[[nodiscard]] bool AllChoicesSet() const;
[[nodiscard]] const std::vector<BaseTurnChoice*>& GetChoices() const;
[[nodiscard]] const List<BaseTurnChoice*>& GetChoices() const;
[[nodiscard]] bool AllPossibleSlotsFilled() const;
@@ -45,13 +48,13 @@ namespace CreatureLib::Battling {
Creature* GetCreature(uint8_t index) const;
bool CreatureOnSide(const Creature* creature) const;
void GetActiveScripts(std::vector<ScriptWrapper>& scripts) final;
void GetActiveScripts(Arbutils::Collections::List<ScriptWrapper>& scripts) final;
const std::vector<Creature*>& GetCreatures() { return _creatures; }
const List<Creature*>& GetCreatures() { return _creatures; }
uint8_t GetSideIndex() { return _index; }
uint8_t GetCreatureIndex(Creature* c) {
for (size_t i = 0; i < _creatures.size(); i++) {
for (size_t i = 0; i < _creatures.Count(); i++) {
if (c == _creatures[i])
return i;
}
@@ -61,7 +64,7 @@ namespace CreatureLib::Battling {
void MarkSlotAsUnfillable(Creature* creature) {
for (uint8_t i = 0; i < _creaturesPerSide; i++) {
if (_creatures[i] == creature) {
_fillableSlots[i] = false;
_fillableSlots.At(i) = false;
return;
}
}