|
|
@@ -17,13 +17,13 @@
|
|
|
#include "../CModHandler.h"
|
|
|
#include "../VCMI_Lib.h"
|
|
|
|
|
|
-static const std::string conditionNames[] = {
|
|
|
+static const std::array<std::string, 12> conditionNames = {
|
|
|
"haveArtifact", "haveCreatures", "haveResources", "haveBuilding",
|
|
|
"control", "destroy", "transport", "daysPassed",
|
|
|
"isHuman", "daysWithoutTown", "standardWin", "constValue"
|
|
|
};
|
|
|
|
|
|
-static const std::string typeNames[] = { "victory", "defeat" };
|
|
|
+static const std::array<std::string, 2> typeNames = { "victory", "defeat" };
|
|
|
|
|
|
static EventCondition JsonToCondition(const JsonNode & node)
|
|
|
{
|
|
|
@@ -50,6 +50,11 @@ static EventCondition JsonToCondition(const JsonNode & node)
|
|
|
return event;
|
|
|
}
|
|
|
|
|
|
+static void ConditionToJson(const EventCondition& event, JsonNode& dest)
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
///CMapFormatJson
|
|
|
const int CMapFormatJson::VERSION_MAJOR = 1;
|
|
|
const int CMapFormatJson::VERSION_MINOR = 0;
|
|
|
@@ -85,6 +90,32 @@ void CMapFormatJson::readTriggeredEvent(TriggeredEvent & event, const JsonNode &
|
|
|
event.trigger = EventExpression(source["condition"], JsonToCondition); // logical expression
|
|
|
}
|
|
|
|
|
|
+void CMapFormatJson::writeTriggeredEvents(JsonNode& output)
|
|
|
+{
|
|
|
+ output["victoryString"].String() = map->victoryMessage;
|
|
|
+ output["victoryIconIndex"].Float() = map->victoryIconIndex;
|
|
|
+
|
|
|
+ output["defeatString"].String() = map->defeatMessage;
|
|
|
+ output["defeatIconIndex"].Float() = map->defeatIconIndex;
|
|
|
+
|
|
|
+// JsonMap & triggeredEvents = output["triggeredEvents"].Struct();
|
|
|
+//
|
|
|
+// for(auto event : map->triggeredEvents)
|
|
|
+// writeTriggeredEvent(event, triggeredEvents[event.identifier]);
|
|
|
+}
|
|
|
+
|
|
|
+void CMapFormatJson::writeTriggeredEvent(const TriggeredEvent& event, JsonNode& dest)
|
|
|
+{
|
|
|
+ dest["message"].String() = event.onFulfill;
|
|
|
+ dest["description"].String() = event.description;
|
|
|
+
|
|
|
+ dest["effect"]["type"].String() = typeNames.at(event.effect.type);
|
|
|
+ dest["effect"]["messageToSend"].String() = event.effect.toOtherMessage;
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
///CMapPatcher
|
|
|
CMapPatcher::CMapPatcher(JsonNode stream):
|
|
|
input(stream)
|
|
|
@@ -296,6 +327,10 @@ void CMapSaverJson::saveHeader()
|
|
|
header["difficulty"].String() = difficultyMap.at(map->difficulty);
|
|
|
header["levelLimit"].Float() = map->levelLimit;
|
|
|
|
|
|
+ writeTriggeredEvents(header);
|
|
|
+
|
|
|
+ //todo: player info
|
|
|
+
|
|
|
//todo: allowedHeroes;
|
|
|
//todo: placeholdedHeroes;
|
|
|
|