Improve performance for setting choices.
This commit is contained in:
parent
beac87f981
commit
19e1308f93
|
@ -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) {
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace CreatureLib::Battling{
|
|||
uint8_t _creaturesPerSide;
|
||||
std::vector<Creature*> _creatures;
|
||||
std::vector<const BaseTurnChoice*> _choices;
|
||||
uint8_t _choicesSet = 0;
|
||||
public:
|
||||
BattleSide(uint8_t creaturesPerSide)
|
||||
: _creaturesPerSide(creaturesPerSide), _creatures(creaturesPerSide), _choices(creaturesPerSide)
|
||||
|
|
Loading…
Reference in New Issue