diff --git a/src/Battling/Models/BattleSide.cpp b/src/Battling/Models/BattleSide.cpp index 162b0a7..a3da100 100644 --- a/src/Battling/Models/BattleSide.cpp +++ b/src/Battling/Models/BattleSide.cpp @@ -5,15 +5,11 @@ using namespace CreatureLib::Battling; bool BattleSide::AllChoicesSet() const { - for (uint8_t i = 0; i < _creaturesPerSide; i++){ - if (_choices[i] == nullptr){ - return false; - } - } - return true; + return _choicesSet == _creaturesPerSide; } void BattleSide::ResetChoices() { + _choicesSet = 0; for (uint8_t i = 0; i < _creaturesPerSide; i++){ _choices[i] = nullptr; } @@ -29,6 +25,7 @@ void BattleSide::SetChoice(const BaseTurnChoice *choice) { throw CreatureException("User not found"); uint8_t index = std::distance(_creatures.begin(),find); _choices[index] = choice; + _choicesSet++; } void BattleSide::SetCreature(Creature *creature, uint8_t index) { diff --git a/src/Battling/Models/BattleSide.hpp b/src/Battling/Models/BattleSide.hpp index cec2dcb..d2be26a 100644 --- a/src/Battling/Models/BattleSide.hpp +++ b/src/Battling/Models/BattleSide.hpp @@ -10,6 +10,7 @@ namespace CreatureLib::Battling{ uint8_t _creaturesPerSide; std::vector _creatures; std::vector _choices; + uint8_t _choicesSet = 0; public: BattleSide(uint8_t creaturesPerSide) : _creaturesPerSide(creaturesPerSide), _creatures(creaturesPerSide), _choices(creaturesPerSide)