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:
@@ -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:
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user