1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-17 20:58:07 +02:00

Deprecate artifact-related building types

This commit is contained in:
Ivan Savenko 2024-08-26 21:25:39 +00:00
parent 55fd7bd7aa
commit 408a632002
19 changed files with 141 additions and 118 deletions

View File

@ -1673,7 +1673,7 @@ void CPlayerInterface::showUniversityWindow(const IMarket *market, const CGHeroI
auto onWindowClosed = [this, queryID](){
cb->selectionMade(0, queryID);
};
GH.windows().createAndPushWindow<CUniversityWindow>(visitor, market, onWindowClosed);
GH.windows().createAndPushWindow<CUniversityWindow>(visitor, BuildingID::NONE, market, onWindowClosed);
}
void CPlayerInterface::showHillFortWindow(const CGObjectInstance *object, const CGHeroInstance *visitor)

View File

@ -145,7 +145,7 @@ void CBuildingRect::clickPressed(const Point & cursorPosition)
if(getBuilding() && area && (parent->selectedBuilding==this))
{
auto building = getBuilding();
parent->buildingClicked(building->bid, building->subId, building->upgrade);
parent->buildingClicked(building->bid);
}
}
@ -681,24 +681,78 @@ const CGHeroInstance * CCastleBuildings::getHero()
return town->garrisonHero;
}
void CCastleBuildings::buildingClicked(BuildingID building, BuildingSubID::EBuildingSubID subID, BuildingID upgrades)
void CCastleBuildings::buildingClicked(BuildingID building)
{
logGlobal->trace("You've clicked on %d", (int)building.toEnum());
const CBuilding *b = town->town->buildings.find(building)->second;
if (town->getWarMachineInBuilding(building).hasValue())
BuildingID buildingToEnter = building;
for(;;)
{
enterBlacksmith(building, town->getWarMachineInBuilding(building));
return;
const CBuilding *b = town->town->buildings.find(buildingToEnter)->second;
if (buildingTryActivateCustomUI(buildingToEnter, building))
return;
if (!b->upgrade.hasValue())
{
enterBuilding(building);
return;
}
buildingToEnter = b->upgrade;
}
}
bool CCastleBuildings::buildingTryActivateCustomUI(BuildingID buildingToTest, BuildingID buildingTarget)
{
logGlobal->trace("You've clicked on %d", (int)buildingToTest.toEnum());
const CBuilding *b = town->town->buildings.at(buildingToTest);
if (town->getWarMachineInBuilding(buildingToTest).hasValue())
{
enterBlacksmith(buildingTarget, town->getWarMachineInBuilding(buildingToTest));
return true;
}
if (building >= BuildingID::DWELL_FIRST)
// FIXME: implement correct visiting of thieves guild
if (!b->marketModes.empty())
{
enterDwelling((BuildingID::getLevelFromDwelling(building)));
switch (*b->marketModes.begin())
{
case EMarketMode::CREATURE_UNDEAD:
GH.windows().createAndPushWindow<CTransformerWindow>(town, getHero(), nullptr);
return true;
case EMarketMode::RESOURCE_SKILL:
if (getHero())
GH.windows().createAndPushWindow<CUniversityWindow>(getHero(), buildingTarget, town, nullptr);
return true;
case EMarketMode::RESOURCE_RESOURCE:
// can't use allied marketplace
if (town->getOwner() == LOCPLINT->playerID)
{
GH.windows().createAndPushWindow<CMarketWindow>(town, getHero(), nullptr, *b->marketModes.begin());
return true;
}
else
return false;
default:
if(getHero())
GH.windows().createAndPushWindow<CMarketWindow>(town, getHero(), nullptr, *b->marketModes.begin());
else
LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[273]) % b->getNameTranslated())); //Only visiting heroes may use the %s.
return true;
}
}
if (buildingToTest >= BuildingID::DWELL_FIRST)
{
enterDwelling((BuildingID::getLevelFromDwelling(buildingToTest)));
return true;
}
else
{
switch(building)
switch(buildingToTest)
{
case BuildingID::MAGES_GUILD_1:
case BuildingID::MAGES_GUILD_2:
@ -706,117 +760,74 @@ void CCastleBuildings::buildingClicked(BuildingID building, BuildingSubID::EBuil
case BuildingID::MAGES_GUILD_4:
case BuildingID::MAGES_GUILD_5:
enterMagesGuild();
break;
return true;
case BuildingID::TAVERN:
LOCPLINT->showTavernWindow(town, nullptr, QueryID::NONE);
break;
return true;
case BuildingID::SHIPYARD:
if(town->shipyardStatus() == IBoatGenerator::GOOD)
{
LOCPLINT->showShipyardDialog(town);
return true;
}
else if(town->shipyardStatus() == IBoatGenerator::BOAT_ALREADY_BUILT)
{
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[51]);
break;
return true;
}
return false;
case BuildingID::FORT:
case BuildingID::CITADEL:
case BuildingID::CASTLE:
GH.windows().createAndPushWindow<CFortScreen>(town);
break;
return true;
case BuildingID::VILLAGE_HALL:
case BuildingID::CITY_HALL:
case BuildingID::TOWN_HALL:
case BuildingID::CAPITOL:
enterTownHall();
break;
case BuildingID::MARKETPLACE:
// can't use allied marketplace
if (town->getOwner() == LOCPLINT->playerID)
GH.windows().createAndPushWindow<CMarketWindow>(town, town->visitingHero, nullptr, EMarketMode::RESOURCE_RESOURCE);
else
enterBuilding(building);
break;
return true;
case BuildingID::SHIP:
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[51]); //Cannot build another boat
break;
return true;
case BuildingID::SPECIAL_1:
case BuildingID::SPECIAL_2:
case BuildingID::SPECIAL_3:
case BuildingID::SPECIAL_4:
switch (subID)
switch (b->subId)
{
case BuildingSubID::NONE:
enterBuilding(building);
break;
case BuildingSubID::MYSTIC_POND:
enterFountain(building, subID, upgrades);
break;
case BuildingSubID::ARTIFACT_MERCHANT:
if(town->visitingHero)
GH.windows().createAndPushWindow<CMarketWindow>(town, town->visitingHero, nullptr, EMarketMode::RESOURCE_ARTIFACT);
else
LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[273]) % b->getNameTranslated())); //Only visiting heroes may use the %s.
break;
case BuildingSubID::FOUNTAIN_OF_FORTUNE:
enterFountain(building, subID, upgrades);
break;
case BuildingSubID::FREELANCERS_GUILD:
if(getHero())
GH.windows().createAndPushWindow<CMarketWindow>(town, getHero(), nullptr, EMarketMode::CREATURE_RESOURCE);
else
LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[273]) % b->getNameTranslated())); //Only visiting heroes may use the %s.
break;
case BuildingSubID::MAGIC_UNIVERSITY:
if (getHero())
GH.windows().createAndPushWindow<CUniversityWindow>(getHero(), town, nullptr);
else
enterBuilding(building);
break;
enterFountain(buildingToTest, b->subId, buildingTarget);
return true;
case BuildingSubID::CASTLE_GATE:
if (LOCPLINT->makingTurn)
{
enterCastleGate();
else
enterBuilding(building);
break;
case BuildingSubID::CREATURE_TRANSFORMER: //Skeleton Transformer
GH.windows().createAndPushWindow<CTransformerWindow>(town, getHero(), nullptr);
break;
return true;
}
return false;
case BuildingSubID::PORTAL_OF_SUMMONING:
if (town->creatures[town->town->creatures.size()].second.empty())//No creatures
LOCPLINT->showInfoDialog(CGI->generaltexth->tcommands[30]);
else
enterDwelling(town->town->creatures.size());
break;
return true;
case BuildingSubID::BANK:
enterBank();
break;
default:
if(upgrades == BuildingID::TAVERN)
LOCPLINT->showTavernWindow(town, nullptr, QueryID::NONE);
else
enterBuilding(building);
break;
return true;
}
break;
return false;
default:
enterBuilding(building);
break;
return false;
}
}
}

