mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-29 23:07:48 +02:00
Merge remote-tracking branch 'upstream/develop' into rewardable-expand
# Conflicts: # lib/JsonRandom.cpp
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
#include "StdInc.h"
|
||||
#include "JsonRandom.h"
|
||||
|
||||
#include <vstd/StringUtils.h>
|
||||
|
||||
#include "JsonNode.h"
|
||||
#include "CRandomGenerator.h"
|
||||
#include "StringConstants.h"
|
||||
@@ -123,7 +125,9 @@ namespace JsonRandom
|
||||
std::set<std::string> defaultStats(std::begin(PrimarySkill::names), std::end(PrimarySkill::names));
|
||||
for(const auto & element : value.Vector())
|
||||
{
|
||||
int id = vstd::find_pos(PrimarySkill::names, loadKey(element, rng, defaultStats));
|
||||
auto key = loadKey(element, rng, defaultStats);
|
||||
defaultStats.erase(key);
|
||||
int id = vstd::find_pos(PrimarySkill::names, key);
|
||||
if(id != -1)
|
||||
ret[id] += loadValue(element, rng);
|
||||
}
|
||||
@@ -148,13 +152,22 @@ namespace JsonRandom
|
||||
for(const auto & skill : VLC->skillh->objects)
|
||||
{
|
||||
IObjectInterface::cb->isAllowed(2, skill->getIndex());
|
||||
defaultSkills.insert(skill->getNameTextID());
|
||||
auto scopeAndName = vstd::splitStringToPair(skill->getJsonKey(), ':');
|
||||
if(scopeAndName.first == CModHandler::scopeBuiltin() || scopeAndName.first == value.meta)
|
||||
defaultSkills.insert(scopeAndName.second);
|
||||
else
|
||||
defaultSkills.insert(skill->getJsonKey());
|
||||
}
|
||||
|
||||
for(const auto & element : value.Vector())
|
||||
{
|
||||
SecondarySkill id(VLC->modh->identifiers.getIdentifier(element.meta, "skill", loadKey(element, rng, defaultSkills)).value());
|
||||
ret[id] = loadValue(element, rng);
|
||||
auto key = loadKey(element, rng, defaultSkills);
|
||||
defaultSkills.erase(key); //avoid dupicates
|
||||
if(auto identifier = VLC->modh->identifiers.getIdentifier(CModHandler::scopeGame(), "skill", key))
|
||||
{
|
||||
SecondarySkill id(identifier.value());
|
||||
ret[id] = loadValue(element, rng);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user