slumber-quest/controllers/controller.cpp

35 lines
811 B
C++
Raw Permalink Normal View History

2021-05-07 21:36:26 -04:00
#include "controller.h"
#include "policy.h"
#include "modificator.h"
2021-05-07 21:36:26 -04:00
#include <algorithm>
Controller::Controller(Initializer&& initializer) :
_keywords(initializer.keywords),
_interaction_message(initializer.message),
_validator(nullptr)
2021-05-07 21:36:26 -04:00
{}
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
2021-05-07 21:36:26 -04:00
{
for (const auto& modificator : _modificators)
modificator->run();
2021-05-07 21:36:26 -04:00
}
void Controller::setValidator(const std::shared_ptr<Validator>& validator)
2021-05-07 21:36:26 -04:00
{
_validator = validator;
}
2021-05-07 21:36:26 -04:00
void Controller::setModificators(const std::list<std::shared_ptr<Modificator>>& modificators)
{
_modificators = modificators;
2021-05-07 21:36:26 -04:00
}