Adds support for History data, allowing us to store specific interesting occurrences in the data flow, and recall them later.
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
2020-08-14 15:18:00 +02:00
parent 939fee3f50
commit cb4765e0cc
12 changed files with 150 additions and 19 deletions

View File

@@ -0,0 +1,24 @@
#ifndef CREATURELIB_ATTACKUSEHISTORY_HPP
#define CREATURELIB_ATTACKUSEHISTORY_HPP
#include "../../Models/ExecutingAttack.hpp"
#include "HistoryElement.hpp"
namespace CreatureLib::Battling {
class AttackUseHistory : public HistoryElement {
std::unique_ptr<const ExecutingAttack> _attack;
protected:
void Clear() override {
_attack.reset();
HistoryElement::Clear();
}
public:
AttackUseHistory(const ExecutingAttack* attack) : _attack(attack) {}
HistoryElementKind GetKind() const noexcept override { return HistoryElementKind::AttackUse; }
ArbUt::BorrowedPtr<const ExecutingAttack> GetAttack() { return _attack; }
};
}
#endif // CREATURELIB_ATTACKUSEHISTORY_HPP

View File

@@ -0,0 +1,25 @@
#ifndef CREATURELIB_HISTORYELEMENT_HPP
#define CREATURELIB_HISTORYELEMENT_HPP
#include <Arbutils/Memory/BorrowedPtr.hpp>
#include "../HistoryElementKind.hpp"
namespace CreatureLib::Battling {
class HistoryElement {
friend class HistoryHolder;
HistoryElement* _previous;
protected:
virtual void Clear() {
if (_previous != nullptr) {
_previous->Clear();
}
}
public:
virtual HistoryElementKind GetKind() const noexcept = 0;
ArbUt::BorrowedPtr<const HistoryElement> GetPrevious() const noexcept { return _previous; }
};
}
#endif // CREATURELIB_HISTORYELEMENT_HPP