CStackBasicDescriptor.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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> void serialize(Handler &h)
  36. {
  37. if(h.saving)
  38. {
  39. h & typeID;
  40. }
  41. else
  42. {
  43. CreatureID creatureID;
  44. h & creatureID;
  45. if(creatureID != CreatureID::NONE)
  46. setType(creatureID.toCreature());
  47. }
  48. h & count;
  49. }
  50. void serializeJson(JsonSerializeFormat & handler);
  51. };
  52. VCMI_LIB_NAMESPACE_END