View File

@ -173,7 +173,8 @@ public:
void enterBank();
void enterToTheQuickRecruitmentWindow();
void buildingClicked(BuildingID building, BuildingSubID::EBuildingSubID subID = BuildingSubID::NONE, BuildingID upgrades = BuildingID::NONE);
bool buildingTryActivateCustomUI(BuildingID buildingToTest, BuildingID buildingTarget);
void buildingClicked(BuildingID building);
void addBuilding(BuildingID building);
void removeBuilding(BuildingID building);//FIXME: not tested!!!
};

View File

@ -946,7 +946,7 @@ void CUniversityWindow::CItem::hover(bool on)
GH.statusbar()->clear();
}
CUniversityWindow::CUniversityWindow(const CGHeroInstance * _hero, const IMarket * _market, const std::function<void()> & onWindowClosed)
CUniversityWindow::CUniversityWindow(const CGHeroInstance * _hero, BuildingID building, const IMarket * _market, const std::function<void()> & onWindowClosed)
: CWindowObject(PLAYER_COLORED, ImagePath::builtin("UNIVERS1")),
hero(_hero),
onWindowClosed(onWindowClosed),
@ -961,8 +961,7 @@ CUniversityWindow::CUniversityWindow(const CGHeroInstance * _hero, const IMarket
if(auto town = dynamic_cast<const CGTownInstance *>(_market))
{
auto faction = town->town->faction->getId();
auto bid = town->town->getSpecialBuilding(BuildingSubID::MAGIC_UNIVERSITY)->bid;
titlePic = std::make_shared<CAnimImage>((*CGI->townh)[faction]->town->clientInfo.buildingsIcons, bid);
titlePic = std::make_shared<CAnimImage>((*CGI->townh)[faction]->town->clientInfo.buildingsIcons, building);
}
else if(auto uni = dynamic_cast<const CGUniversity *>(_market); uni->appearance)
{

View File

@ -391,7 +391,7 @@ class CUniversityWindow final : public CStatusbarWindow, public IMarketHolder
std::function<void()> onWindowClosed;
public:
CUniversityWindow(const CGHeroInstance * _hero, const IMarket * _market, const std::function<void()> & onWindowClosed);
CUniversityWindow(const CGHeroInstance * _hero, BuildingID building, const IMarket * _market, const std::function<void()> & onWindowClosed);
void makeDeal(SecondarySkill skill);
void close() override;

View File

@ -48,7 +48,10 @@
"produce": { "gold": 4000 }
},
"marketplace": { "id" : 14 },
"marketplace": {
"id" : 14,
"marketModes" : ["resource-resource", "resource-player"]
},
"resourceSilo": { "id" : 15, "requires" : [ "marketplace" ] },
"blacksmith": { "id" : 16 },
@ -205,7 +208,26 @@
}
},
// Section 3 - buildings that now have dedicated mechanics
// Section 3 - markets
"artifactMerchant" : {
"requires" : [ "marketplace" ],
"marketModes" : ["resource-artifact", "artifact-resource"]
},
"freelancersGuild" : {
"requires" : [ "marketplace" ],
"marketModes" : ["creature-resource"]
},
"magicUniversity" : {
"marketModes" : ["resource-skill"]
},
"creatureTransformer" : {
"marketModes" : ["creature-undead"]
},
// Section 4 - buildings that now have dedicated mechanics
"ballistaYard": {
"blacksmith" : "ballista"
},

