Make ChoiceQueue use smart pointers.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
#ifndef CREATURELIB_CHOICEQUEUE_HPP
|
||||
#define CREATURELIB_CHOICEQUEUE_HPP
|
||||
|
||||
#include <Arbutils/Memory/UniquePtrList.hpp>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include "../TurnChoices/BaseTurnChoice.hpp"
|
||||
|
||||
namespace CreatureLib::Battling {
|
||||
class ChoiceQueue {
|
||||
std::vector<BaseTurnChoice*> _queue;
|
||||
ArbUt::UniquePtrList<BaseTurnChoice> _queue;
|
||||
size_t _current = 0;
|
||||
|
||||
public:
|
||||
@@ -15,17 +16,17 @@ namespace CreatureLib::Battling {
|
||||
|
||||
explicit ChoiceQueue(std::vector<BaseTurnChoice*> queue) : _queue(std::move(queue)) {}
|
||||
|
||||
BaseTurnChoice* Dequeue() {
|
||||
ArbUt::BorrowedPtr<BaseTurnChoice> Dequeue() {
|
||||
auto b = _queue[_current];
|
||||
_current++;
|
||||
return b;
|
||||
}
|
||||
|
||||
BaseTurnChoice* Peek() { return _queue[_current]; }
|
||||
ArbUt::BorrowedPtr<BaseTurnChoice> Peek() { return _queue[_current]; }
|
||||
|
||||
[[nodiscard]] bool HasNext() const { return _current < _queue.size(); }
|
||||
[[nodiscard]] bool HasNext() const { return _current < _queue.Count(); }
|
||||
|
||||
std::vector<BaseTurnChoice*>& GetInnerQueue() { return _queue; }
|
||||
ArbUt::UniquePtrList<BaseTurnChoice>& GetInnerQueue() { return _queue; }
|
||||
|
||||
bool MoveCreatureChoiceNext(Creature* creature);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user