2022-07-26 15:07:42 +02:00
|
|
|
/*
|
2014-06-05 20:26:50 +03:00
|
|
|
* CGPandoraBox.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-09-15 15:29:41 +02:00
|
|
|
#include "CRewardableObject.h"
|
2017-07-13 10:26:03 +02:00
|
|
|
#include "../ResourceSet.h"
|
2014-06-05 19:52:14 +03:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2014-08-11 21:17:17 +03:00
|
|
|
struct InfoWindow;
|
2014-06-25 17:11:07 +03:00
|
|
|
|
2023-09-15 15:29:41 +02:00
|
|
|
class DLL_LINKAGE CGPandoraBox : public CRewardableObject
|
2014-06-05 19:52:14 +03:00
|
|
|
{
|
|
|
|
public:
|
2024-01-01 16:37:48 +02:00
|
|
|
using CRewardableObject::CRewardableObject;
|
|
|
|
|
2023-09-27 23:11:11 +02:00
|
|
|
MetaString message;
|
2014-06-05 19:52:14 +03:00
|
|
|
|
2016-09-09 19:30:36 +02:00
|
|
|
void initObj(CRandomGenerator & rand) override;
|
2014-06-05 19:52:14 +03:00
|
|
|
void onHeroVisit(const CGHeroInstance * h) const override;
|
|
|
|
void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
|
|
|
|
void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
|
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
2023-09-15 15:29:41 +02:00
|
|
|
h & static_cast<CRewardableObject&>(*this);
|
2017-07-31 15:35:42 +02:00
|
|
|
h & message;
|
2014-06-05 19:52:14 +03:00
|
|
|
}
|
|
|
|
protected:
|
2023-09-17 18:02:24 +02:00
|
|
|
void grantRewardWithMessage(const CGHeroInstance * contextHero, int rewardIndex, bool markAsVisit) const override;
|
|
|
|
|
2023-09-15 15:29:41 +02:00
|
|
|
virtual void init();
|
2016-11-13 12:38:42 +02:00
|
|
|
void serializeJsonOptions(JsonSerializeFormat & handler) override;
|
2014-06-05 19:52:14 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE CGEvent : public CGPandoraBox //event objects
|
|
|
|
{
|
|
|
|
public:
|
2024-01-01 16:37:48 +02:00
|
|
|
using CGPandoraBox::CGPandoraBox;
|
|
|
|
|
2023-02-12 22:39:17 +02:00
|
|
|
bool removeAfterVisit = false; //true if event is removed after occurring
|
2023-08-25 20:40:19 +02:00
|
|
|
std::set<PlayerColor> availableFor; //players whom this event is available for
|
2023-02-12 22:39:17 +02:00
|
|
|
bool computerActivate = false; //true if computer player can activate this event
|
|
|
|
bool humanActivate = false; //true if human player can activate this event
|
2014-06-05 19:52:14 +03:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & static_cast<CGPandoraBox &>(*this);
|
2017-07-31 15:35:42 +02:00
|
|
|
h & removeAfterVisit;
|
|
|
|
h & availableFor;
|
|
|
|
h & computerActivate;
|
|
|
|
h & humanActivate;
|
2014-06-05 19:52:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void onHeroVisit(const CGHeroInstance * h) const override;
|
2016-11-13 12:38:42 +02:00
|
|
|
protected:
|
2023-09-17 18:02:24 +02:00
|
|
|
void grantRewardWithMessage(const CGHeroInstance * contextHero, int rewardIndex, bool markAsVisit) const override;
|
|
|
|
|
2023-09-15 15:29:41 +02:00
|
|
|
void init() override;
|
2016-11-13 12:38:42 +02:00
|
|
|
void serializeJsonOptions(JsonSerializeFormat & handler) override;
|
2014-06-05 19:52:14 +03:00
|
|
|
private:
|
|
|
|
void activated(const CGHeroInstance * h) const;
|
|
|
|
};
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|