Add ready items
parent
5030b71e3f
commit
f7517e0abd
@ -0,0 +1,20 @@
|
||||
#include "changeinteractionmessagemodificator.h"
|
||||
#include "location.h"
|
||||
|
||||
ChangeInteractionMessageModificator::ChangeInteractionMessageModificator()
|
||||
{}
|
||||
|
||||
ChangeInteractionMessageModificator::~ChangeInteractionMessageModificator()
|
||||
{}
|
||||
|
||||
void ChangeInteractionMessageModificator::run() const
|
||||
{
|
||||
_location->setInteractionMessage(_new_message);
|
||||
}
|
||||
|
||||
void ChangeInteractionMessageModificator::setDependentObjects(const std::shared_ptr<Location> &location,
|
||||
const std::string &new_message)
|
||||
{
|
||||
_location = location;
|
||||
_new_message = new_message;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
#ifndef CHANGEINTERACTIONMESSAGEMODIFICATOR_H
|
||||
#define CHANGEINTERACTIONMESSAGEMODIFICATOR_H
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "modificator.h"
|
||||
|
||||
class Location;
|
||||
|
||||
class ChangeInteractionMessageModificator : public Modificator
|
||||
{
|
||||
public:
|
||||
explicit ChangeInteractionMessageModificator();
|
||||
virtual ~ChangeInteractionMessageModificator() override;
|
||||
|
||||
virtual void run() const override;
|
||||
|
||||
void setDependentObjects(const std::shared_ptr<Location>& location,
|
||||
const std::string& new_message);
|
||||
|
||||
private:
|
||||
std::shared_ptr<Location> _location;
|
||||
std::string _new_message;
|
||||
};
|
||||
|
||||
#endif // CHANGEINTERACTIONMESSAGEMODIFICATOR_H
|
@ -0,0 +1,20 @@
|
||||
#include "readyitemrequiredpolicy.h"
|
||||
#include "actor.h"
|
||||
|
||||
ReadyItemRequiredPolicy::ReadyItemRequiredPolicy(const std::string& satisfaction, const std::string& dissatisfaction) :
|
||||
Policy(satisfaction, dissatisfaction)
|
||||
{}
|
||||
|
||||
ReadyItemRequiredPolicy::~ReadyItemRequiredPolicy()
|
||||
{}
|
||||
|
||||
Policy::CheckResult ReadyItemRequiredPolicy::check(const std::shared_ptr<Actor>& actor) const
|
||||
{
|
||||
bool success = actor->isItemReady(_item);
|
||||
return composeMessageFromResult(success);
|
||||
}
|
||||
|
||||
void ReadyItemRequiredPolicy::setRequiredReadyItem(const std::shared_ptr<Item> &item)
|
||||
{
|
||||
_item = item;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
#ifndef READYITEMREQUIREDPOLICY_H
|
||||
#define READYITEMREQUIREDPOLICY_H
|
||||
|
||||
#include "policy.h"
|
||||
|
||||
class Item;
|
||||
|
||||
class ReadyItemRequiredPolicy : public Policy
|
||||
{
|
||||
public:
|
||||
explicit ReadyItemRequiredPolicy(const std::string& satisfaction, const std::string& dissatisfaction);
|
||||
virtual ~ReadyItemRequiredPolicy() override;
|
||||
|
||||
virtual Policy::CheckResult check(const std::shared_ptr<Actor>& actor) const override;
|
||||
|
||||
void setRequiredReadyItem(const std::shared_ptr<Item>& item);
|
||||
|
||||
private:
|
||||
std::shared_ptr<Item> _item;
|
||||
};
|
||||
|
||||
#endif // READYITEMREQUIREDPOLICY_H
|
Loading…
Reference in New Issue