CArtHandler.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. enum EartClass {SartClass=0, TartClass, NartClass, JartClass, RartClass}; //artifact class (relict, treasure, strong, weak etc.)
  9. class CDefHandler;
  10. class DLL_EXPORT CArtifact //container for artifacts
  11. {
  12. std::string name, description; //set if custom
  13. public:
  14. const std::string &Name() const;
  15. const std::string &Description() const;
  16. ui32 price;
  17. std::vector<ui16> possibleSlots; //ids of slots where artifact can be placed
  18. EartClass aClass;
  19. int id;
  20. std::list<HeroBonus> bonuses; //bonuses given by artifact
  21. template <typename Handler> void serialize(Handler &h, const int version)
  22. {
  23. h & name & description & price & possibleSlots & aClass & id & bonuses;
  24. }
  25. };
  26. class DLL_EXPORT CArtHandler //handles artifacts
  27. {
  28. void giveArtBonus(int aid, HeroBonus::BonusType type, int val, int subtype = -1);
  29. public:
  30. std::vector<CArtifact*> treasures, minors, majors, relics;
  31. std::vector<CArtifact> artifacts;
  32. void loadArtifacts(bool onlyTxt);
  33. void sortArts();
  34. void addBonuses();
  35. static int convertMachineID(int id, bool creToArt);
  36. CArtHandler();
  37. template <typename Handler> void serialize(Handler &h, const int version)
  38. {
  39. h & artifacts;
  40. if(!h.saving)
  41. sortArts();
  42. }
  43. };
  44. #endif // __CARTHANDLER_H__