1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Fix "accumulate creatures" victory condition to be in line with h3

This commit is contained in:
Ivan Savenko
2025-11-02 12:38:06 +02:00
parent e54ff1cbb2
commit 155086d802

View File

@@ -1242,17 +1242,20 @@ bool CGameState::checkForVictory(const PlayerColor & player, const EventConditio
case EventCondition::HAVE_CREATURES: case EventCondition::HAVE_CREATURES:
{ {
//check if in players armies there is enough creatures //check if in players armies there is enough creatures
int total = 0; //creature counter // NOTE: only heroes & towns are checked, in line with H3.
for(auto ai : map->getObjects<CArmedInstance>()) // Garrisons, mines, and guards of owned dwellings(!) are excluded
{ int totalCreatures = 0;
if(ai->getOwner() == player) for (const auto & hero : p->getHeroes())
{ for(const auto & elem : hero->Slots()) //iterate through army
for(const auto & elem : ai->Slots()) //iterate through army if(elem.second->getId() == condition.objectType.as<CreatureID>()) //it's searched creature
if(elem.second->getId() == condition.objectType.as<CreatureID>()) //it's searched creature totalCreatures += elem.second->getCount();
total += elem.second->getCount();
} for (const auto & town : p->getTowns())
} for(const auto & elem : town->Slots()) //iterate through army
return total >= condition.value; if(elem.second->getId() == condition.objectType.as<CreatureID>()) //it's searched creature
totalCreatures += elem.second->getCount();
return totalCreatures >= condition.value;
} }
case EventCondition::HAVE_RESOURCES: case EventCondition::HAVE_RESOURCES:
{ {