View File

@ -165,7 +165,7 @@
"townHall": { },
"cityHall": { },
"capitol": { },
"marketplace": { "marketModes" : ["resource-resource", "resource-player"] },
"marketplace": { },
"resourceSilo": { "produce": { "ore": 1, "wood": 1 } },
"blacksmith": { "warMachine" : "ballista" },

View File

@ -170,15 +170,15 @@
"townHall": { },
"cityHall": { },
"capitol": { },
"marketplace": { "marketModes" : ["resource-resource", "resource-player"] },
"marketplace": { },
"resourceSilo": { "produce": { "mercury": 1 } },
"blacksmith": { "warMachine" : "ballista" },
"special1": { "type" : "artifactMerchant", "requires" : [ "marketplace" ], "marketModes" : ["resource-artifact", "artifact-resource"] },
"special1": { "requires" : [ "marketplace" ], "marketModes" : ["resource-artifact", "artifact-resource"] },
"horde1": { "id" : 18, "upgrades" : "dwellingLvl1" },
"horde1Upgr": { "id" : 19, "upgrades" : "dwellingUpLvl1", "requires" : [ "horde1" ], "mode" : "auto" },
"ship": { "id" : 20, "upgrades" : "shipyard" },
"special2": { "type" : "magicUniversity", "requires" : [ "mageGuild1" ] },
"special2": { "requires" : [ "mageGuild1" ], "marketModes" : ["resource-skill"] },
"grail": { "id" : 26, "mode" : "grail", "produce": { "gold": 5000 }},
"extraTownHall": { "id" : 27, "requires" : [ "townHall" ], "mode" : "auto" },
"extraCityHall": { "id" : 28, "requires" : [ "cityHall" ], "mode" : "auto" },

