12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #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);
- }
- }
- }
- Framework::Text QuestRequirementOpenDialog::getRequirementUIML(
- QuestRequirementStorage* zStorage)
- {
- Framework::Text result = "<questRequirement id=\"";
- result.append() << id << "\" fullfilled=\"" << zStorage->isFullfilled()
- << "\"><text>" << description
- << "</text></questRequirement>";
- 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";
- }
|