2019-10-31 11:02:23 +00:00
|
|
|
#ifndef CREATURELIB_CHOICEQUEUE_HPP
|
|
|
|
#define CREATURELIB_CHOICEQUEUE_HPP
|
|
|
|
|
2020-05-31 16:00:39 +00:00
|
|
|
#include <Arbutils/Memory/UniquePtrList.hpp>
|
2019-11-06 17:04:00 +00:00
|
|
|
#include <utility>
|
2019-10-31 11:02:23 +00:00
|
|
|
#include <vector>
|
|
|
|
#include "../TurnChoices/BaseTurnChoice.hpp"
|
|
|
|
|
2019-11-28 11:55:22 +00:00
|
|
|
namespace CreatureLib::Battling {
|
2019-10-31 11:02:23 +00:00
|
|
|
class ChoiceQueue {
|
2020-05-31 16:00:39 +00:00
|
|
|
ArbUt::UniquePtrList<BaseTurnChoice> _queue;
|
2019-10-31 11:02:23 +00:00
|
|
|
size_t _current = 0;
|
2019-11-28 11:55:22 +00:00
|
|
|
|
2019-10-31 11:02:23 +00:00
|
|
|
public:
|
2019-11-06 17:04:00 +00:00
|
|
|
bool HasCompletedQueue = false;
|
|
|
|
|
2019-11-28 11:55:22 +00:00
|
|
|
explicit ChoiceQueue(std::vector<BaseTurnChoice*> queue) : _queue(std::move(queue)) {}
|
2019-10-31 11:02:23 +00:00
|
|
|
|
2020-05-31 16:00:39 +00:00
|
|
|
ArbUt::BorrowedPtr<BaseTurnChoice> Dequeue() {
|
2019-10-31 11:02:23 +00:00
|
|
|
auto b = _queue[_current];
|
|
|
|
_current++;
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
2020-05-31 16:00:39 +00:00
|
|
|
ArbUt::BorrowedPtr<BaseTurnChoice> Peek() { return _queue[_current]; }
|
2020-02-22 13:16:38 +00:00
|
|
|
|
2020-05-31 16:00:39 +00:00
|
|
|
[[nodiscard]] bool HasNext() const { return _current < _queue.Count(); }
|
2019-11-10 13:32:05 +00:00
|
|
|
|
2020-05-31 16:00:39 +00:00
|
|
|
ArbUt::UniquePtrList<BaseTurnChoice>& GetInnerQueue() { return _queue; }
|
2020-02-22 13:16:38 +00:00
|
|
|
|
|
|
|
bool MoveCreatureChoiceNext(Creature* creature);
|
2019-10-31 11:02:23 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-11-28 11:55:22 +00:00
|
|
|
#endif // CREATURELIB_CHOICEQUEUE_HPP
|