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