1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +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) void CPlayerInterface::showMarketWindow(const IMarket *market, const CGHeroInstance *visitor)
{ {
EVENT_HANDLER_CALLED_BY_CLIENT; EVENT_HANDLER_CALLED_BY_CLIENT;
auto * o = dynamic_cast<const CGObjectInstance *>(market);
if(o && o->ID == Obj::ALTAR_OF_SACRIFICE) if(market->allowsTrade(EMarketMode::ARTIFACT_EXP) && visitor->getAlignment() != EAlignment::EVIL)
{ GH.pushIntT<CAltarWindow>(market, visitor, EMarketMode::ARTIFACT_EXP);
//EEMarketMode mode = market->availableModes().front(); else if(market->allowsTrade(EMarketMode::CREATURE_EXP) && visitor->getAlignment() != EAlignment::GOOD)
if (market->allowsTrade(EMarketMode::ARTIFACT_EXP) && visitor->getAlignment() != EAlignment::EVIL) GH.pushIntT<CAltarWindow>(market, visitor, EMarketMode::CREATURE_EXP);
GH.pushIntT<CAltarWindow>(market, visitor, EMarketMode::ARTIFACT_EXP); else if(market->allowsTrade(EMarketMode::CREATURE_UNDEAD))
else if (market->allowsTrade(EMarketMode::CREATURE_EXP) && visitor->getAlignment() != EAlignment::GOOD) GH.pushIntT<CTransformerWindow>(market, visitor);
GH.pushIntT<CAltarWindow>(market, visitor, EMarketMode::CREATURE_EXP); else if(!market->availableModes().empty())
} GH.pushIntT<CMarketplaceWindow>(market, visitor, market->availableModes().front());
else
{
if(market->allowsTrade(EMarketMode::CREATURE_UNDEAD))
GH.pushIntT<CTransformerWindow>(market, visitor);
else
GH.pushIntT<CMarketplaceWindow>(market, visitor, market->availableModes().front());
}
} }
void CPlayerInterface::showUniversityWindow(const IMarket *market, const CGHeroInstance *visitor) void CPlayerInterface::showUniversityWindow(const IMarket *market, const CGHeroInstance *visitor)