mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
Improvements to bonus system node types / propagators
- Node type is now set on construction and never changes - Added army propagator that also checks for TOWN and HERO - Renamed existing propagators to be in sync with enumeration
This commit is contained in:
@@ -42,13 +42,13 @@ void CArmedInstance::randomizeArmy(FactionID type)
|
||||
}
|
||||
|
||||
CArmedInstance::CArmedInstance(IGameInfoCallback *cb)
|
||||
:CArmedInstance(cb, false)
|
||||
:CArmedInstance(cb, BonusNodeType::ARMY, false)
|
||||
{
|
||||
}
|
||||
|
||||
CArmedInstance::CArmedInstance(IGameInfoCallback *cb, bool isHypothetic):
|
||||
CArmedInstance::CArmedInstance(IGameInfoCallback *cb, BonusNodeType nodeType, bool isHypothetic):
|
||||
CGObjectInstance(cb),
|
||||
CBonusSystemNode(isHypothetic),
|
||||
CBonusSystemNode(nodeType, isHypothetic),
|
||||
nonEvilAlignmentMix(this, Selector::type()(BonusType::NONEVIL_ALIGNMENT_MIX)), // Take Angelic Alliance troop-mixing freedom of non-evil units into account.
|
||||
battle(nullptr)
|
||||
{
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CArmedInstance(IGameInfoCallback *cb);
|
||||
CArmedInstance(IGameInfoCallback *cb, bool isHypothetic);
|
||||
CArmedInstance(IGameInfoCallback *cb, BonusNodeType nodeType, bool isHypothetic);
|
||||
|
||||
PlayerColor getOwner() const override
|
||||
{
|
||||
|
||||
@@ -50,7 +50,11 @@ void CGDwellingRandomizationInfo::serializeJson(JsonSerializeFormat & handler)
|
||||
}
|
||||
|
||||
CGDwelling::CGDwelling(IGameInfoCallback *cb):
|
||||
CArmedInstance(cb)
|
||||
CGDwelling(cb, BonusNodeType::ARMY)
|
||||
{}
|
||||
|
||||
CGDwelling::CGDwelling(IGameInfoCallback *cb, BonusNodeType nodeType):
|
||||
CArmedInstance(cb, nodeType, false)
|
||||
{}
|
||||
|
||||
CGDwelling::~CGDwelling() = default;
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
std::optional<CGDwellingRandomizationInfo> randomizationInfo; //random dwelling options; not serialized
|
||||
TCreaturesSet creatures; //creatures[level] -> <vector of alternative ids (base creature and upgrades, creatures amount>
|
||||
|
||||
CGDwelling(IGameInfoCallback *cb, BonusNodeType nodeType);
|
||||
CGDwelling(IGameInfoCallback *cb);
|
||||
~CGDwelling() override;
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ int CGHeroInstance::movementPointsLimitCached(bool onLand, const TurnInfo * ti)
|
||||
}
|
||||
|
||||
CGHeroInstance::CGHeroInstance(IGameInfoCallback * cb)
|
||||
: CArmedInstance(cb),
|
||||
: CArmedInstance(cb, BonusNodeType::HERO, false),
|
||||
CArtifactSet(cb),
|
||||
tacticFormationEnabled(false),
|
||||
inTownGarrison(false),
|
||||
@@ -259,7 +259,6 @@ CGHeroInstance::CGHeroInstance(IGameInfoCallback * cb)
|
||||
turnInfoCache(std::make_unique<TurnInfoCache>(this)),
|
||||
manaPerKnowledgeCached(this, Selector::type()(BonusType::MANA_PER_KNOWLEDGE_PERCENTAGE))
|
||||
{
|
||||
setNodeType(HERO);
|
||||
ID = Obj::HERO;
|
||||
secSkills.emplace_back(SecondarySkill::NONE, -1);
|
||||
}
|
||||
|
||||
@@ -261,8 +261,9 @@ TownFortifications CGTownInstance::fortificationsLevel() const
|
||||
}
|
||||
|
||||
CGTownInstance::CGTownInstance(IGameInfoCallback *cb):
|
||||
CGDwelling(cb),
|
||||
CGDwelling(cb, BonusNodeType::TOWN),
|
||||
IMarket(cb),
|
||||
townAndVis(BonusNodeType::TOWN_AND_VISITOR),
|
||||
built(0),
|
||||
destroyed(0),
|
||||
identifier(0),
|
||||
@@ -271,7 +272,6 @@ CGTownInstance::CGTownInstance(IGameInfoCallback *cb):
|
||||
spellResearchAcceptedCounter(0),
|
||||
spellResearchAllowed(true)
|
||||
{
|
||||
setNodeType(CBonusSystemNode::TOWN);
|
||||
attachTo(townAndVis);
|
||||
}
|
||||
|
||||
@@ -1209,11 +1209,6 @@ GrowthInfo::Entry::Entry(int _count, std::string fullDescription):
|
||||
{
|
||||
}
|
||||
|
||||
CTownAndVisitingHero::CTownAndVisitingHero()
|
||||
{
|
||||
setNodeType(TOWN_AND_VISITOR);
|
||||
}
|
||||
|
||||
int GrowthInfo::totalGrowth() const
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@@ -26,12 +26,6 @@ struct DamageRange;
|
||||
template<typename ContainedClass>
|
||||
class LogicalExpression;
|
||||
|
||||
class DLL_LINKAGE CTownAndVisitingHero : public CBonusSystemNode
|
||||
{
|
||||
public:
|
||||
CTownAndVisitingHero();
|
||||
};
|
||||
|
||||
struct DLL_LINKAGE GrowthInfo
|
||||
{
|
||||
struct Entry
|
||||
@@ -61,7 +55,7 @@ class DLL_LINKAGE CGTownInstance : public CGDwelling, public IShipyard, public I
|
||||
public:
|
||||
enum EFortLevel {NONE = 0, FORT = 1, CITADEL = 2, CASTLE = 3};
|
||||
|
||||
CTownAndVisitingHero townAndVis;
|
||||
CBonusSystemNode townAndVis;
|
||||
si32 built; //how many buildings has been built this turn
|
||||
si32 destroyed; //how many buildings has been destroyed this turn
|
||||
ui32 identifier; //special identifier from h3m (only > RoE maps)
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
FlaggableMapObject::FlaggableMapObject(IGameInfoCallback *cb)
|
||||
:CGObjectInstance(cb)
|
||||
,CBonusSystemNode(BonusNodeType::UNKNOWN)
|
||||
{}
|
||||
|
||||
const IOwnableObject * FlaggableMapObject::asOwnable() const
|
||||
{
|
||||
return this;
|
||||
|
||||
@@ -25,7 +25,7 @@ class DLL_LINKAGE FlaggableMapObject final : public CGObjectInstance, public IOw
|
||||
void initBonuses();
|
||||
|
||||
public:
|
||||
using CGObjectInstance::CGObjectInstance;
|
||||
FlaggableMapObject(IGameInfoCallback *cb);
|
||||
|
||||
void onHeroVisit(IGameEventCallback & gameEvents, const CGHeroInstance * h) const override;
|
||||
void initObj(IGameRandomizer & gameRandomizer) override;
|
||||
|
||||
@@ -930,7 +930,7 @@ void CGGarrison::addAntimagicGarrisonBonus()
|
||||
bonus->type = BonusType::BLOCK_ALL_MAGIC;
|
||||
bonus->source = BonusSource::OBJECT_TYPE;
|
||||
bonus->sid = BonusSourceID(this->ID);
|
||||
bonus->propagator = std::make_shared<CPropagatorNodeType>(CBonusSystemNode::BATTLE);
|
||||
bonus->propagator = std::make_shared<CPropagatorNodeType>(BonusNodeType::BATTLE_WIDE);
|
||||
bonus->duration = BonusDuration::PERMANENT;
|
||||
this->addNewBonus(bonus);
|
||||
}
|
||||
@@ -987,6 +987,7 @@ void CGMagi::onHeroVisit(IGameEventCallback & gameEvents, const CGHeroInstance *
|
||||
|
||||
CGBoat::CGBoat(IGameInfoCallback * cb)
|
||||
: CGObjectInstance(cb)
|
||||
, CBonusSystemNode(BonusNodeType::BOAT)
|
||||
{
|
||||
direction = 4;
|
||||
layer = EPathfindingLayer::SAIL;
|
||||
|
||||
Reference in New Issue
Block a user