|
@@ -12,10 +12,10 @@
|
|
|
#include "JsonRandom.h"
|
|
|
|
|
|
#include <vstd/StringUtils.h>
|
|
|
+#include <vstd/RNG.h>
|
|
|
|
|
|
#include "JsonBonus.h"
|
|
|
|
|
|
-#include "../CRandomGenerator.h"
|
|
|
#include "../constants/StringConstants.h"
|
|
|
#include "../VCMI_Lib.h"
|
|
|
#include "../CArtHandler.h"
|
|
@@ -50,7 +50,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|
|
return variables.at(variableID);
|
|
|
}
|
|
|
|
|
|
- si32 JsonRandom::loadValue(const JsonNode & value, CRandomGenerator & rng, const Variables & variables, si32 defaultValue)
|
|
|
+ si32 JsonRandom::loadValue(const JsonNode & value, vstd::RNG & rng, const Variables & variables, si32 defaultValue)
|
|
|
{
|
|
|
if(value.isNull())
|
|
|
return defaultValue;
|
|
@@ -63,7 +63,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|
|
{
|
|
|
const auto & vector = value.Vector();
|
|
|
|
|
|
- size_t index= rng.getIntRange(0, vector.size()-1)();
|
|
|
+ size_t index= rng.nextInt64(0, vector.size()-1);
|
|
|
return loadValue(vector[index], rng, variables, 0);
|
|
|
}
|
|
|
if(value.isStruct())
|
|
@@ -72,7 +72,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|
|
return loadValue(value["amount"], rng, variables, defaultValue);
|
|
|
si32 min = loadValue(value["min"], rng, variables, 0);
|
|
|
si32 max = loadValue(value["max"], rng, variables, 0);
|
|
|
- return rng.getIntRange(min, max)();
|
|
|
+ return rng.nextInt64(min, max);
|
|
|
}
|
|
|
return defaultValue;
|
|
|
}
|
|
@@ -256,7 +256,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|
|
return valuesSet;
|
|
|
}
|
|
|
|
|
|
- TResources JsonRandom::loadResources(const JsonNode & value, CRandomGenerator & rng, const Variables & variables)
|
|
|
+ TResources JsonRandom::loadResources(const JsonNode & value, vstd::RNG & rng, const Variables & variables)
|
|
|
{
|
|
|
TResources ret;
|
|
|
|
|
@@ -274,7 +274,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
- TResources JsonRandom::loadResource(const JsonNode & value, CRandomGenerator & rng, const Variables & variables)
|
|
|
+ TResources JsonRandom::loadResource(const JsonNode & value, vstd::RNG & rng, const Variables & variables)
|
|
|
{
|
|
|
std::set<GameResID> defaultResources{
|
|
|
GameResID::WOOD,
|
|
@@ -295,7 +295,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
- PrimarySkill JsonRandom::loadPrimary(const JsonNode & value, CRandomGenerator & rng, const Variables & variables)
|
|
|
+ PrimarySkill JsonRandom::loadPrimary(const JsonNode & value, vstd::RNG & rng, const Variables & variables)
|
|
|
{
|
|
|
std::set<PrimarySkill> defaultSkills{
|
|
|
PrimarySkill::ATTACK,
|
|
@@ -307,7 +307,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|
|
return *RandomGeneratorUtil::nextItem(potentialPicks, rng);
|
|
|
}
|
|
|
|
|
|
- std::vector<si32> JsonRandom::loadPrimaries(const JsonNode & value, CRandomGenerator & rng, const Variables & variables)
|
|
|
+ std::vector<si32> JsonRandom::loadPrimaries(const JsonNode & value, vstd::RNG & rng, const Variables & variables)
|
|
|
{
|
|
|
std::vector<si32> ret(GameConstants::PRIMARY_SKILLS, 0);
|
|
|
std::set<PrimarySkill> defaultSkills{
|
|
@@ -339,7 +339,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
- SecondarySkill JsonRandom::loadSecondary(const JsonNode & value, CRandomGenerator & rng, const Variables & variables)
|
|
|
+ SecondarySkill JsonRandom::loadSecondary(const JsonNode & value, vstd::RNG & rng, const Variables & variables)
|
|
|
{
|
|
|
std::set<SecondarySkill> defaultSkills;
|
|
|
for(const auto & skill : VLC->skillh->objects)
|
|
@@ -350,7 +350,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|
|
return *RandomGeneratorUtil::nextItem(potentialPicks, rng);
|
|
|
}
|
|
|
|
|
|
- std::map<SecondarySkill, si32> JsonRandom::loadSecondaries(const JsonNode & value, CRandomGenerator & rng, const Variables & variables)
|
|
|
+ std::map<SecondarySkill, si32> JsonRandom::loadSecondaries(const JsonNode & value, vstd::RNG & rng, const Variables & variables)
|
|
|
{
|
|
|
std::map<SecondarySkill, si32> ret;
|
|
|
if(value.isStruct())
|
|
@@ -380,7 +380,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
- ArtifactID JsonRandom::loadArtifact(const JsonNode & value, CRandomGenerator & rng, const Variables & variables)
|
|
|
+ ArtifactID JsonRandom::loadArtifact(const JsonNode & value, vstd::RNG & rng, const Variables & variables)
|
|
|
{
|
|
|
std::set<ArtifactID> allowedArts;
|
|
|
for(const auto & artifact : VLC->arth->objects)
|
|
@@ -392,7 +392,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|
|
return cb->gameState()->pickRandomArtifact(rng, potentialPicks);
|
|
|
}
|
|
|
|
|
|
- std::vector<ArtifactID> JsonRandom::loadArtifacts(const JsonNode & value, CRandomGenerator & rng, const Variables & variables)
|
|
|
+ std::vector<ArtifactID> JsonRandom::loadArtifacts(const JsonNode & value, vstd::RNG & rng, const Variables & variables)
|
|
|
{
|
|
|
std::vector<ArtifactID> ret;
|
|
|
for (const JsonNode & entry : value.Vector())
|
|
@@ -402,7 +402,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
- SpellID JsonRandom::loadSpell(const JsonNode & value, CRandomGenerator & rng, const Variables & variables)
|
|
|
+ SpellID JsonRandom::loadSpell(const JsonNode & value, vstd::RNG & rng, const Variables & variables)
|
|
|
{
|
|
|
std::set<SpellID> defaultSpells;
|
|
|
for(const auto & spell : VLC->spellh->objects)
|
|
@@ -419,7 +419,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|
|
return *RandomGeneratorUtil::nextItem(potentialPicks, rng);
|
|
|
}
|
|
|
|
|
|
- std::vector<SpellID> JsonRandom::loadSpells(const JsonNode & value, CRandomGenerator & rng, const Variables & variables)
|
|
|
+ std::vector<SpellID> JsonRandom::loadSpells(const JsonNode & value, vstd::RNG & rng, const Variables & variables)
|
|
|
{
|
|
|
std::vector<SpellID> ret;
|
|
|
for (const JsonNode & entry : value.Vector())
|
|
@@ -429,7 +429,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
- std::vector<PlayerColor> JsonRandom::loadColors(const JsonNode & value, CRandomGenerator & rng, const Variables & variables)
|
|
|
+ std::vector<PlayerColor> JsonRandom::loadColors(const JsonNode & value, vstd::RNG & rng, const Variables & variables)
|
|
|
{
|
|
|
std::vector<PlayerColor> ret;
|
|
|
std::set<PlayerColor> defaultPlayers;
|
|
@@ -445,7 +445,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
- std::vector<HeroTypeID> JsonRandom::loadHeroes(const JsonNode & value, CRandomGenerator & rng)
|
|
|
+ std::vector<HeroTypeID> JsonRandom::loadHeroes(const JsonNode & value, vstd::RNG & rng)
|
|
|
{
|
|
|
std::vector<HeroTypeID> ret;
|
|
|
for(auto & entry : value.Vector())
|
|
@@ -455,7 +455,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
- std::vector<HeroClassID> JsonRandom::loadHeroClasses(const JsonNode & value, CRandomGenerator & rng)
|
|
|
+ std::vector<HeroClassID> JsonRandom::loadHeroClasses(const JsonNode & value, vstd::RNG & rng)
|
|
|
{
|
|
|
std::vector<HeroClassID> ret;
|
|
|
for(auto & entry : value.Vector())
|
|
@@ -465,7 +465,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
- CStackBasicDescriptor JsonRandom::loadCreature(const JsonNode & value, CRandomGenerator & rng, const Variables & variables)
|
|
|
+ CStackBasicDescriptor JsonRandom::loadCreature(const JsonNode & value, vstd::RNG & rng, const Variables & variables)
|
|
|
{
|
|
|
CStackBasicDescriptor stack;
|
|
|
|
|
@@ -494,7 +494,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|
|
return stack;
|
|
|
}
|
|
|
|
|
|
- std::vector<CStackBasicDescriptor> JsonRandom::loadCreatures(const JsonNode & value, CRandomGenerator & rng, const Variables & variables)
|
|
|
+ std::vector<CStackBasicDescriptor> JsonRandom::loadCreatures(const JsonNode & value, vstd::RNG & rng, const Variables & variables)
|
|
|
{
|
|
|
std::vector<CStackBasicDescriptor> ret;
|
|
|
for (const JsonNode & node : value.Vector())
|