123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #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<QuestEventOpenDialog*>(zEvent);
- if (event)
- {
- if (event->getDialogId() == dialogId)
- {
- zStorage->setFullfilled(true);
- }
- }
- }
- 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";
- }
|