slumber-quest/controllers/controller.cpp

35 lines
811 B
C++

#include "controller.h"
#include "policy.h"
#include "modificator.h"
#include <algorithm>
Controller::Controller(Initializer&& initializer) :
_keywords(initializer.keywords),
_interaction_message(initializer.message),
_validator(nullptr)
{}
Controller::~Controller()
{}
bool Controller::validateInput(const std::string &input_word) const
{
return std::find(_keywords.begin(), _keywords.end(), input_word) != _keywords.end();
}
void Controller::runModificators() const
{
for (const auto& modificator : _modificators)
modificator->run();
}
void Controller::setValidator(const std::shared_ptr<Validator>& validator)
{
_validator = validator;
}
void Controller::setModificators(const std::list<std::shared_ptr<Modificator>>& modificators)
{
_modificators = modificators;
}