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

Get rid of hardcoded logic for markets

This commit is contained in:
nordsoft 2023-04-29 15:53:44 +04:00 committed by Nordsoft91
parent b29fc1a5f4
commit 11840b9f6d

View File

@ -1709,22 +1709,15 @@ void CPlayerInterface::stopMovement()
void CPlayerInterface::showMarketWindow(const IMarket *market, const CGHeroInstance *visitor)
{
EVENT_HANDLER_CALLED_BY_CLIENT;
auto * o = dynamic_cast<const CGObjectInstance *>(market);
if(o && o->ID == Obj::ALTAR_OF_SACRIFICE)
{
//EEMarketMode mode = market->availableModes().front();
if (market->allowsTrade(EMarketMode::ARTIFACT_EXP) && visitor->getAlignment() != EAlignment::EVIL)
GH.pushIntT<CAltarWindow>(market, visitor, EMarketMode::ARTIFACT_EXP);
else if (market->allowsTrade(EMarketMode::CREATURE_EXP) && visitor->getAlignment() != EAlignment::GOOD)
GH.pushIntT<CAltarWindow>(market, visitor, EMarketMode::CREATURE_EXP);
}
else
{
if(market->allowsTrade(EMarketMode::CREATURE_UNDEAD))
GH.pushIntT<CTransformerWindow>(market, visitor);
else
GH.pushIntT<CMarketplaceWindow>(market, visitor, market->availableModes().front());
}
if(market->allowsTrade(EMarketMode::ARTIFACT_EXP) && visitor->getAlignment() != EAlignment::EVIL)
GH.pushIntT<CAltarWindow>(market, visitor, EMarketMode::ARTIFACT_EXP);
else if(market->allowsTrade(EMarketMode::CREATURE_EXP) && visitor->getAlignment() != EAlignment::GOOD)
GH.pushIntT<CAltarWindow>(market, visitor, EMarketMode::CREATURE_EXP);
else if(market->allowsTrade(EMarketMode::CREATURE_UNDEAD))
GH.pushIntT<CTransformerWindow>(market, visitor);
else if(!market->availableModes().empty())
GH.pushIntT<CMarketplaceWindow>(market, visitor, market->availableModes().front());
}
void CPlayerInterface::showUniversityWindow(const IMarket *market, const CGHeroInstance *visitor)