1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Water heroes will now be correctly banned on random maps.

This commit is contained in:
Tomasz Zieliński 2023-07-17 16:23:34 +02:00
parent bda126a1fd
commit fbd1d728ec
2 changed files with 20 additions and 0 deletions

View File

@ -413,6 +413,7 @@ void CMapGenerator::addHeaderInfo()
m.difficulty = 1;
addPlayerInfo();
m.waterMap = (mapGenOptions.getWaterContent() != EWaterContent::EWaterContent::NONE);
banWaterHeroes();
}
int CMapGenerator::getNextMonlithIndex()
@ -452,6 +453,24 @@ const std::vector<ArtifactID> & CMapGenerator::getAllPossibleQuestArtifacts() co
return questArtifacts;
}
void CMapGenerator::banWaterHeroes()
{
//This also bans only-land heroes on wazter maps
auto isWaterMap = map->getMap(this).isWaterMap();
for (int j = 0; j < map->getMap(this).allowedHeroes.size(); j++)
{
if (map->getMap(this).allowedHeroes[j])
{
auto* h = dynamic_cast<const CHero*>(VLC->heroTypes()->getByIndex(j));
if ((h->onlyOnWaterMap && !isWaterMap) || (h->onlyOnMapWithoutWater && isWaterMap)) //TODO: Refactor? Move to hero?
{
banHero(HeroTypeID(j));
}
}
}
}
const std::vector<HeroTypeID> CMapGenerator::getAllPossibleHeroes() const
{
auto isWaterMap = map->getMap(this).isWaterMap();

View File

@ -63,6 +63,7 @@ public:
int getPrisonsRemaning() const;
std::shared_ptr<CZonePlacer> getZonePlacer() const;
const std::vector<ArtifactID> & getAllPossibleQuestArtifacts() const;
void banWaterHeroes();
const std::vector<HeroTypeID> getAllPossibleHeroes() const;
void banQuestArt(const ArtifactID & id);
void banHero(const HeroTypeID& id);