|
@@ -1,5 +1,7 @@
|
|
|
#include "Quest.h"
|
|
|
|
|
|
+#include "Game.h"
|
|
|
+
|
|
|
QuestRequirementStorage::QuestRequirementStorage(Framework::Text requirementId)
|
|
|
: ReferenceCounter(),
|
|
|
requirementId(requirementId),
|
|
@@ -67,7 +69,7 @@ QuestRequirementStorage* QuestRequirementStorageType::fromJson(
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-Framework::JSON::JSONValue* QuestRequirementStorageType::toJSON(
|
|
|
+Framework::JSON::JSONValue* QuestRequirementStorageType::toJson(
|
|
|
QuestRequirementStorage* zObject) const
|
|
|
{
|
|
|
Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
|
|
@@ -164,7 +166,7 @@ QuestStorage* QuestStorageType::fromJson(
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-Framework::JSON::JSONValue* QuestStorageType::toJSON(
|
|
|
+Framework::JSON::JSONValue* QuestStorageType::toJson(
|
|
|
QuestStorage* zObject) const
|
|
|
{
|
|
|
Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
|
|
@@ -178,7 +180,7 @@ Framework::JSON::JSONValue* QuestStorageType::toJSON(
|
|
|
for (QuestRequirementStorage* storage : zObject->requirements)
|
|
|
{
|
|
|
rewardsArray->addValue(
|
|
|
- Game::INSTANCE->zTypeRegistry()->toJSON(storage));
|
|
|
+ Game::INSTANCE->zTypeRegistry()->toJson(storage));
|
|
|
}
|
|
|
result->addValue("requirements", rewardsArray);
|
|
|
return result;
|
|
@@ -247,7 +249,7 @@ QuestParty* QuestParty::clone() const
|
|
|
for (QuestStorage* storage : questStorage)
|
|
|
{
|
|
|
Framework::JSON::JSONValue* value
|
|
|
- = Game::INSTANCE->zTypeRegistry()->toJSON(storage);
|
|
|
+ = Game::INSTANCE->zTypeRegistry()->toJson(storage);
|
|
|
result->questStorage.add(
|
|
|
Game::INSTANCE->zTypeRegistry()->fromJson<QuestStorage>(value));
|
|
|
value->release();
|
|
@@ -259,8 +261,7 @@ QuestPartyType::QuestPartyType()
|
|
|
: TypeFactory<QuestParty>()
|
|
|
{}
|
|
|
|
|
|
-QuestParty* QuestPartyType::fromJson(
|
|
|
- Framework::JSON::JSONValue* zJson) const
|
|
|
+QuestParty* QuestPartyType::fromJson(Framework::JSON::JSONValue* zJson) const
|
|
|
{
|
|
|
QuestParty* result = new QuestParty();
|
|
|
Framework::JSON::JSONArray* membersArray
|
|
@@ -281,8 +282,7 @@ QuestParty* QuestPartyType::fromJson(
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-Framework::JSON::JSONValue* QuestPartyType::toJSON(
|
|
|
- QuestParty* zObject) const
|
|
|
+Framework::JSON::JSONValue* QuestPartyType::toJson(QuestParty* zObject) const
|
|
|
{
|
|
|
Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
|
|
|
Framework::JSON::JSONArray* membersArray = new Framework::JSON::JSONArray();
|
|
@@ -296,7 +296,7 @@ Framework::JSON::JSONValue* QuestPartyType::toJSON(
|
|
|
for (QuestStorage* storage : zObject->questStorage)
|
|
|
{
|
|
|
storagesArray->addValue(
|
|
|
- Game::INSTANCE->zTypeRegistry()->toJSON(storage));
|
|
|
+ Game::INSTANCE->zTypeRegistry()->toJson(storage));
|
|
|
}
|
|
|
result->addValue("quests", storagesArray);
|
|
|
return result;
|
|
@@ -359,8 +359,8 @@ void Quest::giveReward(
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- rewards.z(choice)->giveReward(zTargetEntity);
|
|
|
zStorage->setQuestRewarded(1);
|
|
|
+ rewards.z(choice)->giveReward(zTargetEntity);
|
|
|
}
|
|
|
|
|
|
const Framework::Text& Quest::getQuestId() const
|
|
@@ -378,6 +378,8 @@ Quest* QuestType::fromJson(Framework::JSON::JSONValue* zJson) const
|
|
|
zJson->asObject()->zValue("questId")->asString()->getString());
|
|
|
result->questName
|
|
|
= zJson->asObject()->zValue("questName")->asString()->getString();
|
|
|
+ result->description
|
|
|
+ = zJson->asObject()->zValue("description")->asString()->getString();
|
|
|
Framework::JSON::JSONArray* requiredQuestIdsArray
|
|
|
= zJson->asObject()->zValue("requiredQuestIds")->asArray();
|
|
|
for (int i = 0; i < requiredQuestIdsArray->getLength(); i++)
|
|
@@ -399,18 +401,20 @@ Quest* QuestType::fromJson(Framework::JSON::JSONValue* zJson) const
|
|
|
{
|
|
|
result->rewards.add(
|
|
|
Game::INSTANCE->zTypeRegistry()->fromJson<QuestReward>(
|
|
|
- requirementsArray->zValue(i)));
|
|
|
+ rewardsArray->zValue(i)));
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-Framework::JSON::JSONValue* QuestType::toJSON(Quest* zObject) const
|
|
|
+Framework::JSON::JSONValue* QuestType::toJson(Quest* zObject) const
|
|
|
{
|
|
|
Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
|
|
|
result->addValue(
|
|
|
"questId", new Framework::JSON::JSONString(zObject->questId));
|
|
|
result->addValue(
|
|
|
"questName", new Framework::JSON::JSONString(zObject->questName));
|
|
|
+ result->addValue(
|
|
|
+ "description", new Framework::JSON::JSONString(zObject->description));
|
|
|
Framework::JSON::JSONArray* requiredQuestIdsArray
|
|
|
= new Framework::JSON::JSONArray();
|
|
|
for (Framework::Text* requiredQuestId : zObject->requiredQuestsIds)
|
|
@@ -423,14 +427,16 @@ Framework::JSON::JSONValue* QuestType::toJSON(Quest* zObject) const
|
|
|
= new Framework::JSON::JSONArray();
|
|
|
for (QuestRequirement* requirement : zObject->requirements)
|
|
|
{
|
|
|
- requirementsArray->addValue(requirement->getAsJSON());
|
|
|
+ requirementsArray->addValue(
|
|
|
+ Game::INSTANCE->zTypeRegistry()->toJson(requirement));
|
|
|
}
|
|
|
result->addValue("requirements", requirementsArray);
|
|
|
Framework::JSON::JSONArray* rewardsArray = new Framework::JSON::JSONArray();
|
|
|
for (QuestReward* reward : zObject->rewards)
|
|
|
{
|
|
|
- rewardsArray->addValue(reward->getAsJSON());
|
|
|
+ rewardsArray->addValue(Game::INSTANCE->zTypeRegistry()->toJson(reward));
|
|
|
}
|
|
|
+ result->addValue("rewards", rewardsArray);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -441,7 +447,10 @@ Framework::JSON::Validator::JSONValidator* QuestType::getValidator() const
|
|
|
->finishString()
|
|
|
->withRequiredString("questName")
|
|
|
->finishString()
|
|
|
+ ->withRequiredString("description")
|
|
|
+ ->finishString()
|
|
|
->withRequiredArray("requiredQuestIds")
|
|
|
+ ->withDefault(new Framework::JSON::JSONArray())
|
|
|
->addAcceptedStringInArray()
|
|
|
->finishString()
|
|
|
->finishArray()
|
|
@@ -527,7 +536,7 @@ QuestCollection* QuestCollectionType::fromJson(
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-Framework::JSON::JSONValue* QuestCollectionType::toJSON(
|
|
|
+Framework::JSON::JSONValue* QuestCollectionType::toJson(
|
|
|
QuestCollection* zObject) const
|
|
|
{
|
|
|
Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
|
|
@@ -535,7 +544,7 @@ Framework::JSON::JSONValue* QuestCollectionType::toJSON(
|
|
|
Framework::JSON::JSONArray* questsArray = new Framework::JSON::JSONArray();
|
|
|
for (Quest* quest : zObject->quests)
|
|
|
{
|
|
|
- questsArray->addValue(Game::INSTANCE->zTypeRegistry()->toJSON(quest));
|
|
|
+ questsArray->addValue(Game::INSTANCE->zTypeRegistry()->toJson(quest));
|
|
|
}
|
|
|
result->addValue("quests", questsArray);
|
|
|
return result;
|
|
@@ -660,7 +669,7 @@ void QuestManager::saveQuests()
|
|
|
for (QuestCollection* questCollection : questCollections)
|
|
|
{
|
|
|
questCollectionsArray->addValue(
|
|
|
- Game::INSTANCE->zTypeRegistry()->toJSON(questCollection));
|
|
|
+ Game::INSTANCE->zTypeRegistry()->toJson(questCollection));
|
|
|
}
|
|
|
Datei datei(questDir + "/quests.json");
|
|
|
if (!datei.existiert()) datei.erstellen();
|
|
@@ -672,7 +681,7 @@ void QuestManager::saveQuests()
|
|
|
Framework::JSON::JSONArray* partiesArray = new Framework::JSON::JSONArray();
|
|
|
for (QuestParty* party : parties)
|
|
|
{
|
|
|
- partiesArray->addValue(Game::INSTANCE->zTypeRegistry()->toJSON(party));
|
|
|
+ partiesArray->addValue(Game::INSTANCE->zTypeRegistry()->toJson(party));
|
|
|
}
|
|
|
datei.setDatei(questDir + "/parties.json");
|
|
|
if (!datei.existiert()) datei.erstellen();
|
|
@@ -683,20 +692,21 @@ void QuestManager::saveQuests()
|
|
|
partiesArray->release();
|
|
|
}
|
|
|
|
|
|
-void QuestManager::processEvent(QuestEvent* zEvent)
|
|
|
+void QuestManager::processEvent(QuestEvent* event)
|
|
|
{
|
|
|
- Entity* zEntity = zEvent->zActingEntity();
|
|
|
+ Entity* zEntity = event->zActingEntity();
|
|
|
for (QuestParty* party : parties)
|
|
|
{
|
|
|
if (party->isMember(zEntity->getId()))
|
|
|
{
|
|
|
for (QuestCollection* questCollection : questCollections)
|
|
|
{
|
|
|
- questCollection->processEvent(zEvent, party);
|
|
|
+ questCollection->processEvent(event, party);
|
|
|
}
|
|
|
- return;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
+ event->release();
|
|
|
}
|
|
|
|
|
|
void QuestManager::giveReward(
|