2022-07-26 15:07:42 +02:00
|
|
|
/*
|
2014-06-05 20:26:50 +03:00
|
|
|
* CGMarket.h, part of VCMI engine
|
2014-06-05 19:52:14 +03:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
2017-07-13 10:26:03 +02:00
|
|
|
#pragma once
|
|
|
|
|
2023-06-02 20:47:37 +02:00
|
|
|
#include "CGObjectInstance.h"
|
|
|
|
#include "IMarket.h"
|
2014-06-05 19:52:14 +03:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2014-06-05 19:52:14 +03:00
|
|
|
class DLL_LINKAGE CGMarket : public CGObjectInstance, public IMarket
|
|
|
|
{
|
|
|
|
public:
|
2023-04-28 03:16:10 +02:00
|
|
|
|
2023-08-19 20:43:50 +02:00
|
|
|
std::set<EMarketMode> marketModes;
|
2023-05-01 02:07:31 +02:00
|
|
|
int marketEfficiency;
|
2023-04-28 03:16:10 +02:00
|
|
|
|
2023-04-29 14:10:30 +02:00
|
|
|
//window variables
|
|
|
|
std::string title;
|
|
|
|
std::string speech; //currently shown only in university
|
|
|
|
|
2014-06-05 19:52:14 +03:00
|
|
|
CGMarket();
|
2023-04-28 03:16:10 +02:00
|
|
|
///IObjectInterface
|
2014-06-05 19:52:14 +03:00
|
|
|
void onHeroVisit(const CGHeroInstance * h) const override; //open trading window
|
2023-04-28 03:16:10 +02:00
|
|
|
void initObj(CRandomGenerator & rand) override;//set skills for trade
|
2014-06-05 19:52:14 +03:00
|
|
|
|
|
|
|
///IMarket
|
|
|
|
int getMarketEfficiency() const override;
|
2023-08-19 20:43:50 +02:00
|
|
|
bool allowsTrade(EMarketMode mode) const override;
|
|
|
|
int availableUnits(EMarketMode mode, int marketItemSerial) const override; //-1 if unlimited
|
|
|
|
std::vector<int> availableItemsIds(EMarketMode mode) const override;
|
2014-06-05 19:52:14 +03:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & static_cast<CGObjectInstance&>(*this);
|
2023-04-28 03:16:10 +02:00
|
|
|
h & marketModes;
|
2023-05-01 02:07:31 +02:00
|
|
|
h & marketEfficiency;
|
2023-04-29 14:10:30 +02:00
|
|
|
h & title;
|
|
|
|
h & speech;
|
2014-06-05 19:52:14 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE CGBlackMarket : public CGMarket
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::vector<const CArtifact *> artifacts; //available artifacts
|
|
|
|
|
2016-09-09 19:30:36 +02:00
|
|
|
void newTurn(CRandomGenerator & rand) const override; //reset artifacts for black market every month
|
2023-08-19 20:43:50 +02:00
|
|
|
std::vector<int> availableItemsIds(EMarketMode mode) const override;
|
2014-06-05 19:52:14 +03:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & static_cast<CGMarket&>(*this);
|
|
|
|
h & artifacts;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE CGUniversity : public CGMarket
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::vector<int> skills; //available skills
|
|
|
|
|
2023-08-19 20:43:50 +02:00
|
|
|
std::vector<int> availableItemsIds(EMarketMode mode) const override;
|
2016-09-09 19:30:36 +02:00
|
|
|
void initObj(CRandomGenerator & rand) override;//set skills for trade
|
2014-06-05 19:52:14 +03:00
|
|
|
void onHeroVisit(const CGHeroInstance * h) const override; //open window
|
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & static_cast<CGMarket&>(*this);
|
|
|
|
h & skills;
|
|
|
|
}
|
|
|
|
};
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|