mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Win/loss conditions now use VariantIdentifier. Removed non-implemented
options
This commit is contained in:
@@ -1380,7 +1380,7 @@ bool CGameState::checkForVictory(const PlayerColor & player, const EventConditio
|
||||
case EventCondition::HAVE_ARTIFACT: //check if any hero has winning artifact
|
||||
{
|
||||
for(const auto & elem : p->heroes)
|
||||
if(elem->hasArt(ArtifactID(condition.objectType)))
|
||||
if(elem->hasArt(condition.objectType.as<ArtifactID>()))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -1396,7 +1396,7 @@ bool CGameState::checkForVictory(const PlayerColor & player, const EventConditio
|
||||
&& (ai = dynamic_cast<const CArmedInstance *>(object.get()))) //contains army
|
||||
{
|
||||
for(const auto & elem : ai->Slots()) //iterate through army
|
||||
if(elem.second->type->getIndex() == condition.objectType) //it's searched creature
|
||||
if(elem.second->getId() == condition.objectType.as<CreatureID>()) //it's searched creature
|
||||
total += elem.second->count;
|
||||
}
|
||||
}
|
||||
@@ -1404,20 +1404,20 @@ bool CGameState::checkForVictory(const PlayerColor & player, const EventConditio
|
||||
}
|
||||
case EventCondition::HAVE_RESOURCES:
|
||||
{
|
||||
return p->resources[condition.objectType] >= condition.value;
|
||||
return p->resources[condition.objectType.as<GameResID>()] >= condition.value;
|
||||
}
|
||||
case EventCondition::HAVE_BUILDING:
|
||||
{
|
||||
if (condition.object) // specific town
|
||||
{
|
||||
const auto * t = dynamic_cast<const CGTownInstance *>(condition.object);
|
||||
return (t->tempOwner == player && t->hasBuilt(BuildingID(condition.objectType)));
|
||||
return (t->tempOwner == player && t->hasBuilt(condition.objectType.as<BuildingID>()));
|
||||
}
|
||||
else // any town
|
||||
{
|
||||
for (const CGTownInstance * t : p->towns)
|
||||
{
|
||||
if (t->hasBuilt(BuildingID(condition.objectType)))
|
||||
if (t->hasBuilt(condition.objectType.as<BuildingID>()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -1436,7 +1436,7 @@ bool CGameState::checkForVictory(const PlayerColor & player, const EventConditio
|
||||
{
|
||||
for(const auto & elem : map->objects) // mode B - destroy all objects of this type
|
||||
{
|
||||
if(elem && elem->ID.getNum() == condition.objectType)
|
||||
if(elem && elem->ID == condition.objectType.as<MapObjectID>())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -1457,7 +1457,7 @@ bool CGameState::checkForVictory(const PlayerColor & player, const EventConditio
|
||||
for(const auto & elem : map->objects) // mode B - flag all objects of this type
|
||||
{
|
||||
//check not flagged objs
|
||||
if ( elem && elem->ID.getNum() == condition.objectType && team.count(elem->tempOwner) == 0 )
|
||||
if ( elem && elem->ID == condition.objectType.as<MapObjectID>() && team.count(elem->tempOwner) == 0 )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -1466,8 +1466,8 @@ bool CGameState::checkForVictory(const PlayerColor & player, const EventConditio
|
||||
case EventCondition::TRANSPORT:
|
||||
{
|
||||
const auto * t = dynamic_cast<const CGTownInstance *>(condition.object);
|
||||
return (t->visitingHero && t->visitingHero->hasArt(ArtifactID(condition.objectType))) ||
|
||||
(t->garrisonHero && t->garrisonHero->hasArt(ArtifactID(condition.objectType)));
|
||||
return (t->visitingHero && t->visitingHero->hasArt(condition.objectType.as<ArtifactID>())) ||
|
||||
(t->garrisonHero && t->garrisonHero->hasArt(condition.objectType.as<ArtifactID>()));
|
||||
}
|
||||
case EventCondition::DAYS_PASSED:
|
||||
{
|
||||
@@ -1488,24 +1488,6 @@ bool CGameState::checkForVictory(const PlayerColor & player, const EventConditio
|
||||
{
|
||||
return condition.value; // just convert to bool
|
||||
}
|
||||
case EventCondition::HAVE_0:
|
||||
{
|
||||
logGlobal->debug("Not implemented event condition type: %d", (int)condition.condition);
|
||||
//TODO: support new condition format
|
||||
return false;
|
||||
}
|
||||
case EventCondition::HAVE_BUILDING_0:
|
||||
{
|
||||
logGlobal->debug("Not implemented event condition type: %d", (int)condition.condition);
|
||||
//TODO: support new condition format
|
||||
return false;
|
||||
}
|
||||
case EventCondition::DESTROY_0:
|
||||
{
|
||||
logGlobal->debug("Not implemented event condition type: %d", (int)condition.condition);
|
||||
//TODO: support new condition format
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
logGlobal->error("Invalid event condition type: %d", (int)condition.condition);
|
||||
return false;
|
||||
@@ -1789,13 +1771,13 @@ void CGameState::obtainPlayersStats(SThievesGuildInfo & tgi, int level)
|
||||
{
|
||||
if(playerInactive(player.second.color)) //do nothing for neutral player
|
||||
continue;
|
||||
int bestCre = -1; //best creature's ID
|
||||
CreatureID bestCre; //best creature's ID
|
||||
for(const auto & elem : player.second.heroes)
|
||||
{
|
||||
for(const auto & it : elem->Slots())
|
||||
{
|
||||
int toCmp = it.second->type->getId(); //ID of creature we should compare with the best one
|
||||
if(bestCre == -1 || VLC->creh->objects[bestCre]->getAIValue() < VLC->creh->objects[toCmp]->getAIValue())
|
||||
CreatureID toCmp = it.second->type->getId(); //ID of creature we should compare with the best one
|
||||
if(bestCre == -1 || bestCre.toEntity(VLC)->getAIValue() < toCmp.toEntity(VLC)->getAIValue())
|
||||
{
|
||||
bestCre = toCmp;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user