2023-06-02 20:47:37 +02:00
|
|
|
/*
|
|
|
|
* IMarket.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2023-11-08 17:49:08 +02:00
|
|
|
#include "../networkPacks/TradeItem.h"
|
|
|
|
#include "../constants/Enumerations.h"
|
2024-08-12 16:38:30 +02:00
|
|
|
#include "../CArtHandler.h"
|
2023-06-02 20:47:37 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2024-08-12 16:38:30 +02:00
|
|
|
class DLL_LINKAGE IMarket : public virtual Serializeable
|
2023-06-02 20:47:37 +02:00
|
|
|
{
|
|
|
|
public:
|
2024-08-12 16:38:30 +02:00
|
|
|
class CArtifactSetAltar : public CArtifactSet
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ArtBearer::ArtBearer bearerType() const override {return ArtBearer::ALTAR;};
|
|
|
|
};
|
2023-06-02 20:47:37 +02:00
|
|
|
|
2024-08-20 16:15:50 +02:00
|
|
|
virtual ObjectInstanceID getObjInstanceID() const = 0; // The market is always an object on the map
|
2023-06-02 20:47:37 +02:00
|
|
|
virtual int getMarketEfficiency() const = 0;
|
2024-08-16 17:00:02 +02:00
|
|
|
virtual bool allowsTrade(const EMarketMode mode) const;
|
2024-08-12 16:38:30 +02:00
|
|
|
virtual int availableUnits(const EMarketMode mode, const int marketItemSerial) const; //-1 if unlimited
|
|
|
|
virtual std::vector<TradeItemBuy> availableItemsIds(const EMarketMode mode) const;
|
2024-08-16 17:00:02 +02:00
|
|
|
void addMarketMode(const EMarketMode mode);
|
|
|
|
void addMarketMode(const std::set<EMarketMode> & modes);
|
|
|
|
void removeMarketMode(const EMarketMode mode);
|
2024-08-20 22:36:31 +02:00
|
|
|
void removeMarketMode(const std::set<EMarketMode> & modes);
|
2024-08-17 21:06:48 +02:00
|
|
|
void removeAllMarketModes();
|
2024-08-17 19:19:48 +02:00
|
|
|
std::set<EMarketMode> availableModes() const;
|
|
|
|
std::shared_ptr<CArtifactSet> getArtifactsStorage() const;
|
2023-08-19 20:43:50 +02:00
|
|
|
bool getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode) const; //val1 - how many units of id1 player has to give to receive val2 units
|
2024-08-12 16:38:30 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler & h)
|
|
|
|
{
|
2024-08-16 17:00:02 +02:00
|
|
|
h & marketModes;
|
|
|
|
|
2024-08-26 22:52:37 +02:00
|
|
|
if(vstd::contains(marketModes, EMarketMode::ARTIFACT_EXP))
|
|
|
|
{
|
|
|
|
if (!h.saving)
|
|
|
|
altarArtifactsStorage = std::make_shared<CArtifactSetAltar>();
|
|
|
|
|
|
|
|
h & *altarArtifactsStorage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Handler> void serializeArtifactsAltar(Handler & h)
|
|
|
|
{
|
|
|
|
h & *altarArtifactsStorage;
|
2024-08-12 16:38:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2024-08-17 19:19:48 +02:00
|
|
|
std::shared_ptr<CArtifactSetAltar> altarArtifactsStorage;
|
2024-08-16 17:00:02 +02:00
|
|
|
std::set<EMarketMode> marketModes;
|
2023-06-02 20:47:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|