mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Restored replacement of town building bonuses via building upgrade
This commit is contained in:
parent
2f3f3c21df
commit
22a126cf2d
@ -50,6 +50,7 @@
|
||||
// Previously hardcoded buildings that might be used by mods
|
||||
// Section 1 - building with bonuses during sieges
|
||||
"brotherhoodOfSword" : {
|
||||
"upgradeReplacesBonuses" : true,
|
||||
"bonuses": [
|
||||
{
|
||||
"type": "MORALE",
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
BuildingID bid; //structure ID
|
||||
BuildingID upgrade; /// indicates that building "upgrade" can be improved by this, -1 = empty
|
||||
BuildingSubID::EBuildingSubID subId; /// subtype for special buildings, -1 = the building is not special
|
||||
std::set<BuildingID> overrideBids; /// the building which bonuses should be overridden with bonuses of the current building
|
||||
bool upgradeReplacesBonuses = false;
|
||||
BonusList buildingBonuses;
|
||||
|
||||
Rewardable::Info rewardableObjectInfo; ///configurable rewards for special buildings
|
||||
|
@ -242,7 +242,7 @@ void CTownHandler::loadBuildingRequirements(CBuilding * building, const JsonNode
|
||||
bidsToLoad.push_back(hlp);
|
||||
}
|
||||
|
||||
void CTownHandler::loadSpecialBuildingBonuses(const JsonNode & source, BonusList & bonusList, CBuilding * building)
|
||||
void CTownHandler::loadBuildingBonuses(const JsonNode & source, BonusList & bonusList, CBuilding * building) const
|
||||
{
|
||||
for(const auto & b : source.Vector())
|
||||
{
|
||||
@ -299,7 +299,7 @@ void CTownHandler::loadBuilding(CTown * town, const std::string & stringID, cons
|
||||
ret->resources = TResources(source["cost"]);
|
||||
ret->produce = TResources(source["produce"]);
|
||||
|
||||
loadSpecialBuildingBonuses(source["bonuses"], ret->buildingBonuses, ret);
|
||||
loadBuildingBonuses(source["bonuses"], ret->buildingBonuses, ret);
|
||||
|
||||
if(!source["configuration"].isNull())
|
||||
ret->rewardableObjectInfo.init(source["configuration"], ret->getBaseTextID());
|
||||
@ -843,7 +843,6 @@ void CTownHandler::beforeValidate(JsonNode & object)
|
||||
void CTownHandler::afterLoadFinalization()
|
||||
{
|
||||
initializeRequirements();
|
||||
initializeOverridden();
|
||||
initializeWarMachines();
|
||||
}
|
||||
|
||||
@ -874,22 +873,6 @@ void CTownHandler::initializeRequirements()
|
||||
requirementsToLoad.clear();
|
||||
}
|
||||
|
||||
void CTownHandler::initializeOverridden()
|
||||
{
|
||||
for(auto & bidHelper : overriddenBidsToLoad)
|
||||
{
|
||||
auto jsonNode = bidHelper.json;
|
||||
auto scope = bidHelper.town->getBuildingScope();
|
||||
|
||||
for(const auto & b : jsonNode.Vector())
|
||||
{
|
||||
auto bid = BuildingID(VLC->identifiers()->getIdentifier(scope, b).value());
|
||||
bidHelper.building->overrideBids.insert(bid);
|
||||
}
|
||||
}
|
||||
overriddenBidsToLoad.clear();
|
||||
}
|
||||
|
||||
void CTownHandler::initializeWarMachines()
|
||||
{
|
||||
// must be done separately after all objects are loaded
|
||||
|
@ -41,7 +41,6 @@ class DLL_LINKAGE CTownHandler : public CHandlerBase<FactionID, Faction, CFactio
|
||||
static const TPropagatorPtr & emptyPropagator();
|
||||
|
||||
void initializeRequirements();
|
||||
void initializeOverridden();
|
||||
void initializeWarMachines();
|
||||
|
||||
/// loads CBuilding's into town
|
||||
@ -84,9 +83,9 @@ public:
|
||||
std::set<FactionID> getDefaultAllowed() const;
|
||||
std::set<FactionID> getAllowedFactions(bool withTown = true) const;
|
||||
|
||||
static void loadSpecialBuildingBonuses(const JsonNode & source, BonusList & bonusList, CBuilding * building);
|
||||
|
||||
protected:
|
||||
|
||||
void loadBuildingBonuses(const JsonNode & source, BonusList & bonusList, CBuilding * building) const;
|
||||
const std::vector<std::string> & getTypeNames() const override;
|
||||
std::shared_ptr<CFaction> loadFromJson(const std::string & scope, const JsonNode & data, const std::string & identifier, size_t index) override;
|
||||
};
|
||||
|
@ -791,11 +791,22 @@ void CGTownInstance::recreateBuildingsBonuses()
|
||||
for(const auto & b : bl)
|
||||
removeBonus(b);
|
||||
|
||||
|
||||
|
||||
for(const auto & bid : builtBuildings)
|
||||
{
|
||||
// FIXME: Restore
|
||||
//if(vstd::contains(overriddenBuildings, bid)) //tricky! -> checks tavern only if no bratherhood of sword
|
||||
// continue;
|
||||
bool bonusesReplacedByUpgrade = false;
|
||||
|
||||
for(const auto & upgradeID : builtBuildings)
|
||||
{
|
||||
const auto & upgrade = town->buildings.at(upgradeID);
|
||||
if (upgrade->getBase() == bid && upgrade->upgradeReplacesBonuses)
|
||||
bonusesReplacedByUpgrade = true;
|
||||
}
|
||||
|
||||
// bonuses from this building are disabled and replaced by bonuses from an upgrade
|
||||
if (bonusesReplacedByUpgrade)
|
||||
continue;
|
||||
|
||||
auto building = town->buildings.at(bid);
|
||||
|
||||
|
@ -219,7 +219,6 @@ void TownRewardableBuildingInstance::onHeroVisit(const CGHeroInstance *h) const
|
||||
cb->showBlockingDialog(&sd);
|
||||
};
|
||||
|
||||
assert(town->hasBuilt(getBuildingType()));
|
||||
if(!town->hasBuilt(getBuildingType()))
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user