View File

@ -165,11 +165,11 @@
"townHall": { },
"cityHall": { },
"capitol": { },
"marketplace": { "marketModes" : ["resource-resource", "resource-player"] },
"marketplace": { },
"resourceSilo": { "produce": { "sulfur": 1 } },
"blacksmith": { "warMachine" : "ballista" },
"special1": { "type" : "artifactMerchant", "requires" : [ "marketplace" ], "marketModes" : ["resource-artifact", "artifact-resource"] },
"special1": { "requires" : [ "marketplace" ], "marketModes" : ["resource-artifact", "artifact-resource"] },
"horde1": { "id" : 18, "upgrades" : "dwellingLvl1" },
"horde1Upgr": { "id" : 19, "upgrades" : "dwellingUpLvl1", "requires" : [ "horde1" ], "mode" : "auto" },
"special2": {

View File

@ -164,7 +164,7 @@
"townHall": { },
"cityHall": { },
"capitol": { },
"marketplace": { "marketModes" : ["resource-resource", "resource-player"] },
"marketplace": { },
"resourceSilo": { "produce": { "wood": 1, "ore": 1 } },
"blacksmith": { "warMachine" : "firstAidTent" },

View File

@ -166,7 +166,7 @@
"townHall": { },
"cityHall": { },
"capitol": { },
"marketplace": { "marketModes" : ["resource-resource", "resource-player"] },
"marketplace": { },
"resourceSilo": { "produce": { "mercury": 1 } },
"blacksmith": { "warMachine" : "ammoCart" },

View File

@ -171,7 +171,7 @@
"townHall": { },
"cityHall": { },
"capitol": { },
"marketplace": { "marketModes" : ["resource-resource", "resource-player"] },
"marketplace": { },
"resourceSilo": { "produce": { "ore": 1, "wood": 1 } },
"blacksmith": { "warMachine" : "firstAidTent" },
@ -181,7 +181,7 @@
"ship": { "id" : 20, "upgrades" : "shipyard" },
"special2": { "requires" : [ "mageGuild1" ],
"bonuses": [ { "type": "UNDEAD_RAISE_PERCENTAGE", "val": 10, "propagator": "PLAYER_PROPAGATOR" } ] },
"special3": { "type" : "creatureTransformer", "requires" : [ "dwellingLvl1" ], "marketModes" : ["creature-undead"] },
"special3": { "requires" : [ "dwellingLvl1" ], "marketModes" : ["creature-undead"] },
"grail": { "id" : 26, "mode" : "grail", "produce": { "gold": 5000 },
"bonuses": [ { "type": "UNDEAD_RAISE_PERCENTAGE", "val": 20, "propagator": "PLAYER_PROPAGATOR" } ] },

View File

@ -169,7 +169,7 @@
"townHall": { },
"cityHall": { },
"capitol": { },
"marketplace": { "marketModes" : ["resource-resource", "resource-player"] },
"marketplace": { },
"resourceSilo": { "produce": { "crystal": 1 } },
"blacksmith": { "warMachine" : "firstAidTent" },

View File

@ -161,14 +161,14 @@
"townHall": { },
"cityHall": { },
"capitol": { },
"marketplace": { "marketModes" : ["resource-resource", "resource-player"] },
"marketplace": { },
"resourceSilo": { "produce": { "ore": 1, "wood": 1 } },
"blacksmith": { "warMachine" : "ammoCart" },
"special1": { "type" : "escapeTunnel", "requires" : [ "fort" ] },
"horde1": { "id" : 18, "upgrades" : "dwellingLvl1" },
"horde1Upgr": { "id" : 19, "upgrades" : "dwellingUpLvl1", "requires" : [ "horde1" ], "mode" : "auto" },
"special2": { "type" : "freelancersGuild", "requires" : [ "marketplace" ], "marketModes" : ["creature-resource"] },
"special2": { "requires" : [ "marketplace" ], "marketModes" : ["creature-resource"] },
"special3": { "warMachine" : "ballista", "requires" : [ "blacksmith" ] },
"special4": {
"requires" : [ "fort" ],

View File

@ -164,11 +164,11 @@
"townHall": { },
"cityHall": { },
"capitol": { },
"marketplace": { "marketModes" : ["resource-resource", "resource-player"] },
"marketplace": { },
"resourceSilo": { "produce" : { "gems": 1 } },
"blacksmith": { "warMachine" : "ammoCart" },
"special1": { "type" : "artifactMerchant", "requires" : [ "marketplace" ], "marketModes" : ["resource-artifact", "artifact-resource"] },
"special1": { "requires" : [ "marketplace" ], "marketModes" : ["resource-artifact", "artifact-resource"] },
"horde1": { "id" : 18, "upgrades" : "dwellingLvl2" },
"horde1Upgr": { "id" : 19, "upgrades" : "dwellingUpLvl2", "requires" : [ "horde1" ], "mode" : "auto" },
"special2": { "height" : "high", "requires" : [ "fort" ] },

View File

@ -36,7 +36,7 @@
},
"type" : {
"type" : "string",
"enum" : [ "mysticPond", "artifactMerchant", "freelancersGuild", "magicUniversity", "castleGate", "creatureTransformer", "portalOfSummoning", "library", "escapeTunnel", "treasury", "bank" ],
"enum" : [ "mysticPond", "castleGate", "portalOfSummoning", "library", "escapeTunnel", "treasury", "bank" ],
"description" : "Subtype for some special buildings"
},
"mode" : {
@ -104,7 +104,10 @@
},
"marketModes" : {
"type" : "array",
"enum" : [ "resource-resource", "resource-player", "creature-resource", "resource-artifact", "artifact-resource", "artifact-experience", "creature-experience", "creature-undead", "resource-skill"],
"items" : {
"type" : "string",
"enum" : [ "resource-resource", "resource-player", "creature-resource", "resource-artifact", "artifact-resource", "artifact-experience", "creature-experience", "creature-undead", "resource-skill"],
},
"description" : "List of modes available in this market"
}
}

