MapDifficulty.h 877 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * MapDifficulty.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. VCMI_LIB_NAMESPACE_BEGIN
  12. enum class EMapDifficulty : uint8_t
  13. {
  14. EASY = 0,
  15. NORMAL = 1,
  16. HARD = 2,
  17. EXPERT = 3,
  18. IMPOSSIBLE = 4,
  19. COUNT = 5
  20. };
  21. class MapDifficultySet
  22. {
  23. static constexpr uint8_t allDifficultiesMask = (1 << static_cast<uint8_t>(EMapDifficulty::COUNT)) - 1;
  24. uint8_t mask = allDifficultiesMask;
  25. public:
  26. MapDifficultySet() = default;
  27. explicit MapDifficultySet(uint8_t mask)
  28. :mask(mask)
  29. {}
  30. bool contains(const EMapDifficulty & difficulty) const
  31. {
  32. return (1 << static_cast<uint8_t>(difficulty)) & mask;
  33. }
  34. template <typename Handler>
  35. void serialize(Handler & h)
  36. {
  37. h & mask;
  38. }
  39. };
  40. VCMI_LIB_NAMESPACE_END