mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-15 00:05:02 +02:00
check amount of artifacts on hero when checking requirements of a quest that requires artifact(s)
fixes case when 2 or more identical artifacts are required
This commit is contained in:
@ -112,11 +112,16 @@ bool CQuest::checkQuest(const CGHeroInstance * h) const
|
||||
return true;
|
||||
return false;
|
||||
case MISSION_ART:
|
||||
for(auto & elem : m5arts)
|
||||
// if the object was deserialized
|
||||
if(artifactsRequirements.empty())
|
||||
for(auto id : m5arts)
|
||||
++artifactsRequirements[id];
|
||||
|
||||
for(const auto & elem : artifactsRequirements)
|
||||
{
|
||||
if(h->hasArt(elem, false, true))
|
||||
continue;
|
||||
return false; //if the artifact was not found
|
||||
// check required amount of artifacts
|
||||
if(h->getArtPosCount(elem.first, false, true, true) < elem.second)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
case MISSION_ARMY:
|
||||
@ -417,6 +422,12 @@ void CQuest::getCompletionText(MetaString &iwText, std::vector<Component> &compo
|
||||
}
|
||||
}
|
||||
|
||||
void CQuest::addArtifactID(ui16 id)
|
||||
{
|
||||
m5arts.push_back(id);
|
||||
++artifactsRequirements[id];
|
||||
}
|
||||
|
||||
void CQuest::serializeJson(JsonSerializeFormat & handler, const std::string & fieldName)
|
||||
{
|
||||
auto q = handler.enterStruct(fieldName);
|
||||
|
Reference in New Issue
Block a user