2023-04-26 20:55:56 +02:00
|
|
|
/*
|
|
|
|
* CGDwelling.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
|
|
|
|
|
|
|
|
#include "CArmedInstance.h"
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class CGDwelling;
|
|
|
|
|
2023-10-25 12:50:11 +02:00
|
|
|
class DLL_LINKAGE CGDwellingRandomizationInfo
|
2023-04-26 20:55:56 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-10-25 12:50:11 +02:00
|
|
|
std::set<FactionID> allowedFactions;
|
2023-04-26 20:55:56 +02:00
|
|
|
|
|
|
|
std::string instanceId;//vcmi map instance identifier
|
2023-10-25 12:50:11 +02:00
|
|
|
int32_t identifier = 0;//h3m internal identifier
|
2023-04-26 20:55:56 +02:00
|
|
|
|
2023-10-25 12:50:11 +02:00
|
|
|
uint8_t minLevel = 1;
|
|
|
|
uint8_t maxLevel = 7; //minimal and maximal level of creature in dwelling: <1, 7>
|
2023-04-26 20:55:56 +02:00
|
|
|
|
2023-10-25 12:50:11 +02:00
|
|
|
void serializeJson(JsonSerializeFormat & handler);
|
2023-04-26 20:55:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE CGDwelling : public CArmedInstance
|
|
|
|
{
|
|
|
|
public:
|
2024-05-06 17:33:30 +02:00
|
|
|
using TCreaturesSet = std::vector<std::pair<ui32, std::vector<CreatureID> > >;
|
2023-04-26 20:55:56 +02:00
|
|
|
|
2023-10-25 12:50:11 +02:00
|
|
|
std::optional<CGDwellingRandomizationInfo> randomizationInfo; //random dwelling options; not serialized
|
2023-04-26 20:55:56 +02:00
|
|
|
TCreaturesSet creatures; //creatures[level] -> <vector of alternative ids (base creature and upgrades, creatures amount>
|
|
|
|
|
2024-01-01 16:37:48 +02:00
|
|
|
CGDwelling(IGameCallback *cb);
|
2023-04-26 20:55:56 +02:00
|
|
|
~CGDwelling() override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void serializeJsonOptions(JsonSerializeFormat & handler) override;
|
|
|
|
|
|
|
|
private:
|
2024-06-01 17:28:17 +02:00
|
|
|
FactionID randomizeFaction(vstd::RNG & rand);
|
|
|
|
int randomizeLevel(vstd::RNG & rand);
|
2023-10-25 12:50:11 +02:00
|
|
|
|
2024-06-01 17:28:17 +02:00
|
|
|
void pickRandomObject(vstd::RNG & rand) override;
|
|
|
|
void initObj(vstd::RNG & rand) override;
|
2023-04-26 20:55:56 +02:00
|
|
|
void onHeroVisit(const CGHeroInstance * h) const override;
|
2024-06-01 17:28:17 +02:00
|
|
|
void newTurn(vstd::RNG & rand) const override;
|
2023-11-06 18:27:16 +02:00
|
|
|
void setPropertyDer(ObjProperty what, ObjPropertyID identifier) override;
|
2023-04-26 20:55:56 +02:00
|
|
|
void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
|
|
|
|
void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
|
2023-11-02 15:49:45 +02:00
|
|
|
std::vector<Component> getPopupComponents(PlayerColor player) const override;
|
2023-04-26 20:55:56 +02:00
|
|
|
|
|
|
|
void updateGuards() const;
|
|
|
|
void heroAcceptsCreatures(const CGHeroInstance *h) const;
|
|
|
|
|
|
|
|
public:
|
2024-01-20 20:34:51 +02:00
|
|
|
template <typename Handler> void serialize(Handler &h)
|
2023-04-26 20:55:56 +02:00
|
|
|
{
|
|
|
|
h & static_cast<CArmedInstance&>(*this);
|
|
|
|
h & creatures;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|