Rework for BattleSide to use std::vector<bool> to deal with some edge cases
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2022-03-26 11:44:40 +01:00
parent acf6612eba
commit 24f18c775d
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 4 additions and 4 deletions

View File

@ -10,7 +10,7 @@ namespace CreatureLib::Battling {
u8 _creaturesPerSide; u8 _creaturesPerSide;
ArbUt::List<ArbUt::OptionalBorrowedPtr<Creature>> _creatures; ArbUt::List<ArbUt::OptionalBorrowedPtr<Creature>> _creatures;
ArbUt::List<std::shared_ptr<BaseTurnChoice>> _choices; ArbUt::List<std::shared_ptr<BaseTurnChoice>> _choices;
ArbUt::List<bool> _fillableSlots; std::vector<bool> _fillableSlots;
u8 _choicesSet = 0; u8 _choicesSet = 0;
ScriptSet _volatile; ScriptSet _volatile;
ArbUt::BorrowedPtr<Battle> _battle; ArbUt::BorrowedPtr<Battle> _battle;
@ -23,7 +23,7 @@ namespace CreatureLib::Battling {
for (size_t i = 0; i < creaturesPerSide; i++) { for (size_t i = 0; i < creaturesPerSide; i++) {
_creatures.Append(nullptr); _creatures.Append(nullptr);
_choices.Append(nullptr); _choices.Append(nullptr);
_fillableSlots.Append(true); _fillableSlots[i] = true;
} }
ResetChoices(); ResetChoices();
} }
@ -72,7 +72,7 @@ namespace CreatureLib::Battling {
if (!_creatures[i].HasValue()) if (!_creatures[i].HasValue())
continue; continue;
if (_creatures[i].GetValue() == creature) { if (_creatures[i].GetValue() == creature) {
_fillableSlots.At(i) = false; _fillableSlots.at(i) = false;
return; return;
} }
} }
@ -83,7 +83,7 @@ namespace CreatureLib::Battling {
if (!_creatures[i].HasValue()) if (!_creatures[i].HasValue())
continue; continue;
if (_creatures[i].GetValue() == creature) { if (_creatures[i].GetValue() == creature) {
return _fillableSlots.At(i); return _fillableSlots.at(i);
} }
} }
return false; return false;