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:
parent
2733927527
commit
abe02247b5
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user