1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fixed bank randomization.

This commit is contained in:
DjWarmonger 2015-10-02 17:28:33 +02:00
parent 2733927527
commit abe02247b5

View File

@ -313,17 +313,15 @@ void CBankInstanceConstructor::configureObject(CGObjectInstance * object, CRando
si32 selectedChance = rng.nextInt(totalChance - 1);
//logGlobal->debugStream() << "Selected chance for bank config is " << selectedChance;
int cumulativeChance = 0;
for (auto & node : levels)
{
if (selectedChance < node["chance"].Float())
cumulativeChance += node["chance"].Float();
if (selectedChance < cumulativeChance)
{
bank->setConfig(generateConfig(node, rng));
break;
}
else
{
selectedChance -= node["chance"].Float();
}
}
}