CStackBasicDescriptor.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * CStackBasicDescriptor.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 "GameConstants.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class JsonNode;
  14. class CCreature;
  15. class CGHeroInstance;
  16. class CArmedInstance;
  17. class CCreatureArtifactSet;
  18. class JsonSerializeFormat;
  19. class DLL_LINKAGE CStackBasicDescriptor
  20. {
  21. CreatureID typeID;
  22. TQuantity count = -1; //exact quantity or quantity ID from CCreature::getQuantityID when getting info about enemy army
  23. public:
  24. CStackBasicDescriptor();
  25. CStackBasicDescriptor(const CreatureID & id, TQuantity Count);
  26. CStackBasicDescriptor(const CCreature * c, TQuantity Count);
  27. virtual ~CStackBasicDescriptor() = default;
  28. const Creature * getType() const;
  29. const CCreature * getCreature() const;
  30. CreatureID getId() const;
  31. TQuantity getCount() const;
  32. virtual void setType(const CCreature * c);
  33. virtual void setCount(TQuantity amount);
  34. friend bool operator==(const CStackBasicDescriptor & l, const CStackBasicDescriptor & r);
  35. template<typename Handler>
  36. void serialize(Handler & h)
  37. {
  38. if(h.saving)
  39. {
  40. h & typeID;
  41. }
  42. else
  43. {
  44. CreatureID creatureID;
  45. h & creatureID;
  46. if(creatureID != CreatureID::NONE)
  47. setType(creatureID.toCreature());
  48. }
  49. h & count;
  50. }
  51. void serializeJson(JsonSerializeFormat & handler);
  52. };
  53. VCMI_LIB_NAMESPACE_END