mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-23 00:28:08 +02:00
- Pre-distribute max number of Prisons
- Minor refactor for artifact and hero pool management
This commit is contained in:
@ -130,7 +130,7 @@ void ObjectDistributor::distributeSeerHuts()
|
||||
|
||||
RandomGeneratorUtil::randomShuffle(zones, generator.rand);
|
||||
|
||||
const auto & possibleQuestArts = generator.getQuestArtsRemaning();
|
||||
const auto & possibleQuestArts = generator.getAllPossibleQuestArtifacts();
|
||||
size_t availableArts = possibleQuestArts.size();
|
||||
auto artIt = possibleQuestArts.begin();
|
||||
for (int i = zones.size() - 1; i >= 0 ; i--)
|
||||
@ -149,4 +149,25 @@ void ObjectDistributor::distributeSeerHuts()
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectDistributor::distributePrisons()
|
||||
{
|
||||
//Copy by value to random shuffle
|
||||
const auto & zoneMap = map.getZones();
|
||||
RmgMap::ZoneVector zones(zoneMap.begin(), zoneMap.end());
|
||||
|
||||
RandomGeneratorUtil::randomShuffle(zones, generator.rand);
|
||||
|
||||
size_t allowedPrisons = generator.getPrisonsRemaning();
|
||||
for (int i = zones.size() - 1; i >= 0; i--)
|
||||
{
|
||||
auto zone = zones[i].second;
|
||||
auto * tp = zone->getModificator<TreasurePlacer>();
|
||||
if (tp)
|
||||
{
|
||||
tp->setMaxPrisons(std::ceil(float(allowedPrisons) / (i + 1)));
|
||||
allowedPrisons -= tp->getMaxPrisons();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
Reference in New Issue
Block a user