CArmedInstance.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * CArmedInstance.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "CGObjectInstance.h"
  12. #include "../CCreatureSet.h"
  13. #include "../bonuses/CBonusSystemNode.h"
  14. #include "../bonuses/BonusCache.h"
  15. VCMI_LIB_NAMESPACE_BEGIN
  16. class BattleInfo;
  17. class CGameState;
  18. class JsonSerializeFormat;
  19. class DLL_LINKAGE CArmedInstance: public CGObjectInstance, public CBonusSystemNode, public CCreatureSet, public IConstBonusProvider
  20. {
  21. private:
  22. BonusValueCache nonEvilAlignmentMix;
  23. public:
  24. BattleInfo *battle; //set to the current battle, if engaged
  25. void randomizeArmy(FactionID type);
  26. virtual void updateMoraleBonusFromArmy();
  27. void armyChanged() override;
  28. CArmedInstance * getArmy() final { return this; }
  29. const CArmedInstance * getArmy() const final { return this; }
  30. //////////////////////////////////////////////////////////////////////////
  31. //IConstBonusProvider
  32. const IBonusBearer* getBonusBearer() const override;
  33. // int valOfGlobalBonuses(CSelector selector) const; //used only for castle interface ???
  34. virtual CBonusSystemNode & whereShouldBeAttached(CGameState * gs);
  35. virtual CBonusSystemNode & whatShouldBeAttached();
  36. //////////////////////////////////////////////////////////////////////////
  37. CArmedInstance(IGameCallback *cb);
  38. CArmedInstance(IGameCallback *cb, bool isHypothetic);
  39. PlayerColor getOwner() const override
  40. {
  41. return this->tempOwner;
  42. }
  43. TerrainId getCurrentTerrain() const;
  44. void serializeJsonOptions(JsonSerializeFormat & handler) override;
  45. template <typename Handler> void serialize(Handler &h)
  46. {
  47. h & static_cast<CGObjectInstance&>(*this);
  48. h & static_cast<CBonusSystemNode&>(*this);
  49. h & static_cast<CCreatureSet&>(*this);
  50. }
  51. };
  52. VCMI_LIB_NAMESPACE_END