1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Replaced remaining placeholder code with callbacks

This commit is contained in:
Ivan Savenko
2024-01-09 19:08:22 +02:00
parent e67e4430ba
commit 60ffb81b33
14 changed files with 55 additions and 52 deletions

View File

@@ -34,10 +34,10 @@ void CBankInstanceConstructor::initTypeData(const JsonNode & input)
coastVisitable = input["coastVisitable"].Bool();
}
BankConfig CBankInstanceConstructor::generateConfig(const JsonNode & level, CRandomGenerator & rng) const
BankConfig CBankInstanceConstructor::generateConfig(IGameCallback * cb, const JsonNode & level, CRandomGenerator & rng) const
{
BankConfig bc;
JsonRandom randomizer(nullptr);
JsonRandom randomizer(cb);
JsonRandom::Variables emptyVariables;
bc.chance = static_cast<ui32>(level["chance"].Float());
@@ -71,7 +71,7 @@ void CBankInstanceConstructor::randomizeObject(CBank * bank, CRandomGenerator &
cumulativeChance += static_cast<int>(node["chance"].Float());
if(selectedChance < cumulativeChance)
{
bank->setConfig(generateConfig(node, rng));
bank->setConfig(generateConfig(bank->cb, node, rng));
break;
}
}
@@ -125,10 +125,10 @@ std::vector<PossibleReward<TResources>> CBankInfo::getPossibleResourcesReward()
return result;
}
std::vector<PossibleReward<CStackBasicDescriptor>> CBankInfo::getPossibleCreaturesReward() const
std::vector<PossibleReward<CStackBasicDescriptor>> CBankInfo::getPossibleCreaturesReward(IGameCallback * cb) const
{
JsonRandom::Variables emptyVariables;
JsonRandom randomizer(nullptr);
JsonRandom randomizer(cb);
std::vector<PossibleReward<CStackBasicDescriptor>> aproximateReward;
for(const JsonNode & configEntry : config)