diff --git a/src/Battling/Models/Battle.cpp b/src/Battling/Models/Battle.cpp index 47cd947..9848db6 100644 --- a/src/Battling/Models/Battle.cpp +++ b/src/Battling/Models/Battle.cpp @@ -18,8 +18,9 @@ bool Battle::CanUse(const ArbUt::BorrowedPtr& choice) { bool Battle::TrySetChoice(BaseTurnChoice* choice) { EnsureNotNull(choice) - if (!CanUse(choice)) + if (!CanUse(choice)) { return false; + } Ensure(choice->GetUser()->GetBattleSide().HasValue()) choice->GetUser()->GetBattleSide().GetValue()->SetChoice(choice); CheckChoicesSetAndRun(); @@ -28,12 +29,12 @@ bool Battle::TrySetChoice(BaseTurnChoice* choice) { void Battle::CheckChoicesSetAndRun() { try { - for (auto side : _sides) { + for (auto* side : _sides) { if (!side->AllChoicesSet()) { return; } } - for (auto side : _sides) { + for (auto* side : _sides) { if (!side->AllPossibleSlotsFilled()) { return; } @@ -48,7 +49,7 @@ void Battle::CheckChoicesSetAndRun() { auto choices = std::vector>(_numberOfSides * _creaturesPerSide); auto i = 0; try { - for (auto side : _sides) { + for (auto* side : _sides) { for (auto choice : side->GetChoices()) { EnsureNotNull(choice) if (choice->GetKind() == TurnChoiceKind::Attack) { diff --git a/src/Battling/Models/BattleSide.cpp b/src/Battling/Models/BattleSide.cpp index da48384..2846e45 100644 --- a/src/Battling/Models/BattleSide.cpp +++ b/src/Battling/Models/BattleSide.cpp @@ -11,8 +11,9 @@ bool BattleSide::AllPossibleSlotsFilled() const { for (size_t i = 0; i < _creatures.Count(); i++) { auto c = _creatures[i]; if (!c.HasValue() || c.GetValue()->IsFainted()) { - if (_battle->CanSlotBeFilled(_index, i)) + if (_battle->CanSlotBeFilled(_index, i)) { return false; + } } } } catch (const std::exception& e) { diff --git a/src/Battling/Models/Creature.cpp b/src/Battling/Models/Creature.cpp index 1a63b3c..4812dbc 100644 --- a/src/Battling/Models/Creature.cpp +++ b/src/Battling/Models/Creature.cpp @@ -103,6 +103,7 @@ namespace CreatureLib::Battling { void Creature::ClearBattleData() noexcept { _battle = nullptr; _side = nullptr; + _seenOpponents = {}; } bool Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmount) { @@ -135,10 +136,6 @@ namespace CreatureLib::Battling { this->_boostedStats.SetStat(stat, s); } - const ArbUt::OptionalBorrowedPtr& Creature::GetBattle() const { return _battle; } - - const ArbUt::OptionalBorrowedPtr& Creature::GetBattleSide() const { return _side; } - bool Creature::IsFainted() const noexcept { return this->_currentHealth == 0; } void Creature::OnFaint() { diff --git a/src/Battling/Models/Creature.hpp b/src/Battling/Models/Creature.hpp index d7ff076..4bbc4e8 100644 --- a/src/Battling/Models/Creature.hpp +++ b/src/Battling/Models/Creature.hpp @@ -106,8 +106,8 @@ namespace CreatureLib::Battling { void SetBattleData(const ArbUt::BorrowedPtr& battle, const ArbUt::BorrowedPtr& side); void ClearBattleData() noexcept; - const ArbUt::OptionalBorrowedPtr& GetBattle() const; - const ArbUt::OptionalBorrowedPtr& GetBattleSide() const; + inline const ArbUt::OptionalBorrowedPtr& GetBattle() const { return _battle; } + inline const ArbUt::OptionalBorrowedPtr& GetBattleSide() const { return _side; } inline void SetOnBattleField(bool value) { _onBattleField = value; } inline bool IsOnBattleField() const { return _onBattleField; }