#ifndef ACTOR_H
#define ACTOR_H

#include <QObject>
#include <QString>
#include <QJsonObject>

#include "items/item.h"

class Actor : public Item
{
	Q_OBJECT
public:

	uint8_t triggerValue = 0;

protected:
	bool active = true;
	bool exausted = false;

	void performAction();
	void performValueAction(uint8_t value);

	virtual void enactValue(uint8_t value) override;

signals:

	void sigItemUpdate(ItemUpdateRequest update);

public slots:
	virtual void makeActive();
	virtual void makeInactive();
	virtual void setActive(uint8_t state);
	virtual void onItemUpdated(ItemUpdateRequest update);

public:
	Actor(QObject* parent = nullptr);
	virtual ~Actor();
	bool isExausted();

	virtual QString actionName();

	bool isActive();
	void setTriggerValue(uint8_t value);

	uint8_t getTriggerValue();

	static std::shared_ptr<Actor> createActor(const QString& type);

	virtual void store(QJsonObject& json) override;
	virtual void load(const QJsonObject& json, const bool preserve = false) override;
	static std::shared_ptr<Actor> loadActor(const QJsonObject& json);
};

#endif // ACTOR_H
