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:
@@ -8,25 +8,21 @@
|
||||
|
||||
namespace CreatureLib::Battling {
|
||||
class ChoiceQueue {
|
||||
ArbUt::UniquePtrList<BaseTurnChoice> _queue;
|
||||
std::vector<std::shared_ptr<BaseTurnChoice>> _queue;
|
||||
size_t _current = 0;
|
||||
|
||||
public:
|
||||
bool HasCompletedQueue = false;
|
||||
|
||||
explicit ChoiceQueue(std::vector<BaseTurnChoice*> queue) : _queue(std::move(queue)) {}
|
||||
explicit ChoiceQueue(std::vector<std::shared_ptr<BaseTurnChoice>> queue) : _queue(std::move(queue)) {}
|
||||
|
||||
ArbUt::BorrowedPtr<BaseTurnChoice> Dequeue() {
|
||||
auto b = _queue[_current];
|
||||
_current++;
|
||||
return b;
|
||||
}
|
||||
const std::shared_ptr<BaseTurnChoice>& Dequeue() { return _queue[_current++]; }
|
||||
|
||||
ArbUt::BorrowedPtr<BaseTurnChoice> Peek() { return _queue[_current]; }
|
||||
const std::shared_ptr<BaseTurnChoice>& Peek() { return _queue[_current]; }
|
||||
|
||||
[[nodiscard]] bool HasNext() const { return _current < _queue.Count(); }
|
||||
[[nodiscard]] bool HasNext() const { return _current < _queue.size(); }
|
||||
|
||||
ArbUt::UniquePtrList<BaseTurnChoice>& GetInnerQueue() { return _queue; }
|
||||
const std::vector<std::shared_ptr<BaseTurnChoice>>& GetInnerQueue() { return _queue; }
|
||||
|
||||
bool MoveCreatureChoiceNext(Creature* creature);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user