1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Merge pull request #206 from Chocimier/fixes

genBuildingRequirements is tricky one, but in tests it's seems everything is okay
This commit is contained in:
ArseniyShestakov 2016-09-04 09:02:34 +03:00 committed by GitHub
commit 5fc1fd4daf
6 changed files with 17 additions and 10 deletions

View File

@ -1378,7 +1378,7 @@ std::string CBuildWindow::getTextForState(int state)
};
ret = CGI->generaltexth->allTexts[52];
ret += "\n" + town->genBuildingRequirements(building->bid, false).toString(toStr);
ret += "\n" + town->genBuildingRequirements(building->bid).toString(toStr);
break;
}
case EBuildingState::MISSING_BASE:

View File

@ -74,6 +74,10 @@ CModListView::CModListView(QWidget *parent) :
{
loadRepositories();
}
else
{
manager->resetRepositories();
}
}
void CModListView::loadRepositories()

View File

@ -1126,7 +1126,7 @@ bool CGTownInstance::hasBuilt(BuildingID buildingID) const
return vstd::contains(builtBuildings, buildingID);
}
CBuilding::TRequired CGTownInstance::genBuildingRequirements(BuildingID buildID, bool includeUpgrade) const
CBuilding::TRequired CGTownInstance::genBuildingRequirements(BuildingID buildID) const
{
const CBuilding * building = town->buildings.at(buildID);
@ -1138,10 +1138,14 @@ CBuilding::TRequired CGTownInstance::genBuildingRequirements(BuildingID buildID,
if (!hasBuilt(id))
return id;
if (build->upgrade != BuildingID::NONE && !hasBuilt(build->upgrade))
return build->upgrade;
CBuilding::TRequired::OperatorAll requirements;
return build->requirements.morph(dependTest);
if (build->upgrade != BuildingID::NONE)
requirements.expressions.push_back(dependTest(build->upgrade));
requirements.expressions.push_back(build->requirements.morph(dependTest));
return requirements;
};
CBuilding::TRequired::OperatorAll requirements;
@ -1149,9 +1153,7 @@ CBuilding::TRequired CGTownInstance::genBuildingRequirements(BuildingID buildID,
{
const CBuilding * upgr = town->buildings.at(building->upgrade);
if (includeUpgrade)
requirements.expressions.push_back(upgr->bid);
requirements.expressions.push_back(upgr->requirements.morph(dependTest));
requirements.expressions.push_back(dependTest(upgr->bid));
}
requirements.expressions.push_back(building->requirements.morph(dependTest));

View File

@ -238,7 +238,7 @@ public:
bool armedGarrison() const; //true if town has creatures in garrison or garrisoned hero
int getTownLevel() const;
CBuilding::TRequired genBuildingRequirements(BuildingID build, bool includeUpgrade=true) const;
CBuilding::TRequired genBuildingRequirements(BuildingID build) const;
void mergeGarrisonOnSiege() const; // merge garrison into army of visiting hero
void removeCapitols (PlayerColor owner) const;

View File

@ -857,6 +857,7 @@ void CGOnceVisitable::initObj()
info[0].reward.bonuses.push_back(bonus);
info[1].reward.bonuses.push_back(bonus);
info[0].message.addTxt(MetaString::ADVOB_TXT, 162);
info[0].message.addReplacement(VLC->arth->artifacts[info[0].reward.artifacts.back()]->Name());
info[1].message.addTxt(MetaString::ADVOB_TXT, 163);
}
break;

View File

@ -1659,7 +1659,7 @@ std::string CGShrine::getHoverText(PlayerColor player) const
std::string CGShrine::getHoverText(const CGHeroInstance * hero) const
{
std::string hoverName = getHoverText(hero->tempOwner);
if(vstd::contains(hero->spells, spell)) //hero knows that spell
if(wasVisited(hero->tempOwner) && vstd::contains(hero->spells, spell)) //know what spell there is and hero knows that spell
hoverName += "\n\n" + VLC->generaltexth->allTexts[354]; // (Already learned)
return hoverName;
}