HeroBonus.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #pragma once
  2. #include "../global.h"
  3. #include <string>
  4. struct DLL_EXPORT HeroBonus
  5. {
  6. enum BonusType{NONE, MOVEMENT, LAND_MOVEMENT, SEA_MOVEMENT, MORALE, LUCK, MORALE_AND_LUCK};
  7. enum BonusDuration{PERMANENT, ONE_BATTLE, ONE_DAY, ONE_WEEK};
  8. enum BonusSource{ARTIFACT, OBJECT};
  9. ui8 duration; //uses BonusDuration values
  10. ui8 type; //uses BonusType values - says to what is this bonus
  11. ui8 source;//uses BonusSource values - what gave that bonus
  12. si32 val;//for morale/luck [-3,+3], others any
  13. ui32 id; //id of object/artifact
  14. std::string description;
  15. HeroBonus(ui8 Dur, ui8 Type, ui8 Src, si32 Val, ui32 ID, std::string Desc)
  16. :duration(Dur), type(Type), source(Src), val(Val), id(ID), description(Desc)
  17. {}
  18. HeroBonus(){};
  19. template <typename Handler> void serialize(Handler &h, const int version)
  20. {
  21. h & duration & type & source & val & id & description;
  22. }
  23. static bool OneDay(const HeroBonus &hb)
  24. {
  25. return hb.duration==HeroBonus::ONE_DAY;
  26. }
  27. static bool OneWeek(const HeroBonus &hb)
  28. {
  29. return hb.duration==HeroBonus::ONE_WEEK;
  30. }
  31. static bool OneBattle(const HeroBonus &hb)
  32. {
  33. return hb.duration==HeroBonus::ONE_BATTLE;
  34. }
  35. };