mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-22 22:13:35 +02:00
Renamed JsonNode::meta to more logical modScope. Member is now private
This commit is contained in:
parent
e73516b7d1
commit
922966dcf8
@ -248,7 +248,7 @@ void ClientCommandManager::handleGetConfigCommand()
|
|||||||
{
|
{
|
||||||
const JsonNode& object = nameAndObject.second;
|
const JsonNode& object = nameAndObject.second;
|
||||||
|
|
||||||
std::string name = ModUtility::makeFullIdentifier(object.meta, contentName, nameAndObject.first);
|
std::string name = ModUtility::makeFullIdentifier(object.getModScope(), contentName, nameAndObject.first);
|
||||||
|
|
||||||
boost::algorithm::replace_all(name, ":", "_");
|
boost::algorithm::replace_all(name, ":", "_");
|
||||||
|
|
||||||
|
@ -461,7 +461,7 @@ CArtifact * CArtHandler::loadFromJson(const std::string & scope, const JsonNode
|
|||||||
VLC->identifiers()->requestIdentifier(scope, "object", "artifact", [=](si32 index)
|
VLC->identifiers()->requestIdentifier(scope, "object", "artifact", [=](si32 index)
|
||||||
{
|
{
|
||||||
JsonNode conf;
|
JsonNode conf;
|
||||||
conf.setMeta(scope);
|
conf.setModScope(scope);
|
||||||
|
|
||||||
VLC->objtypeh->loadSubObject(art->identifier, conf, Obj::ARTIFACT, art->getIndex());
|
VLC->objtypeh->loadSubObject(art->identifier, conf, Obj::ARTIFACT, art->getIndex());
|
||||||
|
|
||||||
@ -469,7 +469,7 @@ CArtifact * CArtHandler::loadFromJson(const std::string & scope, const JsonNode
|
|||||||
{
|
{
|
||||||
JsonNode templ;
|
JsonNode templ;
|
||||||
templ["animation"].String() = art->advMapDef;
|
templ["animation"].String() = art->advMapDef;
|
||||||
templ.setMeta(scope);
|
templ.setModScope(scope);
|
||||||
|
|
||||||
// add new template.
|
// add new template.
|
||||||
// Necessary for objects added via mods that don't have any templates in H3
|
// Necessary for objects added via mods that don't have any templates in H3
|
||||||
|
@ -418,7 +418,7 @@ void CCreatureHandler::loadCommanders()
|
|||||||
|
|
||||||
std::string modSource = VLC->modh->findResourceOrigin(configResource);
|
std::string modSource = VLC->modh->findResourceOrigin(configResource);
|
||||||
JsonNode data(configResource);
|
JsonNode data(configResource);
|
||||||
data.setMeta(modSource);
|
data.setModScope(modSource);
|
||||||
|
|
||||||
const JsonNode & config = data; // switch to const data accessors
|
const JsonNode & config = data; // switch to const data accessors
|
||||||
|
|
||||||
@ -640,7 +640,7 @@ CCreature * CCreatureHandler::loadFromJson(const std::string & scope, const Json
|
|||||||
VLC->identifiers()->requestIdentifier(scope, "object", "monster", [=](si32 index)
|
VLC->identifiers()->requestIdentifier(scope, "object", "monster", [=](si32 index)
|
||||||
{
|
{
|
||||||
JsonNode conf;
|
JsonNode conf;
|
||||||
conf.setMeta(scope);
|
conf.setModScope(scope);
|
||||||
|
|
||||||
VLC->objtypeh->loadSubObject(cre->identifier, conf, Obj::MONSTER, cre->getId().num);
|
VLC->objtypeh->loadSubObject(cre->identifier, conf, Obj::MONSTER, cre->getId().num);
|
||||||
if (!advMapFile.isNull())
|
if (!advMapFile.isNull())
|
||||||
@ -649,7 +649,7 @@ CCreature * CCreatureHandler::loadFromJson(const std::string & scope, const Json
|
|||||||
templ["animation"] = advMapFile;
|
templ["animation"] = advMapFile;
|
||||||
if (!advMapMask.isNull())
|
if (!advMapMask.isNull())
|
||||||
templ["mask"] = advMapMask;
|
templ["mask"] = advMapMask;
|
||||||
templ.setMeta(scope);
|
templ.setModScope(scope);
|
||||||
|
|
||||||
// if creature has custom advMapFile, reset any potentially imported H3M templates and use provided file instead
|
// if creature has custom advMapFile, reset any potentially imported H3M templates and use provided file instead
|
||||||
VLC->objtypeh->getHandlerFor(Obj::MONSTER, cre->getId().num)->clearTemplates();
|
VLC->objtypeh->getHandlerFor(Obj::MONSTER, cre->getId().num)->clearTemplates();
|
||||||
|
@ -293,7 +293,7 @@ CHeroClass * CHeroClassHandler::loadFromJson(const std::string & scope, const Js
|
|||||||
for(auto skillPair : node["secondarySkills"].Struct())
|
for(auto skillPair : node["secondarySkills"].Struct())
|
||||||
{
|
{
|
||||||
int probability = static_cast<int>(skillPair.second.Integer());
|
int probability = static_cast<int>(skillPair.second.Integer());
|
||||||
VLC->identifiers()->requestIdentifier(skillPair.second.meta, "skill", skillPair.first, [heroClass, probability](si32 skillID)
|
VLC->identifiers()->requestIdentifier(skillPair.second.getModScope(), "skill", skillPair.first, [heroClass, probability](si32 skillID)
|
||||||
{
|
{
|
||||||
heroClass->secSkillProbability[skillID] = probability;
|
heroClass->secSkillProbability[skillID] = probability;
|
||||||
});
|
});
|
||||||
@ -310,7 +310,7 @@ CHeroClass * CHeroClassHandler::loadFromJson(const std::string & scope, const Js
|
|||||||
{
|
{
|
||||||
int value = static_cast<int>(tavern.second.Float());
|
int value = static_cast<int>(tavern.second.Float());
|
||||||
|
|
||||||
VLC->identifiers()->requestIdentifier(tavern.second.meta, "faction", tavern.first,
|
VLC->identifiers()->requestIdentifier(tavern.second.getModScope(), "faction", tavern.first,
|
||||||
[=](si32 factionID)
|
[=](si32 factionID)
|
||||||
{
|
{
|
||||||
heroClass->selectionProbability[FactionID(factionID)] = value;
|
heroClass->selectionProbability[FactionID(factionID)] = value;
|
||||||
@ -329,7 +329,7 @@ CHeroClass * CHeroClassHandler::loadFromJson(const std::string & scope, const Js
|
|||||||
classConf["heroClass"].String() = identifier;
|
classConf["heroClass"].String() = identifier;
|
||||||
if (!node["compatibilityIdentifiers"].isNull())
|
if (!node["compatibilityIdentifiers"].isNull())
|
||||||
classConf["compatibilityIdentifiers"] = node["compatibilityIdentifiers"];
|
classConf["compatibilityIdentifiers"] = node["compatibilityIdentifiers"];
|
||||||
classConf.setMeta(scope);
|
classConf.setModScope(scope);
|
||||||
VLC->objtypeh->loadSubObject(identifier, classConf, index, heroClass->getIndex());
|
VLC->objtypeh->loadSubObject(identifier, classConf, index, heroClass->getIndex());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -617,7 +617,7 @@ void CTownHandler::loadSpecialBuildingBonuses(const JsonNode & source, BonusList
|
|||||||
void CTownHandler::loadBuilding(CTown * town, const std::string & stringID, const JsonNode & source)
|
void CTownHandler::loadBuilding(CTown * town, const std::string & stringID, const JsonNode & source)
|
||||||
{
|
{
|
||||||
assert(stringID.find(':') == std::string::npos);
|
assert(stringID.find(':') == std::string::npos);
|
||||||
assert(!source.meta.empty());
|
assert(!source.getModScope().empty());
|
||||||
|
|
||||||
auto * ret = new CBuilding();
|
auto * ret = new CBuilding();
|
||||||
ret->bid = getMappedValue<BuildingID, std::string>(stringID, BuildingID::NONE, MappedKeys::BUILDING_NAMES_TO_TYPES, false);
|
ret->bid = getMappedValue<BuildingID, std::string>(stringID, BuildingID::NONE, MappedKeys::BUILDING_NAMES_TO_TYPES, false);
|
||||||
@ -640,11 +640,11 @@ void CTownHandler::loadBuilding(CTown * town, const std::string & stringID, cons
|
|||||||
ret->height = getMappedValue<CBuilding::ETowerHeight>(source["height"], CBuilding::HEIGHT_NO_TOWER, CBuilding::TOWER_TYPES);
|
ret->height = getMappedValue<CBuilding::ETowerHeight>(source["height"], CBuilding::HEIGHT_NO_TOWER, CBuilding::TOWER_TYPES);
|
||||||
|
|
||||||
ret->identifier = stringID;
|
ret->identifier = stringID;
|
||||||
ret->modScope = source.meta;
|
ret->modScope = source.getModScope();
|
||||||
ret->town = town;
|
ret->town = town;
|
||||||
|
|
||||||
VLC->generaltexth->registerString(source.meta, ret->getNameTextID(), source["name"].String());
|
VLC->generaltexth->registerString(source.getModScope(), ret->getNameTextID(), source["name"].String());
|
||||||
VLC->generaltexth->registerString(source.meta, ret->getDescriptionTextID(), source["description"].String());
|
VLC->generaltexth->registerString(source.getModScope(), ret->getDescriptionTextID(), source["description"].String());
|
||||||
|
|
||||||
ret->resources = TResources(source["cost"]);
|
ret->resources = TResources(source["cost"]);
|
||||||
ret->produce = TResources(source["produce"]);
|
ret->produce = TResources(source["produce"]);
|
||||||
@ -729,7 +729,7 @@ void CTownHandler::loadBuilding(CTown * town, const std::string & stringID, cons
|
|||||||
|
|
||||||
ret->town->buildings[ret->bid] = ret;
|
ret->town->buildings[ret->bid] = ret;
|
||||||
|
|
||||||
registerObject(source.meta, ret->town->getBuildingScope(), ret->identifier, ret->bid.getNum());
|
registerObject(source.getModScope(), ret->town->getBuildingScope(), ret->identifier, ret->bid.getNum());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTownHandler::loadBuildings(CTown * town, const JsonNode & source)
|
void CTownHandler::loadBuildings(CTown * town, const JsonNode & source)
|
||||||
@ -751,14 +751,14 @@ void CTownHandler::loadStructure(CTown &town, const std::string & stringID, cons
|
|||||||
ret->building = nullptr;
|
ret->building = nullptr;
|
||||||
ret->buildable = nullptr;
|
ret->buildable = nullptr;
|
||||||
|
|
||||||
VLC->identifiers()->tryRequestIdentifier( source.meta, "building." + town.faction->getJsonKey(), stringID, [=, &town](si32 identifier) mutable
|
VLC->identifiers()->tryRequestIdentifier( source.getModScope(), "building." + town.faction->getJsonKey(), stringID, [=, &town](si32 identifier) mutable
|
||||||
{
|
{
|
||||||
ret->building = town.buildings[BuildingID(identifier)];
|
ret->building = town.buildings[BuildingID(identifier)];
|
||||||
});
|
});
|
||||||
|
|
||||||
if (source["builds"].isNull())
|
if (source["builds"].isNull())
|
||||||
{
|
{
|
||||||
VLC->identifiers()->tryRequestIdentifier( source.meta, "building." + town.faction->getJsonKey(), stringID, [=, &town](si32 identifier) mutable
|
VLC->identifiers()->tryRequestIdentifier( source.getModScope(), "building." + town.faction->getJsonKey(), stringID, [=, &town](si32 identifier) mutable
|
||||||
{
|
{
|
||||||
ret->building = town.buildings[BuildingID(identifier)];
|
ret->building = town.buildings[BuildingID(identifier)];
|
||||||
});
|
});
|
||||||
@ -944,7 +944,7 @@ void CTownHandler::loadTown(CTown * town, const JsonNode & source)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VLC->identifiers()->requestIdentifier( source.meta, "spell", "castleMoat", [=](si32 ability)
|
VLC->identifiers()->requestIdentifier( source.getModScope(), "spell", "castleMoat", [=](si32 ability)
|
||||||
{
|
{
|
||||||
town->moatAbility = SpellID(ability);
|
town->moatAbility = SpellID(ability);
|
||||||
});
|
});
|
||||||
@ -984,7 +984,7 @@ void CTownHandler::loadTown(CTown * town, const JsonNode & source)
|
|||||||
{
|
{
|
||||||
int chance = static_cast<int>(node.second.Float());
|
int chance = static_cast<int>(node.second.Float());
|
||||||
|
|
||||||
VLC->identifiers()->requestIdentifier(node.second.meta, "heroClass",node.first, [=](si32 classID)
|
VLC->identifiers()->requestIdentifier(node.second.getModScope(), "heroClass",node.first, [=](si32 classID)
|
||||||
{
|
{
|
||||||
VLC->heroclassesh->objects[classID]->selectionProbability[town->faction->getId()] = chance;
|
VLC->heroclassesh->objects[classID]->selectionProbability[town->faction->getId()] = chance;
|
||||||
});
|
});
|
||||||
@ -994,7 +994,7 @@ void CTownHandler::loadTown(CTown * town, const JsonNode & source)
|
|||||||
{
|
{
|
||||||
int chance = static_cast<int>(node.second.Float());
|
int chance = static_cast<int>(node.second.Float());
|
||||||
|
|
||||||
VLC->identifiers()->requestIdentifier(node.second.meta, "spell", node.first, [=](si32 spellID)
|
VLC->identifiers()->requestIdentifier(node.second.getModScope(), "spell", node.first, [=](si32 spellID)
|
||||||
{
|
{
|
||||||
VLC->spellh->objects.at(spellID)->probabilities[town->faction->getId()] = chance;
|
VLC->spellh->objects.at(spellID)->probabilities[town->faction->getId()] = chance;
|
||||||
});
|
});
|
||||||
@ -1120,9 +1120,9 @@ void CTownHandler::loadObject(std::string scope, std::string name, const JsonNod
|
|||||||
// register town once objects are loaded
|
// register town once objects are loaded
|
||||||
JsonNode config = data["town"]["mapObject"];
|
JsonNode config = data["town"]["mapObject"];
|
||||||
config["faction"].String() = name;
|
config["faction"].String() = name;
|
||||||
config["faction"].meta = scope;
|
config["faction"].setModScope(scope, false);
|
||||||
if (config.meta.empty())// MODS COMPATIBILITY FOR 0.96
|
if (config.getModScope().empty())// MODS COMPATIBILITY FOR 0.96
|
||||||
config.meta = scope;
|
config.setModScope(scope, false);
|
||||||
VLC->objtypeh->loadSubObject(object->identifier, config, index, object->index);
|
VLC->objtypeh->loadSubObject(object->identifier, config, index, object->index);
|
||||||
|
|
||||||
// MODS COMPATIBILITY FOR 0.96
|
// MODS COMPATIBILITY FOR 0.96
|
||||||
@ -1163,7 +1163,7 @@ void CTownHandler::loadObject(std::string scope, std::string name, const JsonNod
|
|||||||
// register town once objects are loaded
|
// register town once objects are loaded
|
||||||
JsonNode config = data["town"]["mapObject"];
|
JsonNode config = data["town"]["mapObject"];
|
||||||
config["faction"].String() = name;
|
config["faction"].String() = name;
|
||||||
config["faction"].meta = scope;
|
config["faction"].setModScope(scope, false);
|
||||||
VLC->objtypeh->loadSubObject(object->identifier, config, index, object->index);
|
VLC->objtypeh->loadSubObject(object->identifier, config, index, object->index);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1174,7 +1174,7 @@ void CTownHandler::loadObject(std::string scope, std::string name, const JsonNod
|
|||||||
void CTownHandler::loadRandomFaction()
|
void CTownHandler::loadRandomFaction()
|
||||||
{
|
{
|
||||||
JsonNode randomFactionJson(JsonPath::builtin("config/factions/random.json"));
|
JsonNode randomFactionJson(JsonPath::builtin("config/factions/random.json"));
|
||||||
randomFactionJson.setMeta(ModScope::scopeBuiltin(), true);
|
randomFactionJson.setModScope(ModScope::scopeBuiltin(), true);
|
||||||
loadBuildings(randomTown, randomFactionJson["random"]["town"]["buildings"]);
|
loadBuildings(randomTown, randomFactionJson["random"]["town"]["buildings"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +353,7 @@ const JsonNode & BonusParams::toJson()
|
|||||||
ret["targetSourceType"].String() = vstd::findKey(bonusSourceMap, *targetType);
|
ret["targetSourceType"].String() = vstd::findKey(bonusSourceMap, *targetType);
|
||||||
jsonCreated = true;
|
jsonCreated = true;
|
||||||
}
|
}
|
||||||
ret.setMeta(ModScope::scopeGame());
|
ret.setModScope(ModScope::scopeGame());
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,14 +40,14 @@ static void loadBonusSubtype(BonusSubtypeID & subtype, BonusType type, const Jso
|
|||||||
|
|
||||||
if (node.isNumber()) // Compatibility code for 1.3 or older
|
if (node.isNumber()) // Compatibility code for 1.3 or older
|
||||||
{
|
{
|
||||||
logMod->warn("Bonus subtype must be string! (%s)", node.meta);
|
logMod->warn("Bonus subtype must be string! (%s)", node.getModScope());
|
||||||
subtype = BonusCustomSubtype(node.Integer());
|
subtype = BonusCustomSubtype(node.Integer());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!node.isString())
|
if (!node.isString())
|
||||||
{
|
{
|
||||||
logMod->warn("Bonus subtype must be string! (%s)", node.meta);
|
logMod->warn("Bonus subtype must be string! (%s)", node.getModScope());
|
||||||
subtype = BonusSubtypeID();
|
subtype = BonusSubtypeID();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -124,9 +124,14 @@ JsonNode::JsonType JsonNode::getType() const
|
|||||||
return static_cast<JsonType>(data.index());
|
return static_cast<JsonType>(data.index());
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonNode::setMeta(const std::string & metadata, bool recursive)
|
const std::string & JsonNode::getModScope() const
|
||||||
{
|
{
|
||||||
meta = metadata;
|
return modScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JsonNode::setModScope(const std::string & metadata, bool recursive)
|
||||||
|
{
|
||||||
|
modScope = metadata;
|
||||||
if (recursive)
|
if (recursive)
|
||||||
{
|
{
|
||||||
switch (getType())
|
switch (getType())
|
||||||
@ -135,14 +140,14 @@ void JsonNode::setMeta(const std::string & metadata, bool recursive)
|
|||||||
{
|
{
|
||||||
for(auto & node : Vector())
|
for(auto & node : Vector())
|
||||||
{
|
{
|
||||||
node.setMeta(metadata);
|
node.setModScope(metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break; case JsonType::DATA_STRUCT:
|
break; case JsonType::DATA_STRUCT:
|
||||||
{
|
{
|
||||||
for(auto & node : Struct())
|
for(auto & node : Struct())
|
||||||
{
|
{
|
||||||
node.second.setMeta(metadata);
|
node.second.setModScope(metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,9 +41,9 @@ private:
|
|||||||
|
|
||||||
JsonData data;
|
JsonData data;
|
||||||
|
|
||||||
|
/// Mod-origin of this particular field
|
||||||
|
std::string modScope;
|
||||||
public:
|
public:
|
||||||
/// free to use metadata fields
|
|
||||||
std::string meta;
|
|
||||||
/// meta-flags like override
|
/// meta-flags like override
|
||||||
std::vector<std::string> flags;
|
std::vector<std::string> flags;
|
||||||
|
|
||||||
@ -68,7 +68,8 @@ public:
|
|||||||
bool operator == (const JsonNode &other) const;
|
bool operator == (const JsonNode &other) const;
|
||||||
bool operator != (const JsonNode &other) const;
|
bool operator != (const JsonNode &other) const;
|
||||||
|
|
||||||
void setMeta(const std::string & metadata, bool recursive = true);
|
const std::string & getModScope() const;
|
||||||
|
void setModScope(const std::string & metadata, bool recursive = true);
|
||||||
|
|
||||||
/// Convert node to another type. Converting to nullptr will clear all data
|
/// Convert node to another type. Converting to nullptr will clear all data
|
||||||
void setType(JsonType Type);
|
void setType(JsonType Type);
|
||||||
@ -130,7 +131,7 @@ public:
|
|||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h)
|
template <typename Handler> void serialize(Handler &h)
|
||||||
{
|
{
|
||||||
h & meta;
|
h & modScope;
|
||||||
h & flags;
|
h & flags;
|
||||||
h & data;
|
h & data;
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|||||||
{
|
{
|
||||||
for(const auto & pair : value.Struct())
|
for(const auto & pair : value.Struct())
|
||||||
{
|
{
|
||||||
PrimarySkill id = decodeKey<PrimarySkill>(pair.second.meta, pair.first, variables);
|
PrimarySkill id = decodeKey<PrimarySkill>(pair.second.getModScope(), pair.first, variables);
|
||||||
ret[id.getNum()] += loadValue(pair.second, rng, variables);
|
ret[id.getNum()] += loadValue(pair.second, rng, variables);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -357,7 +357,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|||||||
{
|
{
|
||||||
for(const auto & pair : value.Struct())
|
for(const auto & pair : value.Struct())
|
||||||
{
|
{
|
||||||
SecondarySkill id = decodeKey<SecondarySkill>(pair.second.meta, pair.first, variables);
|
SecondarySkill id = decodeKey<SecondarySkill>(pair.second.getModScope(), pair.first, variables);
|
||||||
ret[id] = loadValue(pair.second, rng, variables);
|
ret[id] = loadValue(pair.second, rng, variables);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ void JsonUtils::merge(JsonNode & dest, JsonNode & source, bool ignoreOverride, b
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (copyMeta)
|
if (copyMeta)
|
||||||
dest.meta = source.meta;
|
dest.setModScope(source.getModScope(), false);
|
||||||
|
|
||||||
//recursively merge all entries from struct
|
//recursively merge all entries from struct
|
||||||
for(auto & node : source.Struct())
|
for(auto & node : source.Struct())
|
||||||
|
@ -469,45 +469,45 @@ namespace
|
|||||||
|
|
||||||
std::string textFile(const JsonNode & node)
|
std::string textFile(const JsonNode & node)
|
||||||
{
|
{
|
||||||
TEST_FILE(node.meta, "", node.String(), EResType::JSON);
|
TEST_FILE(node.getModScope(), "", node.String(), EResType::JSON);
|
||||||
return "Text file \"" + node.String() + "\" was not found";
|
return "Text file \"" + node.String() + "\" was not found";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string musicFile(const JsonNode & node)
|
std::string musicFile(const JsonNode & node)
|
||||||
{
|
{
|
||||||
TEST_FILE(node.meta, "Music/", node.String(), EResType::SOUND);
|
TEST_FILE(node.getModScope(), "Music/", node.String(), EResType::SOUND);
|
||||||
TEST_FILE(node.meta, "", node.String(), EResType::SOUND);
|
TEST_FILE(node.getModScope(), "", node.String(), EResType::SOUND);
|
||||||
return "Music file \"" + node.String() + "\" was not found";
|
return "Music file \"" + node.String() + "\" was not found";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string soundFile(const JsonNode & node)
|
std::string soundFile(const JsonNode & node)
|
||||||
{
|
{
|
||||||
TEST_FILE(node.meta, "Sounds/", node.String(), EResType::SOUND);
|
TEST_FILE(node.getModScope(), "Sounds/", node.String(), EResType::SOUND);
|
||||||
return "Sound file \"" + node.String() + "\" was not found";
|
return "Sound file \"" + node.String() + "\" was not found";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string defFile(const JsonNode & node)
|
std::string defFile(const JsonNode & node)
|
||||||
{
|
{
|
||||||
return testAnimation(node.String(), node.meta);
|
return testAnimation(node.String(), node.getModScope());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string animationFile(const JsonNode & node)
|
std::string animationFile(const JsonNode & node)
|
||||||
{
|
{
|
||||||
return testAnimation(node.String(), node.meta);
|
return testAnimation(node.String(), node.getModScope());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string imageFile(const JsonNode & node)
|
std::string imageFile(const JsonNode & node)
|
||||||
{
|
{
|
||||||
TEST_FILE(node.meta, "Data/", node.String(), EResType::IMAGE);
|
TEST_FILE(node.getModScope(), "Data/", node.String(), EResType::IMAGE);
|
||||||
TEST_FILE(node.meta, "Sprites/", node.String(), EResType::IMAGE);
|
TEST_FILE(node.getModScope(), "Sprites/", node.String(), EResType::IMAGE);
|
||||||
if (node.String().find(':') != std::string::npos)
|
if (node.String().find(':') != std::string::npos)
|
||||||
return testAnimation(node.String().substr(0, node.String().find(':')), node.meta);
|
return testAnimation(node.String().substr(0, node.String().find(':')), node.getModScope());
|
||||||
return "Image file \"" + node.String() + "\" was not found";
|
return "Image file \"" + node.String() + "\" was not found";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string videoFile(const JsonNode & node)
|
std::string videoFile(const JsonNode & node)
|
||||||
{
|
{
|
||||||
TEST_FILE(node.meta, "Video/", node.String(), EResType::VIDEO);
|
TEST_FILE(node.getModScope(), "Video/", node.String(), EResType::VIDEO);
|
||||||
return "Video file \"" + node.String() + "\" was not found";
|
return "Video file \"" + node.String() + "\" was not found";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,8 +37,8 @@ void JsonWriter::writeEntry(JsonMap::const_iterator entry)
|
|||||||
{
|
{
|
||||||
if(!compactMode)
|
if(!compactMode)
|
||||||
{
|
{
|
||||||
if (!entry->second.meta.empty())
|
if (!entry->second.getModScope().empty())
|
||||||
out << prefix << " // " << entry->second.meta << "\n";
|
out << prefix << " // " << entry->second.getModScope() << "\n";
|
||||||
if(!entry->second.flags.empty())
|
if(!entry->second.flags.empty())
|
||||||
out << prefix << " // flags: " << boost::algorithm::join(entry->second.flags, ", ") << "\n";
|
out << prefix << " // flags: " << boost::algorithm::join(entry->second.flags, ", ") << "\n";
|
||||||
out << prefix;
|
out << prefix;
|
||||||
@ -52,8 +52,8 @@ void JsonWriter::writeEntry(JsonVector::const_iterator entry)
|
|||||||
{
|
{
|
||||||
if(!compactMode)
|
if(!compactMode)
|
||||||
{
|
{
|
||||||
if (!entry->meta.empty())
|
if (!entry->getModScope().empty())
|
||||||
out << prefix << " // " << entry->meta << "\n";
|
out << prefix << " // " << entry->getModScope() << "\n";
|
||||||
if(!entry->flags.empty())
|
if(!entry->flags.empty())
|
||||||
out << prefix << " // flags: " << boost::algorithm::join(entry->flags, ", ") << "\n";
|
out << prefix << " // flags: " << boost::algorithm::join(entry->flags, ", ") << "\n";
|
||||||
out << prefix;
|
out << prefix;
|
||||||
|
@ -27,7 +27,7 @@ void CBankInstanceConstructor::initTypeData(const JsonNode & input)
|
|||||||
if (input.Struct().count("name") == 0)
|
if (input.Struct().count("name") == 0)
|
||||||
logMod->warn("Bank %s missing name!", getJsonKey());
|
logMod->warn("Bank %s missing name!", getJsonKey());
|
||||||
|
|
||||||
VLC->generaltexth->registerString(input.meta, getNameTextID(), input["name"].String());
|
VLC->generaltexth->registerString(input.getModScope(), getNameTextID(), input["name"].String());
|
||||||
|
|
||||||
levels = input["levels"].Vector();
|
levels = input["levels"].Vector();
|
||||||
bankResetDuration = static_cast<si32>(input["resetDuration"].Float());
|
bankResetDuration = static_cast<si32>(input["resetDuration"].Float());
|
||||||
|
@ -259,21 +259,21 @@ std::unique_ptr<ObjectClass> CObjectClassesHandler::loadFromJson(const std::stri
|
|||||||
{
|
{
|
||||||
if (!subData.second["index"].isNull())
|
if (!subData.second["index"].isNull())
|
||||||
{
|
{
|
||||||
const std::string & subMeta = subData.second["index"].meta;
|
const std::string & subMeta = subData.second["index"].getModScope();
|
||||||
|
|
||||||
if ( subMeta == "core")
|
if ( subMeta == "core")
|
||||||
{
|
{
|
||||||
size_t subIndex = subData.second["index"].Integer();
|
size_t subIndex = subData.second["index"].Integer();
|
||||||
loadSubObject(subData.second.meta, subData.first, subData.second, obj.get(), subIndex);
|
loadSubObject(subData.second.getModScope(), subData.first, subData.second, obj.get(), subIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logMod->error("Object %s:%s.%s - attempt to load object with preset index! This option is reserved for built-in mod", subMeta, name, subData.first );
|
logMod->error("Object %s:%s.%s - attempt to load object with preset index! This option is reserved for built-in mod", subMeta, name, subData.first );
|
||||||
loadSubObject(subData.second.meta, subData.first, subData.second, obj.get());
|
loadSubObject(subData.second.getModScope(), subData.first, subData.second, obj.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
loadSubObject(subData.second.meta, subData.first, subData.second, obj.get());
|
loadSubObject(subData.second.getModScope(), subData.first, subData.second, obj.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj->id == MapObjectID::MONOLITH_TWO_WAY)
|
if (obj->id == MapObjectID::MONOLITH_TWO_WAY)
|
||||||
@ -306,7 +306,7 @@ void CObjectClassesHandler::loadSubObject(const std::string & identifier, JsonNo
|
|||||||
objects.at(ID.getNum())->objects.resize(subID.getNum()+1);
|
objects.at(ID.getNum())->objects.resize(subID.getNum()+1);
|
||||||
|
|
||||||
JsonUtils::inherit(config, objects.at(ID.getNum())->base);
|
JsonUtils::inherit(config, objects.at(ID.getNum())->base);
|
||||||
loadSubObject(config.meta, identifier, config, objects.at(ID.getNum()).get(), subID.getNum());
|
loadSubObject(config.getModScope(), identifier, config, objects.at(ID.getNum()).get(), subID.getNum());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CObjectClassesHandler::removeSubObject(MapObjectID ID, MapObjectSubID subID)
|
void CObjectClassesHandler::removeSubObject(MapObjectID ID, MapObjectSubID subID)
|
||||||
|
@ -22,7 +22,7 @@ void CRewardableConstructor::initTypeData(const JsonNode & config)
|
|||||||
blockVisit = config["blockedVisitable"].Bool();
|
blockVisit = config["blockedVisitable"].Bool();
|
||||||
|
|
||||||
if (!config["name"].isNull())
|
if (!config["name"].isNull())
|
||||||
VLC->generaltexth->registerString( config.meta, getNameTextID(), config["name"].String());
|
VLC->generaltexth->registerString( config.getModScope(), getNameTextID(), config["name"].String());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ void CTownInstanceConstructor::initTypeData(const JsonNode & input)
|
|||||||
|
|
||||||
// change scope of "filters" to scope of object that is being loaded
|
// change scope of "filters" to scope of object that is being loaded
|
||||||
// since this filters require to resolve building ID's
|
// since this filters require to resolve building ID's
|
||||||
filtersJson.setMeta(input["faction"].meta);
|
filtersJson.setModScope(input["faction"].getModScope());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTownInstanceConstructor::afterLoadFinalization()
|
void CTownInstanceConstructor::afterLoadFinalization()
|
||||||
|
@ -29,7 +29,7 @@ void DwellingInstanceConstructor::initTypeData(const JsonNode & input)
|
|||||||
if (input.Struct().count("name") == 0)
|
if (input.Struct().count("name") == 0)
|
||||||
logMod->warn("Dwelling %s missing name!", getJsonKey());
|
logMod->warn("Dwelling %s missing name!", getJsonKey());
|
||||||
|
|
||||||
VLC->generaltexth->registerString( input.meta, getNameTextID(), input["name"].String());
|
VLC->generaltexth->registerString( input.getModScope(), getNameTextID(), input["name"].String());
|
||||||
|
|
||||||
const JsonVector & levels = input["creatures"].Vector();
|
const JsonVector & levels = input["creatures"].Vector();
|
||||||
const auto totalLevels = levels.size();
|
const auto totalLevels = levels.size();
|
||||||
|
@ -171,7 +171,7 @@ static JsonNode loadPatches(const std::string & path)
|
|||||||
for (auto & entry : node.Struct())
|
for (auto & entry : node.Struct())
|
||||||
JsonUtils::validate(entry.second, "vcmi:mapHeader", "patch for " + entry.first);
|
JsonUtils::validate(entry.second, "vcmi:mapHeader", "patch for " + entry.first);
|
||||||
|
|
||||||
node.setMeta(ModScope::scopeMap());
|
node.setModScope(ModScope::scopeMap());
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1153,7 +1153,7 @@ CGObjectInstance * CMapLoaderH3M::readWitchHut(const int3 & position, std::share
|
|||||||
variable["anyOf"].Vector() = anyOfList;
|
variable["anyOf"].Vector() = anyOfList;
|
||||||
}
|
}
|
||||||
|
|
||||||
variable.setMeta(ModScope::scopeGame()); // list may include skills from all mods
|
variable.setModScope(ModScope::scopeGame()); // list may include skills from all mods
|
||||||
rewardable->configuration.presetVariable("secondarySkill", "gainedSkill", variable);
|
rewardable->configuration.presetVariable("secondarySkill", "gainedSkill", variable);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1189,7 +1189,7 @@ CGObjectInstance * CMapLoaderH3M::readScholar(const int3 & position, std::shared
|
|||||||
JsonNode variable;
|
JsonNode variable;
|
||||||
JsonNode dice;
|
JsonNode dice;
|
||||||
variable.String() = NPrimarySkill::names[bonusID];
|
variable.String() = NPrimarySkill::names[bonusID];
|
||||||
variable.setMeta(ModScope::scopeGame());
|
variable.setModScope(ModScope::scopeGame());
|
||||||
dice.Integer() = 80;
|
dice.Integer() = 80;
|
||||||
rewardable->configuration.presetVariable("primarySkill", "gainedStat", variable);
|
rewardable->configuration.presetVariable("primarySkill", "gainedStat", variable);
|
||||||
rewardable->configuration.presetVariable("dice", "0", dice);
|
rewardable->configuration.presetVariable("dice", "0", dice);
|
||||||
@ -1200,7 +1200,7 @@ CGObjectInstance * CMapLoaderH3M::readScholar(const int3 & position, std::shared
|
|||||||
JsonNode variable;
|
JsonNode variable;
|
||||||
JsonNode dice;
|
JsonNode dice;
|
||||||
variable.String() = VLC->skills()->getByIndex(bonusID)->getJsonKey();
|
variable.String() = VLC->skills()->getByIndex(bonusID)->getJsonKey();
|
||||||
variable.setMeta(ModScope::scopeGame());
|
variable.setModScope(ModScope::scopeGame());
|
||||||
dice.Integer() = 50;
|
dice.Integer() = 50;
|
||||||
rewardable->configuration.presetVariable("secondarySkill", "gainedSkill", variable);
|
rewardable->configuration.presetVariable("secondarySkill", "gainedSkill", variable);
|
||||||
rewardable->configuration.presetVariable("dice", "0", dice);
|
rewardable->configuration.presetVariable("dice", "0", dice);
|
||||||
@ -1211,7 +1211,7 @@ CGObjectInstance * CMapLoaderH3M::readScholar(const int3 & position, std::shared
|
|||||||
JsonNode variable;
|
JsonNode variable;
|
||||||
JsonNode dice;
|
JsonNode dice;
|
||||||
variable.String() = VLC->spells()->getByIndex(bonusID)->getJsonKey();
|
variable.String() = VLC->spells()->getByIndex(bonusID)->getJsonKey();
|
||||||
variable.setMeta(ModScope::scopeGame());
|
variable.setModScope(ModScope::scopeGame());
|
||||||
dice.Integer() = 20;
|
dice.Integer() = 20;
|
||||||
rewardable->configuration.presetVariable("spell", "gainedSpell", variable);
|
rewardable->configuration.presetVariable("spell", "gainedSpell", variable);
|
||||||
rewardable->configuration.presetVariable("dice", "0", dice);
|
rewardable->configuration.presetVariable("dice", "0", dice);
|
||||||
@ -1356,7 +1356,7 @@ CGObjectInstance * CMapLoaderH3M::readShrine(const int3 & position, std::shared_
|
|||||||
{
|
{
|
||||||
JsonNode variable;
|
JsonNode variable;
|
||||||
variable.String() = VLC->spells()->getById(spell)->getJsonKey();
|
variable.String() = VLC->spells()->getById(spell)->getJsonKey();
|
||||||
variable.setMeta(ModScope::scopeGame()); // list may include spells from all mods
|
variable.setModScope(ModScope::scopeGame()); // list may include spells from all mods
|
||||||
rewardable->configuration.presetVariable("spell", "gainedSpell", variable);
|
rewardable->configuration.presetVariable("spell", "gainedSpell", variable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ void MapIdentifiersH3M::loadMapping(std::map<IdentifierID, IdentifierID> & resul
|
|||||||
for (auto entry : mapping.Struct())
|
for (auto entry : mapping.Struct())
|
||||||
{
|
{
|
||||||
IdentifierID sourceID (entry.second.Integer());
|
IdentifierID sourceID (entry.second.Integer());
|
||||||
IdentifierID targetID (*VLC->identifiers()->getIdentifier(entry.second.meta, identifierName, entry.first));
|
IdentifierID targetID (*VLC->identifiers()->getIdentifier(entry.second.getModScope(), identifierName, entry.first));
|
||||||
|
|
||||||
result[sourceID] = targetID;
|
result[sourceID] = targetID;
|
||||||
}
|
}
|
||||||
@ -41,13 +41,13 @@ void MapIdentifiersH3M::loadMapping(const JsonNode & mapping)
|
|||||||
|
|
||||||
for (auto entryFaction : mapping["buildings"].Struct())
|
for (auto entryFaction : mapping["buildings"].Struct())
|
||||||
{
|
{
|
||||||
FactionID factionID (*VLC->identifiers()->getIdentifier(entryFaction.second.meta, "faction", entryFaction.first));
|
FactionID factionID (*VLC->identifiers()->getIdentifier(entryFaction.second.getModScope(), "faction", entryFaction.first));
|
||||||
auto buildingMap = entryFaction.second;
|
auto buildingMap = entryFaction.second;
|
||||||
|
|
||||||
for (auto entryBuilding : buildingMap.Struct())
|
for (auto entryBuilding : buildingMap.Struct())
|
||||||
{
|
{
|
||||||
BuildingID sourceID (entryBuilding.second.Integer());
|
BuildingID sourceID (entryBuilding.second.Integer());
|
||||||
BuildingID targetID (*VLC->identifiers()->getIdentifier(entryBuilding.second.meta, "building." + VLC->factions()->getById(factionID)->getJsonKey(), entryBuilding.first));
|
BuildingID targetID (*VLC->identifiers()->getIdentifier(entryBuilding.second.getModScope(), "building." + VLC->factions()->getById(factionID)->getJsonKey(), entryBuilding.first));
|
||||||
|
|
||||||
mappingFactionBuilding[factionID][sourceID] = targetID;
|
mappingFactionBuilding[factionID][sourceID] = targetID;
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ void MapIdentifiersH3M::loadMapping(const JsonNode & mapping)
|
|||||||
{
|
{
|
||||||
for (auto entryInner : entryOuter.second.Struct())
|
for (auto entryInner : entryOuter.second.Struct())
|
||||||
{
|
{
|
||||||
auto handler = VLC->objtypeh->getHandlerFor( entryInner.second.meta, entryOuter.first, entryInner.first);
|
auto handler = VLC->objtypeh->getHandlerFor( entryInner.second.getModScope(), entryOuter.first, entryInner.first);
|
||||||
|
|
||||||
auto entryValues = entryInner.second.Vector();
|
auto entryValues = entryInner.second.Vector();
|
||||||
ObjectTypeIdentifier h3mID{Obj(entryValues[0].Integer()), int32_t(entryValues[1].Integer())};
|
ObjectTypeIdentifier h3mID{Obj(entryValues[0].Integer()), int32_t(entryValues[1].Integer())};
|
||||||
@ -80,7 +80,7 @@ void MapIdentifiersH3M::loadMapping(const JsonNode & mapping)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto handler = VLC->objtypeh->getHandlerFor( entryOuter.second.meta, entryOuter.first, entryOuter.first);
|
auto handler = VLC->objtypeh->getHandlerFor( entryOuter.second.getModScope(), entryOuter.first, entryOuter.first);
|
||||||
|
|
||||||
auto entryValues = entryOuter.second.Vector();
|
auto entryValues = entryOuter.second.Vector();
|
||||||
ObjectTypeIdentifier h3mID{Obj(entryValues[0].Integer()), int32_t(entryValues[1].Integer())};
|
ObjectTypeIdentifier h3mID{Obj(entryValues[0].Integer()), int32_t(entryValues[1].Integer())};
|
||||||
|
@ -18,7 +18,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|||||||
|
|
||||||
static JsonNode addMeta(JsonNode config, const std::string & meta)
|
static JsonNode addMeta(JsonNode config, const std::string & meta)
|
||||||
{
|
{
|
||||||
config.setMeta(meta);
|
config.setModScope(meta);
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ ContentTypeHandler::ContentTypeHandler(IHandlerBase * handler, const std::string
|
|||||||
{
|
{
|
||||||
for(auto & node : originalData)
|
for(auto & node : originalData)
|
||||||
{
|
{
|
||||||
node.setMeta(ModScope::scopeBuiltin());
|
node.setModScope(ModScope::scopeBuiltin());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ bool ContentTypeHandler::preloadModData(const std::string & modName, const std::
|
|||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
JsonNode data = JsonUtils::assembleFromFiles(fileList, result);
|
JsonNode data = JsonUtils::assembleFromFiles(fileList, result);
|
||||||
data.setMeta(modName);
|
data.setModScope(modName);
|
||||||
|
|
||||||
ModInfo & modInfo = modData[modName];
|
ModInfo & modInfo = modData[modName];
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ bool ContentTypeHandler::loadMod(const std::string & modName, bool validate)
|
|||||||
const std::string & name = entry.first;
|
const std::string & name = entry.first;
|
||||||
JsonNode & data = entry.second;
|
JsonNode & data = entry.second;
|
||||||
|
|
||||||
if (data.meta != modName)
|
if (data.getModScope() != modName)
|
||||||
{
|
{
|
||||||
// in this scenario, entire object record comes from another mod
|
// in this scenario, entire object record comes from another mod
|
||||||
// normally, this is used to "patch" object from another mod (which is legal)
|
// normally, this is used to "patch" object from another mod (which is legal)
|
||||||
@ -112,7 +112,7 @@ bool ContentTypeHandler::loadMod(const std::string & modName, bool validate)
|
|||||||
// - another mod attempts to add object into this mod (technically can be supported, but might lead to weird edge cases)
|
// - another mod attempts to add object into this mod (technically can be supported, but might lead to weird edge cases)
|
||||||
// - another mod attempts to edit object from this mod that no longer exist - DANGER since such patch likely has very incomplete data
|
// - another mod attempts to edit object from this mod that no longer exist - DANGER since such patch likely has very incomplete data
|
||||||
// so emit warning and skip such case
|
// so emit warning and skip such case
|
||||||
logMod->warn("Mod '%s' attempts to edit object '%s' of type '%s' from mod '%s' but no such object exist!", data.meta, name, objectName, modName);
|
logMod->warn("Mod '%s' attempts to edit object '%s' of type '%s' from mod '%s' but no such object exist!", data.getModScope(), name, objectName, modName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ void ContentTypeHandler::afterLoadFinalization()
|
|||||||
if (data.second.modData.isNull())
|
if (data.second.modData.isNull())
|
||||||
{
|
{
|
||||||
for (auto node : data.second.patches.Struct())
|
for (auto node : data.second.patches.Struct())
|
||||||
logMod->warn("Mod '%s' have added patch for object '%s' from mod '%s', but this mod was not loaded or has no new objects.", node.second.meta, node.first, data.first);
|
logMod->warn("Mod '%s' have added patch for object '%s' from mod '%s', but this mod was not loaded or has no new objects.", node.second.getModScope(), node.first, data.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto & otherMod : modData)
|
for(auto & otherMod : modData)
|
||||||
|
@ -180,12 +180,12 @@ void CIdentifierStorage::requestIdentifier(const std::string & scope, const std:
|
|||||||
|
|
||||||
void CIdentifierStorage::requestIdentifier(const std::string & type, const JsonNode & name, const std::function<void(si32)> & callback) const
|
void CIdentifierStorage::requestIdentifier(const std::string & type, const JsonNode & name, const std::function<void(si32)> & callback) const
|
||||||
{
|
{
|
||||||
requestIdentifier(ObjectCallback::fromNameAndType(name.meta, type, name.String(), callback, false));
|
requestIdentifier(ObjectCallback::fromNameAndType(name.getModScope(), type, name.String(), callback, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIdentifierStorage::requestIdentifier(const JsonNode & name, const std::function<void(si32)> & callback) const
|
void CIdentifierStorage::requestIdentifier(const JsonNode & name, const std::function<void(si32)> & callback) const
|
||||||
{
|
{
|
||||||
requestIdentifier(ObjectCallback::fromNameWithType(name.meta, name.String(), callback, false));
|
requestIdentifier(ObjectCallback::fromNameWithType(name.getModScope(), name.String(), callback, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIdentifierStorage::tryRequestIdentifier(const std::string & scope, const std::string & type, const std::string & name, const std::function<void(si32)> & callback) const
|
void CIdentifierStorage::tryRequestIdentifier(const std::string & scope, const std::string & type, const std::string & name, const std::function<void(si32)> & callback) const
|
||||||
@ -195,7 +195,7 @@ void CIdentifierStorage::tryRequestIdentifier(const std::string & scope, const s
|
|||||||
|
|
||||||
void CIdentifierStorage::tryRequestIdentifier(const std::string & type, const JsonNode & name, const std::function<void(si32)> & callback) const
|
void CIdentifierStorage::tryRequestIdentifier(const std::string & type, const JsonNode & name, const std::function<void(si32)> & callback) const
|
||||||
{
|
{
|
||||||
requestIdentifier(ObjectCallback::fromNameAndType(name.meta, type, name.String(), callback, true));
|
requestIdentifier(ObjectCallback::fromNameAndType(name.getModScope(), type, name.String(), callback, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<si32> CIdentifierStorage::getIdentifier(const std::string & scope, const std::string & type, const std::string & name, bool silent) const
|
std::optional<si32> CIdentifierStorage::getIdentifier(const std::string & scope, const std::string & type, const std::string & name, bool silent) const
|
||||||
@ -210,7 +210,7 @@ std::optional<si32> CIdentifierStorage::getIdentifier(const std::string & type,
|
|||||||
{
|
{
|
||||||
assert(state != ELoadingState::LOADING);
|
assert(state != ELoadingState::LOADING);
|
||||||
|
|
||||||
auto options = ObjectCallback::fromNameAndType(name.meta, type, name.String(), std::function<void(si32)>(), silent);
|
auto options = ObjectCallback::fromNameAndType(name.getModScope(), type, name.String(), std::function<void(si32)>(), silent);
|
||||||
|
|
||||||
return getIdentifierImpl(options, silent);
|
return getIdentifierImpl(options, silent);
|
||||||
}
|
}
|
||||||
@ -219,7 +219,7 @@ std::optional<si32> CIdentifierStorage::getIdentifier(const JsonNode & name, boo
|
|||||||
{
|
{
|
||||||
assert(state != ELoadingState::LOADING);
|
assert(state != ELoadingState::LOADING);
|
||||||
|
|
||||||
auto options = ObjectCallback::fromNameWithType(name.meta, name.String(), std::function<void(si32)>(), silent);
|
auto options = ObjectCallback::fromNameWithType(name.getModScope(), name.String(), std::function<void(si32)>(), silent);
|
||||||
return getIdentifierImpl(options, silent);
|
return getIdentifierImpl(options, silent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ void Rewardable::Info::init(const JsonNode & objectConfig, const std::string & o
|
|||||||
|
|
||||||
auto loadString = [&](const JsonNode & entry, const TextIdentifier & textID){
|
auto loadString = [&](const JsonNode & entry, const TextIdentifier & textID){
|
||||||
if (entry.isString() && !entry.String().empty() && entry.String()[0] != '@')
|
if (entry.isString() && !entry.String().empty() && entry.String()[0] != '@')
|
||||||
VLC->generaltexth->registerString(entry.meta, textID, entry.String());
|
VLC->generaltexth->registerString(entry.getModScope(), textID, entry.String());
|
||||||
};
|
};
|
||||||
|
|
||||||
parameters = objectConfig;
|
parameters = objectConfig;
|
||||||
@ -201,8 +201,8 @@ void Rewardable::Info::configureReward(Rewardable::Configuration & object, CRand
|
|||||||
|
|
||||||
for ( auto node : source["changeCreatures"].Struct() )
|
for ( auto node : source["changeCreatures"].Struct() )
|
||||||
{
|
{
|
||||||
CreatureID from(VLC->identifiers()->getIdentifier(node.second.meta, "creature", node.first).value());
|
CreatureID from(VLC->identifiers()->getIdentifier(node.second.getModScope(), "creature", node.first).value());
|
||||||
CreatureID dest(VLC->identifiers()->getIdentifier(node.second.meta, "creature", node.second.String()).value());
|
CreatureID dest(VLC->identifiers()->getIdentifier(node.second.getModScope(), "creature", node.second.String()).value());
|
||||||
|
|
||||||
reward.extraComponents.emplace_back(ComponentType::CREATURE, dest);
|
reward.extraComponents.emplace_back(ComponentType::CREATURE, dest);
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ void JsonDeserializer::serializeInternal(const std::string & fieldName, si32 & v
|
|||||||
if(rawId < 0) //may be, user has installed the mod into another directory...
|
if(rawId < 0) //may be, user has installed the mod into another directory...
|
||||||
{
|
{
|
||||||
auto internalId = vstd::splitStringToPair(identifier, ':').second;
|
auto internalId = vstd::splitStringToPair(identifier, ':').second;
|
||||||
auto currentScope = getCurrent().meta;
|
auto currentScope = getCurrent().getModScope();
|
||||||
auto actualId = currentScope.length() > 0 ? currentScope + ":" + internalId : internalId;
|
auto actualId = currentScope.length() > 0 ? currentScope + ":" + internalId : internalId;
|
||||||
|
|
||||||
rawId = decoder(actualId);
|
rawId = decoder(actualId);
|
||||||
|
@ -719,7 +719,7 @@ CSpell * CSpellHandler::loadFromJson(const std::string & scope, const JsonNode &
|
|||||||
{
|
{
|
||||||
const int chance = static_cast<int>(node.second.Integer());
|
const int chance = static_cast<int>(node.second.Integer());
|
||||||
|
|
||||||
VLC->identifiers()->requestIdentifier(node.second.meta, "faction", node.first, [=](si32 factionID)
|
VLC->identifiers()->requestIdentifier(node.second.getModScope(), "faction", node.first, [=](si32 factionID)
|
||||||
{
|
{
|
||||||
spell->probabilities[FactionID(factionID)] = chance;
|
spell->probabilities[FactionID(factionID)] = chance;
|
||||||
});
|
});
|
||||||
@ -742,7 +742,7 @@ CSpell * CSpellHandler::loadFromJson(const std::string & scope, const JsonNode &
|
|||||||
{
|
{
|
||||||
if(counteredSpell.second.Bool())
|
if(counteredSpell.second.Bool())
|
||||||
{
|
{
|
||||||
VLC->identifiers()->requestIdentifier(counteredSpell.second.meta, "spell", counteredSpell.first, [=](si32 id)
|
VLC->identifiers()->requestIdentifier(counteredSpell.second.getModScope(), "spell", counteredSpell.first, [=](si32 id)
|
||||||
{
|
{
|
||||||
spell->counteredSpells.emplace_back(id);
|
spell->counteredSpells.emplace_back(id);
|
||||||
});
|
});
|
||||||
|
@ -544,7 +544,7 @@ void TargetCondition::loadConditions(const JsonNode & source, bool exclusive, bo
|
|||||||
|
|
||||||
ModUtility::parseIdentifier(keyValue.first, scope, type, identifier);
|
ModUtility::parseIdentifier(keyValue.first, scope, type, identifier);
|
||||||
|
|
||||||
item = itemFactory->createConfigurable(keyValue.second.meta, type, identifier);
|
item = itemFactory->createConfigurable(keyValue.second.getModScope(), type, identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(item)
|
if(item)
|
||||||
|
@ -347,8 +347,8 @@ void LuaContext::pop(JsonNode & value)
|
|||||||
break;
|
break;
|
||||||
case LUA_TTABLE:
|
case LUA_TTABLE:
|
||||||
{
|
{
|
||||||
JsonNode asVector(JsonNode::JsonType::DATA_VECTOR);
|
JsonNode asVector;
|
||||||
JsonNode asStruct(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode asStruct;
|
||||||
|
|
||||||
lua_pushnil(L); /* first key */
|
lua_pushnil(L); /* first key */
|
||||||
|
|
||||||
|
@ -98,12 +98,12 @@ bool LuaSpellEffect::applicable(Problem & problem, const Mechanics * m, const Ef
|
|||||||
for(const auto & dest : target)
|
for(const auto & dest : target)
|
||||||
{
|
{
|
||||||
JsonNode targetData;
|
JsonNode targetData;
|
||||||
targetData.Vector().push_back(JsonUtils::intNode(dest.hexValue.hex));
|
targetData.Vector().emplace_back(dest.hexValue.hex);
|
||||||
|
|
||||||
if(dest.unitValue)
|
if(dest.unitValue)
|
||||||
targetData.Vector().push_back(JsonUtils::intNode(dest.unitValue->unitId()));
|
targetData.Vector().emplace_back(dest.unitValue->unitId());
|
||||||
else
|
else
|
||||||
targetData.Vector().push_back(JsonUtils::intNode(-1));
|
targetData.Vector().emplace_back(-1);
|
||||||
|
|
||||||
requestP.Vector().push_back(targetData);
|
requestP.Vector().push_back(targetData);
|
||||||
}
|
}
|
||||||
@ -141,12 +141,12 @@ void LuaSpellEffect::apply(ServerCallback * server, const Mechanics * m, const E
|
|||||||
for(const auto & dest : target)
|
for(const auto & dest : target)
|
||||||
{
|
{
|
||||||
JsonNode targetData;
|
JsonNode targetData;
|
||||||
targetData.Vector().push_back(JsonUtils::intNode(dest.hexValue.hex));
|
targetData.Vector().emplace_back(dest.hexValue.hex);
|
||||||
|
|
||||||
if(dest.unitValue)
|
if(dest.unitValue)
|
||||||
targetData.Vector().push_back(JsonUtils::intNode(dest.unitValue->unitId()));
|
targetData.Vector().emplace_back(dest.unitValue->unitId());
|
||||||
else
|
else
|
||||||
targetData.Vector().push_back(JsonUtils::intNode(-1));
|
targetData.Vector().emplace_back(-1);
|
||||||
|
|
||||||
requestP.Vector().push_back(targetData);
|
requestP.Vector().push_back(targetData);
|
||||||
}
|
}
|
||||||
|
@ -183,8 +183,8 @@ bool LuaStack::tryGet(int position, JsonNode & value)
|
|||||||
return tryGet(position, value.String());
|
return tryGet(position, value.String());
|
||||||
case LUA_TTABLE:
|
case LUA_TTABLE:
|
||||||
{
|
{
|
||||||
JsonNode asVector(JsonNode::JsonType::DATA_VECTOR);
|
JsonNode asVector;
|
||||||
JsonNode asStruct(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode asStruct;
|
||||||
|
|
||||||
lua_pushnil(L); /* first key */
|
lua_pushnil(L); /* first key */
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ TEST_F(CCreatureTest, RegistersIcons)
|
|||||||
|
|
||||||
TEST_F(CCreatureTest, DISABLED_JsonUpdate)
|
TEST_F(CCreatureTest, DISABLED_JsonUpdate)
|
||||||
{
|
{
|
||||||
JsonNode data(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode data;
|
||||||
|
|
||||||
JsonNode & config = data["config"];
|
JsonNode & config = data["config"];
|
||||||
config["cost"]["gold"].Integer() = 750;
|
config["cost"]["gold"].Integer() = 750;
|
||||||
@ -106,7 +106,7 @@ TEST_F(CCreatureTest, DISABLED_JsonUpdate)
|
|||||||
|
|
||||||
TEST_F(CCreatureTest, DISABLED_JsonAddBonus)
|
TEST_F(CCreatureTest, DISABLED_JsonAddBonus)
|
||||||
{
|
{
|
||||||
JsonNode data(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode data;
|
||||||
|
|
||||||
auto b = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::BLOCKS_RETALIATION, BonusSource::CREATURE_ABILITY, 17, BonusSourceID(CreatureID(42)), BonusSubtypeID(CreatureID(43)), BonusValueType::BASE_NUMBER);
|
auto b = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::BLOCKS_RETALIATION, BonusSource::CREATURE_ABILITY, 17, BonusSourceID(CreatureID(42)), BonusSubtypeID(CreatureID(43)), BonusValueType::BASE_NUMBER);
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ TEST_F(CCreatureTest, DISABLED_JsonAddBonus)
|
|||||||
|
|
||||||
TEST_F(CCreatureTest, DISABLED_JsonRemoveBonus)
|
TEST_F(CCreatureTest, DISABLED_JsonRemoveBonus)
|
||||||
{
|
{
|
||||||
JsonNode data(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode data;
|
||||||
|
|
||||||
auto b1 = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::BLOCKS_RETALIATION, BonusSource::CREATURE_ABILITY, 17, BonusSourceID(CreatureID(42)), BonusSubtypeID(CreatureID(43)), BonusValueType::BASE_NUMBER);
|
auto b1 = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::BLOCKS_RETALIATION, BonusSource::CREATURE_ABILITY, 17, BonusSourceID(CreatureID(42)), BonusSubtypeID(CreatureID(43)), BonusValueType::BASE_NUMBER);
|
||||||
subject->addNewBonus(b1);
|
subject->addNewBonus(b1);
|
||||||
|
@ -420,6 +420,6 @@ TEST_F(CGameStateTest, updateEntity)
|
|||||||
|
|
||||||
JsonNode actual;
|
JsonNode actual;
|
||||||
EXPECT_CALL(services, updateEntity(Eq(Metatype::CREATURE), Eq(424242), _)).WillOnce(SaveArg<2>(&actual));
|
EXPECT_CALL(services, updateEntity(Eq(Metatype::CREATURE), Eq(424242), _)).WillOnce(SaveArg<2>(&actual));
|
||||||
gameState->updateEntity(Metatype::CREATURE, 424242, JsonUtils::stringNode("TEST"));
|
gameState->updateEntity(Metatype::CREATURE, 424242, JsonNode("TEST"));
|
||||||
EXPECT_EQ(actual.String(), "TEST");
|
EXPECT_EQ(actual.String(), "TEST");
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ static JsonNode getFromArchive(CZipLoader & archive, const std::string & archive
|
|||||||
|
|
||||||
auto data = archive.load(resource)->readAll();
|
auto data = archive.load(resource)->readAll();
|
||||||
|
|
||||||
JsonNode res(reinterpret_cast<char*>(data.first.get()), data.second);
|
JsonNode res(reinterpret_cast<const std::byte *>(data.first.get()), data.second);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ TEST_F(LuaSpellEffectAPITest, DISABLED_ApplicableOnExpert)
|
|||||||
|
|
||||||
JsonNode ret = context->callGlobal("applicable", params);
|
JsonNode ret = context->callGlobal("applicable", params);
|
||||||
|
|
||||||
JsonNode expected = JsonUtils::boolNode(true);
|
JsonNode expected(true);
|
||||||
|
|
||||||
JsonComparer cmp(false);
|
JsonComparer cmp(false);
|
||||||
cmp.compare("applicable result", ret, expected);
|
cmp.compare("applicable result", ret, expected);
|
||||||
@ -65,7 +65,7 @@ TEST_F(LuaSpellEffectAPITest, DISABLED_NotApplicableOnAdvanced)
|
|||||||
|
|
||||||
JsonNode ret = context->callGlobal("applicable", params);
|
JsonNode ret = context->callGlobal("applicable", params);
|
||||||
|
|
||||||
JsonNode expected = JsonUtils::boolNode(false);
|
JsonNode expected(false);
|
||||||
|
|
||||||
JsonComparer cmp(false);
|
JsonComparer cmp(false);
|
||||||
cmp.compare("applicable result", ret, expected);
|
cmp.compare("applicable result", ret, expected);
|
||||||
@ -84,7 +84,7 @@ TEST_F(LuaSpellEffectAPITest, DISABLED_ApplicableOnLeftSideOfField)
|
|||||||
BattleHex hex(2,2);
|
BattleHex hex(2,2);
|
||||||
|
|
||||||
JsonNode first;
|
JsonNode first;
|
||||||
first.Vector().push_back(JsonUtils::intNode(hex.hex));
|
first.Vector().push_back(JsonNode(hex.hex));
|
||||||
first.Vector().push_back(JsonNode());
|
first.Vector().push_back(JsonNode());
|
||||||
|
|
||||||
JsonNode targets;
|
JsonNode targets;
|
||||||
@ -94,7 +94,7 @@ TEST_F(LuaSpellEffectAPITest, DISABLED_ApplicableOnLeftSideOfField)
|
|||||||
|
|
||||||
JsonNode ret = context->callGlobal("applicableTarget", params);
|
JsonNode ret = context->callGlobal("applicableTarget", params);
|
||||||
|
|
||||||
JsonNode expected = JsonUtils::boolNode(true);
|
JsonNode expected(true);
|
||||||
|
|
||||||
JsonComparer cmp(false);
|
JsonComparer cmp(false);
|
||||||
cmp.compare("applicable result", ret, expected);
|
cmp.compare("applicable result", ret, expected);
|
||||||
@ -113,8 +113,8 @@ TEST_F(LuaSpellEffectAPITest, DISABLED_NotApplicableOnRightSideOfField)
|
|||||||
BattleHex hex(11,2);
|
BattleHex hex(11,2);
|
||||||
|
|
||||||
JsonNode first;
|
JsonNode first;
|
||||||
first.Vector().push_back(JsonUtils::intNode(hex.hex));
|
first.Vector().emplace_back(hex.hex);
|
||||||
first.Vector().push_back(JsonUtils::intNode(-1));
|
first.Vector().emplace_back(-1);
|
||||||
|
|
||||||
JsonNode targets;
|
JsonNode targets;
|
||||||
targets.Vector().push_back(first);
|
targets.Vector().push_back(first);
|
||||||
@ -123,7 +123,7 @@ TEST_F(LuaSpellEffectAPITest, DISABLED_NotApplicableOnRightSideOfField)
|
|||||||
|
|
||||||
JsonNode ret = context->callGlobal("applicableTarget", params);
|
JsonNode ret = context->callGlobal("applicableTarget", params);
|
||||||
|
|
||||||
JsonNode expected = JsonUtils::boolNode(false);
|
JsonNode expected(false);
|
||||||
|
|
||||||
JsonComparer cmp(false);
|
JsonComparer cmp(false);
|
||||||
cmp.compare("applicable result", ret, expected);
|
cmp.compare("applicable result", ret, expected);
|
||||||
@ -138,14 +138,14 @@ TEST_F(LuaSpellEffectAPITest, DISABLED_ApplyMoveUnit)
|
|||||||
BattleHex hex1(11,2);
|
BattleHex hex1(11,2);
|
||||||
|
|
||||||
JsonNode unit;
|
JsonNode unit;
|
||||||
unit.Vector().push_back(JsonUtils::intNode(hex1.hex));
|
unit.Vector().emplace_back(hex1.hex);
|
||||||
unit.Vector().push_back(JsonUtils::intNode(42));
|
unit.Vector().emplace_back(42);
|
||||||
|
|
||||||
BattleHex hex2(5,4);
|
BattleHex hex2(5,4);
|
||||||
|
|
||||||
JsonNode destination;
|
JsonNode destination;
|
||||||
destination.Vector().push_back(JsonUtils::intNode(hex2.hex));
|
destination.Vector().emplace_back(hex2.hex);
|
||||||
destination.Vector().push_back(JsonUtils::intNode(-1));
|
destination.Vector().emplace_back(-1);
|
||||||
|
|
||||||
JsonNode targets;
|
JsonNode targets;
|
||||||
targets.Vector().push_back(unit);
|
targets.Vector().push_back(unit);
|
||||||
|
@ -91,7 +91,7 @@ public:
|
|||||||
|
|
||||||
JsonNode saveRequest(const std::string &, const JsonNode & parameters)
|
JsonNode saveRequest(const std::string &, const JsonNode & parameters)
|
||||||
{
|
{
|
||||||
JsonNode response = JsonUtils::boolNode(true);
|
JsonNode response(true);
|
||||||
|
|
||||||
request = parameters;
|
request = parameters;
|
||||||
return response;
|
return response;
|
||||||
@ -99,7 +99,7 @@ public:
|
|||||||
|
|
||||||
JsonNode saveRequest2(ServerCallback *, const std::string &, const JsonNode & parameters)
|
JsonNode saveRequest2(ServerCallback *, const std::string &, const JsonNode & parameters)
|
||||||
{
|
{
|
||||||
JsonNode response = JsonUtils::boolNode(true);
|
JsonNode response(true);
|
||||||
|
|
||||||
request = parameters;
|
request = parameters;
|
||||||
return response;
|
return response;
|
||||||
@ -123,7 +123,7 @@ TEST_F(LuaSpellEffectTest, ApplicableRedirected)
|
|||||||
{
|
{
|
||||||
setDefaultExpectations();
|
setDefaultExpectations();
|
||||||
|
|
||||||
JsonNode response = JsonUtils::boolNode(true);
|
JsonNode response(true);
|
||||||
|
|
||||||
EXPECT_CALL(*contextMock, callGlobal(Eq("applicable"),_)).WillOnce(Return(response));//TODO: check call parameter
|
EXPECT_CALL(*contextMock, callGlobal(Eq("applicable"),_)).WillOnce(Return(response));//TODO: check call parameter
|
||||||
|
|
||||||
@ -154,12 +154,12 @@ TEST_F(LuaSpellEffectTest, ApplicableTargetRedirected)
|
|||||||
|
|
||||||
|
|
||||||
JsonNode first;
|
JsonNode first;
|
||||||
first.Vector().push_back(JsonUtils::intNode(hex1.hex));
|
first.Vector().push_back(JsonNode(hex1.hex));
|
||||||
first.Vector().push_back(JsonUtils::intNode(id1));
|
first.Vector().push_back(JsonNode(id1));
|
||||||
|
|
||||||
JsonNode second;
|
JsonNode second;
|
||||||
second.Vector().push_back(JsonUtils::intNode(hex2.hex));
|
second.Vector().push_back(JsonNode(hex2.hex));
|
||||||
second.Vector().push_back(JsonUtils::intNode(-1));
|
second.Vector().push_back(JsonNode(-1));
|
||||||
|
|
||||||
JsonNode targets;
|
JsonNode targets;
|
||||||
targets.Vector().push_back(first);
|
targets.Vector().push_back(first);
|
||||||
@ -193,8 +193,8 @@ TEST_F(LuaSpellEffectTest, ApplyRedirected)
|
|||||||
subject->apply(&serverMock, &mechanicsMock, target);
|
subject->apply(&serverMock, &mechanicsMock, target);
|
||||||
|
|
||||||
JsonNode first;
|
JsonNode first;
|
||||||
first.Vector().push_back(JsonUtils::intNode(hex1.hex));
|
first.Vector().push_back(JsonNode(hex1.hex));
|
||||||
first.Vector().push_back(JsonUtils::intNode(id1));
|
first.Vector().push_back(JsonNode(id1));
|
||||||
|
|
||||||
JsonNode targets;
|
JsonNode targets;
|
||||||
targets.Vector().push_back(first);
|
targets.Vector().push_back(first);
|
||||||
|
@ -23,7 +23,7 @@ ScriptFixture::~ScriptFixture() = default;
|
|||||||
|
|
||||||
void ScriptFixture::loadScriptFromFile(const std::string & path)
|
void ScriptFixture::loadScriptFromFile(const std::string & path)
|
||||||
{
|
{
|
||||||
JsonNode scriptConfig(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode scriptConfig;
|
||||||
scriptConfig["source"].String() = path;
|
scriptConfig["source"].String() = path;
|
||||||
loadScript(scriptConfig);
|
loadScript(scriptConfig);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ TEST_F(TargetConditionTest, SerializesCorrectly)
|
|||||||
|
|
||||||
EXPECT_CALL(factoryMock, createConfigurable(Eq(""), Eq("bonus"), Eq("UNDEAD"))).WillOnce(Return(normalItem));
|
EXPECT_CALL(factoryMock, createConfigurable(Eq(""), Eq("bonus"), Eq("UNDEAD"))).WillOnce(Return(normalItem));
|
||||||
|
|
||||||
JsonNode config(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode config;
|
||||||
config["noneOf"]["bonus.NON_LIVING"].String() = "normal";
|
config["noneOf"]["bonus.NON_LIVING"].String() = "normal";
|
||||||
config["anyOf"]["bonus.SIEGE_WEAPON"].String() = "absolute";
|
config["anyOf"]["bonus.SIEGE_WEAPON"].String() = "absolute";
|
||||||
config["allOf"]["bonus.UNDEAD"].String() = "normal";
|
config["allOf"]["bonus.UNDEAD"].String() = "normal";
|
||||||
|
@ -116,7 +116,7 @@ private:
|
|||||||
TEST_F(CatapultApplyTest, DISABLED_DamageToIntactPart)
|
TEST_F(CatapultApplyTest, DISABLED_DamageToIntactPart)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
JsonNode config(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode config;
|
||||||
config["targetsToAttack"].Integer() = 1;
|
config["targetsToAttack"].Integer() = 1;
|
||||||
config["chanceToNormalHit"].Integer() = 100;
|
config["chanceToNormalHit"].Integer() = 100;
|
||||||
EffectFixture::setupEffect(config);
|
EffectFixture::setupEffect(config);
|
||||||
|
@ -40,7 +40,7 @@ protected:
|
|||||||
TEST_F(CloneTest, ApplicableToValidTarget)
|
TEST_F(CloneTest, ApplicableToValidTarget)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
JsonNode config(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode config;
|
||||||
config["maxTier"].Integer() = 7;
|
config["maxTier"].Integer() = 7;
|
||||||
EffectFixture::setupEffect(config);
|
EffectFixture::setupEffect(config);
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ TEST_F(DamageApplyTest, DISABLED_DoesDamageByPercent)
|
|||||||
using namespace ::battle;
|
using namespace ::battle;
|
||||||
|
|
||||||
{
|
{
|
||||||
JsonNode config(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode config;
|
||||||
config["killByPercentage"].Bool() = true;
|
config["killByPercentage"].Bool() = true;
|
||||||
EffectFixture::setupEffect(config);
|
EffectFixture::setupEffect(config);
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ TEST_F(DamageApplyTest, DISABLED_DoesDamageByCount)
|
|||||||
using namespace ::battle;
|
using namespace ::battle;
|
||||||
|
|
||||||
{
|
{
|
||||||
JsonNode config(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode config;
|
||||||
config["killByCount"].Bool() = true;
|
config["killByCount"].Bool() = true;
|
||||||
EffectFixture::setupEffect(config);
|
EffectFixture::setupEffect(config);
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ class DispelTest : public DispelFixture
|
|||||||
TEST_F(DispelTest, DISABLED_ApplicableToAliveUnitWithTimedEffect)
|
TEST_F(DispelTest, DISABLED_ApplicableToAliveUnitWithTimedEffect)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
JsonNode config(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode config;
|
||||||
config["dispelNegative"].Bool() = true;
|
config["dispelNegative"].Bool() = true;
|
||||||
EffectFixture::setupEffect(config);
|
EffectFixture::setupEffect(config);
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ TEST_F(DispelTest, DISABLED_ApplicableToAliveUnitWithTimedEffect)
|
|||||||
TEST_F(DispelTest, DISABLED_IgnoresOwnEffects)
|
TEST_F(DispelTest, DISABLED_IgnoresOwnEffects)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
JsonNode config(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode config;
|
||||||
config["dispelPositive"].Bool() = true;
|
config["dispelPositive"].Bool() = true;
|
||||||
config["dispelNegative"].Bool() = true;
|
config["dispelNegative"].Bool() = true;
|
||||||
config["dispelNeutral"].Bool() = true;
|
config["dispelNeutral"].Bool() = true;
|
||||||
@ -165,7 +165,7 @@ public:
|
|||||||
TEST_F(DispelApplyTest, DISABLED_RemovesEffects)
|
TEST_F(DispelApplyTest, DISABLED_RemovesEffects)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
JsonNode config(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode config;
|
||||||
config["dispelPositive"].Bool() = true;
|
config["dispelPositive"].Bool() = true;
|
||||||
config["dispelNegative"].Bool() = true;
|
config["dispelNegative"].Bool() = true;
|
||||||
config["dispelNeutral"].Bool() = true;
|
config["dispelNeutral"].Bool() = true;
|
||||||
|
@ -77,7 +77,7 @@ TEST_F(HealTest, ApplicableToWoundedUnit)
|
|||||||
TEST_F(HealTest, ApplicableIfActuallyResurrects)
|
TEST_F(HealTest, ApplicableIfActuallyResurrects)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
JsonNode config(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode config;
|
||||||
config["healLevel"].String() = "resurrect";
|
config["healLevel"].String() = "resurrect";
|
||||||
config["minFullUnits"].Integer() = 5;
|
config["minFullUnits"].Integer() = 5;
|
||||||
EffectFixture::setupEffect(config);
|
EffectFixture::setupEffect(config);
|
||||||
@ -104,7 +104,7 @@ TEST_F(HealTest, ApplicableIfActuallyResurrects)
|
|||||||
TEST_F(HealTest, NotApplicableIfNotEnoughCasualties)
|
TEST_F(HealTest, NotApplicableIfNotEnoughCasualties)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
JsonNode config(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode config;
|
||||||
config["healLevel"].String() = "resurrect";
|
config["healLevel"].String() = "resurrect";
|
||||||
config["minFullUnits"].Integer() = 1;
|
config["minFullUnits"].Integer() = 1;
|
||||||
EffectFixture::setupEffect(config);
|
EffectFixture::setupEffect(config);
|
||||||
@ -130,7 +130,7 @@ TEST_F(HealTest, NotApplicableIfNotEnoughCasualties)
|
|||||||
TEST_F(HealTest, NotApplicableIfResurrectsLessThanRequired)
|
TEST_F(HealTest, NotApplicableIfResurrectsLessThanRequired)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
JsonNode config(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode config;
|
||||||
config["healLevel"].String() = "resurrect";
|
config["healLevel"].String() = "resurrect";
|
||||||
config["minFullUnits"].Integer() = 5;
|
config["minFullUnits"].Integer() = 5;
|
||||||
EffectFixture::setupEffect(config);
|
EffectFixture::setupEffect(config);
|
||||||
@ -156,7 +156,7 @@ TEST_F(HealTest, NotApplicableIfResurrectsLessThanRequired)
|
|||||||
TEST_F(HealTest, ApplicableToDeadUnit)
|
TEST_F(HealTest, ApplicableToDeadUnit)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
JsonNode config(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode config;
|
||||||
config["healLevel"].String() = "resurrect";
|
config["healLevel"].String() = "resurrect";
|
||||||
EffectFixture::setupEffect(config);
|
EffectFixture::setupEffect(config);
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ TEST_F(HealTest, ApplicableToDeadUnit)
|
|||||||
TEST_F(HealTest, DISABLED_NotApplicableIfDeadUnitIsBlocked)
|
TEST_F(HealTest, DISABLED_NotApplicableIfDeadUnitIsBlocked)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
JsonNode config(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode config;
|
||||||
config["healLevel"].String() = "resurrect";
|
config["healLevel"].String() = "resurrect";
|
||||||
EffectFixture::setupEffect(config);
|
EffectFixture::setupEffect(config);
|
||||||
}
|
}
|
||||||
@ -224,7 +224,7 @@ TEST_F(HealTest, DISABLED_NotApplicableIfDeadUnitIsBlocked)
|
|||||||
TEST_F(HealTest, DISABLED_ApplicableWithAnotherDeadUnitInSamePosition)
|
TEST_F(HealTest, DISABLED_ApplicableWithAnotherDeadUnitInSamePosition)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
JsonNode config(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode config;
|
||||||
config["healLevel"].String() = "resurrect";
|
config["healLevel"].String() = "resurrect";
|
||||||
EffectFixture::setupEffect(config);
|
EffectFixture::setupEffect(config);
|
||||||
}
|
}
|
||||||
@ -261,7 +261,7 @@ TEST_F(HealTest, DISABLED_ApplicableWithAnotherDeadUnitInSamePosition)
|
|||||||
TEST_F(HealTest, NotApplicableIfEffectValueTooLow)
|
TEST_F(HealTest, NotApplicableIfEffectValueTooLow)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
JsonNode config(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode config;
|
||||||
config["minFullUnits"].Integer() = 1;
|
config["minFullUnits"].Integer() = 1;
|
||||||
EffectFixture::setupEffect(config);
|
EffectFixture::setupEffect(config);
|
||||||
}
|
}
|
||||||
@ -328,7 +328,7 @@ protected:
|
|||||||
TEST_P(HealApplyTest, DISABLED_Heals)
|
TEST_P(HealApplyTest, DISABLED_Heals)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
JsonNode config(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode config;
|
||||||
config["healLevel"].String() = HEAL_LEVEL_MAP.at(static_cast<size_t>(healLevel));
|
config["healLevel"].String() = HEAL_LEVEL_MAP.at(static_cast<size_t>(healLevel));
|
||||||
config["healPower"].String() = HEAL_POWER_MAP.at(static_cast<size_t>(healPower));
|
config["healPower"].String() = HEAL_POWER_MAP.at(static_cast<size_t>(healPower));
|
||||||
EffectFixture::setupEffect(config);
|
EffectFixture::setupEffect(config);
|
||||||
|
@ -39,7 +39,7 @@ protected:
|
|||||||
EffectFixture::setUp();
|
EffectFixture::setUp();
|
||||||
|
|
||||||
{
|
{
|
||||||
JsonNode config(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode config;
|
||||||
config["healLevel"].String() = "resurrect";
|
config["healLevel"].String() = "resurrect";
|
||||||
EffectFixture::setupEffect(config);
|
EffectFixture::setupEffect(config);
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ protected:
|
|||||||
EffectFixture::setUp();
|
EffectFixture::setUp();
|
||||||
|
|
||||||
{
|
{
|
||||||
JsonNode config(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode config;
|
||||||
config["healLevel"].String() = "resurrect";
|
config["healLevel"].String() = "resurrect";
|
||||||
config["healPower"].String() = "permanent";
|
config["healPower"].String() = "permanent";
|
||||||
EffectFixture::setupEffect(config);
|
EffectFixture::setupEffect(config);
|
||||||
|
@ -73,7 +73,7 @@ protected:
|
|||||||
|
|
||||||
toSummon = creature1;
|
toSummon = creature1;
|
||||||
|
|
||||||
JsonNode options(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode options;
|
||||||
options["id"].String() = "airElemental";
|
options["id"].String() = "airElemental";
|
||||||
options["exclusive"].Bool() = exclusive;
|
options["exclusive"].Bool() = exclusive;
|
||||||
options["summonSameUnit"].Bool() = summonSameUnit;
|
options["summonSameUnit"].Bool() = summonSameUnit;
|
||||||
@ -202,7 +202,7 @@ protected:
|
|||||||
permanent = ::testing::get<0>(GetParam());
|
permanent = ::testing::get<0>(GetParam());
|
||||||
summonByHealth = ::testing::get<1>(GetParam());
|
summonByHealth = ::testing::get<1>(GetParam());
|
||||||
|
|
||||||
JsonNode options(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode options;
|
||||||
options["id"].String() = "airElemental";
|
options["id"].String() = "airElemental";
|
||||||
options["permanent"].Bool() = permanent;
|
options["permanent"].Bool() = permanent;
|
||||||
options["summonByHealth"].Bool() = summonByHealth;
|
options["summonByHealth"].Bool() = summonByHealth;
|
||||||
|
@ -77,11 +77,11 @@ TEST_P(TimedApplyTest, DISABLED_ChangesBonuses)
|
|||||||
Bonus testBonus2(BonusDuration::N_TURNS, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 3, BonusSourceID(), BonusSubtypeID(PrimarySkill::KNOWLEDGE));
|
Bonus testBonus2(BonusDuration::N_TURNS, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 3, BonusSourceID(), BonusSubtypeID(PrimarySkill::KNOWLEDGE));
|
||||||
testBonus2.turnsRemain = 4;
|
testBonus2.turnsRemain = 4;
|
||||||
|
|
||||||
JsonNode options(JsonNode::JsonType::DATA_STRUCT);
|
JsonNode options;
|
||||||
options["cumulative"].Bool() = cumulative;
|
options["cumulative"].Bool() = cumulative;
|
||||||
options["bonus"]["test1"] = testBonus1.toJsonNode();
|
options["bonus"]["test1"] = testBonus1.toJsonNode();
|
||||||
options["bonus"]["test2"] = testBonus2.toJsonNode();
|
options["bonus"]["test2"] = testBonus2.toJsonNode();
|
||||||
options.setMeta(ModScope::scopeBuiltin());
|
options.setModScope(ModScope::scopeBuiltin());
|
||||||
setupEffect(options);
|
setupEffect(options);
|
||||||
|
|
||||||
const uint32_t unitId = 42;
|
const uint32_t unitId = 42;
|
||||||
|
Loading…
Reference in New Issue
Block a user