Use smart pointers for BattleSide.
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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user