1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-14 10:12:59 +02:00
vcmi/lib/mapObjects/CGDwelling.h

73 lines
2.0 KiB
C++
Raw Normal View History

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;
class DLL_LINKAGE CGDwellingRandomizationInfo
2023-04-26 20:55:56 +02:00
{
public:
std::set<FactionID> allowedFactions;
2023-04-26 20:55:56 +02:00
std::string instanceId;//vcmi map instance identifier
int32_t identifier = 0;//h3m internal identifier
2023-04-26 20:55:56 +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
void serializeJson(JsonSerializeFormat & handler);
2023-04-26 20:55:56 +02:00
};
class DLL_LINKAGE CGDwelling : public CArmedInstance
{
public:
using TCreaturesSet = std::vector<std::pair<ui32, std::vector<CreatureID> > >;
2023-04-26 20:55:56 +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:
FactionID randomizeFaction(vstd::RNG & rand);
int randomizeLevel(vstd::RNG & rand);
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;
void newTurn(vstd::RNG & rand) const override;
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;
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:
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