Initial support for setting battle choices.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -1 +1,35 @@
|
||||
#include "BattleSide.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
bool BattleSide::AllChoicesSet() const {
|
||||
for (uint8_t i = 0; i < _creaturesPerSide; i++){
|
||||
if (_choices[i] == nullptr){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void BattleSide::ResetChoices() {
|
||||
for (uint8_t i = 0; i < _creaturesPerSide; i++){
|
||||
_choices[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<const BaseTurnChoice *>& BattleSide::GetChoices() const{
|
||||
return _choices;
|
||||
}
|
||||
|
||||
void BattleSide::SetChoice(const BaseTurnChoice *choice) {
|
||||
auto find = std::find(_creatures.begin(), _creatures.end(), choice->GetUser());
|
||||
if (find ==_creatures.end())
|
||||
throw "User not found";
|
||||
uint8_t index = std::distance(_creatures.begin(),find);
|
||||
_choices[index] = choice;
|
||||
}
|
||||
|
||||
void BattleSide::SetCreature(Creature *creature, uint8_t index) {
|
||||
_creatures[index] = creature;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user