#include "QuestRequirement.h" #include "Quest.h" QuestRequirement::QuestRequirement( Framework::Text id, Framework::Text description) : ReferenceCounter(), id(id), description(description) {} const Framework::Text& QuestRequirement::getRequirementId() const { return id; } const Framework::Text& QuestRequirement::getDescription() const { return description; } QuestRequirementOpenDialog::QuestRequirementOpenDialog( Framework::Text id, Framework::Text description, Framework::Text dialogId) : QuestRequirement(id, description), dialogId(dialogId) {} void QuestRequirementOpenDialog::processEvent( QuestEvent* zEvent, QuestRequirementStorage* zStorage) { QuestEventOpenDialog* event = dynamic_cast(zEvent); if (event) { if (event->getDialogId() == dialogId) { zStorage->setFullfilled(true); } } } Framework::Text QuestRequirementOpenDialog::getRequirementUIML( QuestRequirementStorage* zStorage) { Framework::Text result = "isFullfilled() << "\">" << description << ""; return result; } QuestRequirementOpenDialogType::QuestRequirementOpenDialogType() : SubTypeFactory() {} QuestRequirementOpenDialog* QuestRequirementOpenDialogType::fromJson( Framework::JSON::JSONObject* zJson) const { return new QuestRequirementOpenDialog( zJson->zValue("id")->asString()->getString(), zJson->zValue("description")->asString()->getString(), zJson->zValue("dialogId")->asString()->getString()); } Framework::JSON::JSONObject* QuestRequirementOpenDialogType::toJson( QuestRequirementOpenDialog* zObject) const { Framework::JSON::JSONObject* json = new Framework::JSON::JSONObject(); json->addValue( "id", new Framework::JSON::JSONString(zObject->getRequirementId())); json->addValue("description", new Framework::JSON::JSONString(zObject->getDescription())); json->addValue( "dialogId", new Framework::JSON::JSONString(zObject->dialogId)); return json; } Framework::JSON::Validator::JSONValidator* QuestRequirementOpenDialogType::getValidator( Framework::JSON::Validator::ObjectValidationBuilder< Framework::JSON::Validator::JSONValidator>* builder) const { return builder->withRequiredString("id") ->finishString() ->withRequiredString("description") ->finishString() ->withRequiredString("dialogId") ->finishString() ->finishObject(); } Framework::Text QuestRequirementOpenDialogType::getTypeToken() const { return "open_dialog"; }