CArtHandler.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef __CARTHANDLER_H__
  2. #define __CARTHANDLER_H__
  3. #include "../global.h"
  4. #include "../lib/HeroBonus.h"
  5. #include <list>
  6. #include <string>
  7. #include <vector>
  8. /*
  9. * CArtHandler.h, part of VCMI engine
  10. *
  11. * Authors: listed in file AUTHORS in main folder
  12. *
  13. * License: GNU General Public License v2.0 or later
  14. * Full text of license available in license.txt file, in main folder
  15. *
  16. */
  17. class CDefHandler;
  18. class DLL_EXPORT CArtifact //container for artifacts
  19. {
  20. std::string name, description; //set if custom
  21. public:
  22. enum EartClass {ART_SPECIAL=1, ART_TREASURE=2, ART_MINOR=4, ART_MAJOR=8, ART_RELIC=16}; //artifact classes
  23. const std::string &Name() const; //getter
  24. const std::string &Description() const; //getter
  25. ui32 price;
  26. std::vector<ui16> possibleSlots; //ids of slots where artifact can be placed
  27. EartClass aClass;
  28. int id;
  29. std::list<HeroBonus> bonuses; //bonuses given by artifact
  30. template <typename Handler> void serialize(Handler &h, const int version)
  31. {
  32. h & name & description & price & possibleSlots & aClass & id & bonuses;
  33. }
  34. };
  35. class DLL_EXPORT CArtHandler //handles artifacts
  36. {
  37. void giveArtBonus(int aid, HeroBonus::BonusType type, int val, int subtype = -1);
  38. public:
  39. std::vector<CArtifact*> treasures, minors, majors, relics;
  40. std::vector<CArtifact> artifacts;
  41. void loadArtifacts(bool onlyTxt);
  42. void sortArts();
  43. void addBonuses();
  44. static int convertMachineID(int id, bool creToArt);
  45. CArtHandler();
  46. template <typename Handler> void serialize(Handler &h, const int version)
  47. {
  48. h & artifacts;
  49. if(!h.saving)
  50. sortArts();
  51. }
  52. };
  53. #endif // __CARTHANDLER_H__