Use smart pointers for BattleSide.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2020-06-02 13:06:24 +02:00
parent 49e8ff055d
commit f898698f49
20 changed files with 86 additions and 107 deletions

View File

@@ -39,13 +39,13 @@ void Battle::CheckChoicesSetAndRun() {
}
}
auto choices = std::vector<BaseTurnChoice*>(_numberOfSides * _creaturesPerSide);
auto choices = std::vector<std::shared_ptr<BaseTurnChoice>>(_numberOfSides * _creaturesPerSide);
auto i = 0;
for (auto side : _sides) {
for (BaseTurnChoice* choice : side->GetChoices()) {
for (const auto& choice : side->GetChoices()) {
AssertNotNull(choice)
if (choice->GetKind() == TurnChoiceKind::Attack) {
auto attack = (dynamic_cast<AttackTurnChoice*>((choice)))->GetAttack();
auto attack = ((AttackTurnChoice*)choice.get())->GetAttack();
uint8_t uses = 1;
// HOOK: change number of uses needed.
if (attack->GetRemainingUses() < uses) {
@@ -73,7 +73,7 @@ ArbUt::BorrowedPtr<ChoiceQueue> Battle::GetCurrentTurnQueue() const noexcept { r
BattleRandom* Battle::GetRandom() noexcept { return &_random; }
bool Battle::CreatureInField(const Creature* creature) const {
bool Battle::CreatureInField(ArbUt::BorrowedPtr<Creature> creature) const {
AssertNotNull(creature)
for (auto s : _sides) {
if (s->CreatureOnSide(creature))