Make the last couple classes use smart pointers.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-06-02 18:30:37 +02:00
parent 7262ae9e8b
commit 657d646fda
10 changed files with 33 additions and 25 deletions

View File

@@ -9,16 +9,16 @@ namespace CreatureLib::Battling {
class Creature;
class BaseTurnChoice : public ScriptSource {
Creature* _user;
ArbUt::BorrowedPtr<Creature> _user;
int32_t _randomValue;
protected:
BaseTurnChoice(Creature* user) noexcept : _user(user){};
BaseTurnChoice(ArbUt::BorrowedPtr<Creature> user) noexcept : _user(user){};
public:
virtual ~BaseTurnChoice() = default;
[[nodiscard]] virtual TurnChoiceKind GetKind() const noexcept = 0;
[[nodiscard]] inline Creature* GetUser() const noexcept { return _user; }
[[nodiscard]] inline const ArbUt::BorrowedPtr<Creature>& GetUser() const noexcept { return _user; }
inline void __SetRandomValue(int32_t val) noexcept { _randomValue = val; }
inline int32_t __GetRandomValue() const noexcept { return _randomValue; }

View File

@@ -7,7 +7,7 @@
namespace CreatureLib::Battling {
class FleeTurnChoice : public BaseTurnChoice {
public:
FleeTurnChoice(Creature* user) : BaseTurnChoice(user) {}
FleeTurnChoice(ArbUt::BorrowedPtr<Creature> user) : BaseTurnChoice(user) {}
TurnChoiceKind GetKind() const noexcept override { return TurnChoiceKind ::Flee; }
size_t ScriptCount() const override { return GetUser()->ScriptCount(); }

View File

@@ -6,7 +6,7 @@
namespace CreatureLib::Battling {
class PassTurnChoice : public BaseTurnChoice {
public:
PassTurnChoice(Creature* c) : BaseTurnChoice(c) {}
PassTurnChoice(ArbUt::BorrowedPtr<Creature> c) : BaseTurnChoice(c) {}
TurnChoiceKind GetKind() const noexcept override { return TurnChoiceKind ::Pass; }
size_t ScriptCount() const override { return GetUser()->ScriptCount(); }

View File

@@ -4,15 +4,15 @@
#include "BaseTurnChoice.hpp"
namespace CreatureLib::Battling {
class SwitchTurnChoice : public BaseTurnChoice {
Creature* _newCreature;
ArbUt::BorrowedPtr<Creature> _newCreature;
public:
SwitchTurnChoice(Creature* user, Creature* newCreature) noexcept
SwitchTurnChoice(ArbUt::BorrowedPtr<Creature> user, ArbUt::BorrowedPtr<Creature> newCreature) noexcept
: BaseTurnChoice(user), _newCreature(newCreature) {}
TurnChoiceKind GetKind() const noexcept final { return TurnChoiceKind::Switch; }
inline Creature* GetNewCreature() const noexcept { return _newCreature; }
inline const ArbUt::BorrowedPtr<Creature>& GetNewCreature() const noexcept { return _newCreature; }
size_t ScriptCount() const override { return GetUser()->ScriptCount(); }
protected: