Make ChoiceQueue use smart pointers.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-05-31 18:00:39 +02:00
parent ff181204ae
commit 29cb4eac37
8 changed files with 32 additions and 35 deletions

View File

@@ -9,11 +9,11 @@ using namespace CreatureLib::Battling;
const ArbUt::BorrowedPtr<const BattleLibrary>& Battle::GetLibrary() const noexcept { return _library; }
bool Battle::CanUse(const BaseTurnChoice* choice) {
bool Battle::CanUse(const ArbUt::BorrowedPtr<BaseTurnChoice>& choice) {
AssertNotNull(choice)
if (choice->GetKind() == TurnChoiceKind::Attack) {
// HOOK: change number of uses needed.
return dynamic_cast<const AttackTurnChoice*>(choice)->GetAttack()->GetRemainingUses() >= 1;
return choice.ForceAs<AttackTurnChoice>()->GetAttack()->GetRemainingUses() >= 1;
}
return true;
}

View File

@@ -59,7 +59,7 @@ namespace CreatureLib::Battling {
[[nodiscard]] const ArbUt::BorrowedPtr<const BattleLibrary>& GetLibrary() const noexcept;
[[nodiscard]] uint32_t GetCurrentTurn() const noexcept { return _currentTurn; }
virtual bool CanUse(const BaseTurnChoice* choice);
virtual bool CanUse(const ArbUt::BorrowedPtr<BaseTurnChoice>& choice);
virtual bool TrySetChoice(BaseTurnChoice* choice);
bool CanFlee() const noexcept { return _canFlee; }