View File

@ -26,15 +26,10 @@ namespace BuildingSubID
DEFAULT = -50,
NONE = -1,
CASTLE_GATE,
CREATURE_TRANSFORMER,
MYSTIC_POND,
FOUNTAIN_OF_FORTUNE,
ARTIFACT_MERCHANT,
LIBRARY,
PORTAL_OF_SUMMONING,
ESCAPE_TUNNEL,
FREELANCERS_GUILD,
MAGIC_UNIVERSITY,
TREASURY,
BANK
};

View File

@ -178,14 +178,9 @@ namespace MappedKeys
static const std::map<std::string, BuildingSubID::EBuildingSubID> SPECIAL_BUILDINGS =
{
{ "mysticPond", BuildingSubID::MYSTIC_POND },
{ "artifactMerchant", BuildingSubID::ARTIFACT_MERCHANT },
{ "freelancersGuild", BuildingSubID::FREELANCERS_GUILD },
{ "magicUniversity", BuildingSubID::MAGIC_UNIVERSITY },
{ "castleGate", BuildingSubID::CASTLE_GATE },
{ "creatureTransformer", BuildingSubID::CREATURE_TRANSFORMER },//only skeleton transformer yet
{ "portalOfSummoning", BuildingSubID::PORTAL_OF_SUMMONING },
{ "library", BuildingSubID::LIBRARY },
{ "fountainOfFortune", BuildingSubID::FOUNTAIN_OF_FORTUNE },//luck garrison bonus
{ "escapeTunnel", BuildingSubID::ESCAPE_TUNNEL },
{ "treasury", BuildingSubID::TREASURY },
{ "bank", BuildingSubID::BANK }

View File

@ -44,13 +44,10 @@ int CGTownInstance::getSightRadius() const //returns sight distance
for(const auto & bid : builtBuildings)
{
if(bid.IsSpecialOrGrail())
{
auto height = town->buildings.at(bid)->height;
if(ret < height)
ret = height;
auto height = town->buildings.at(bid)->height;
if(ret < height)
ret = height;
}
}
return ret;
}