TavernHeroesPool.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * TavernHeroesPool.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. #include "TavernSlot.h"
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. class CGHeroInstance;
  15. class CTown;
  16. class CRandomGenerator;
  17. class CHeroClass;
  18. class CGameState;
  19. class CSimpleArmy;
  20. class DLL_LINKAGE TavernHeroesPool
  21. {
  22. struct TavernSlot
  23. {
  24. CGHeroInstance * hero;
  25. TavernHeroSlot slot;
  26. TavernSlotRole role;
  27. PlayerColor player;
  28. template <typename Handler> void serialize(Handler &h, const int version)
  29. {
  30. h & hero;
  31. h & slot;
  32. h & role;
  33. h & player;
  34. }
  35. };
  36. /// list of all heroes in pool, including those currently present in taverns
  37. std::map<HeroTypeID, CGHeroInstance* > heroesPool;
  38. /// list of which players are able to purchase specific hero
  39. /// if hero is not present in list, he is available for everyone
  40. std::map<HeroTypeID, PlayerColor::Mask> perPlayerAvailability;
  41. /// list of heroes currently available in taverns
  42. std::vector<TavernSlot> currentTavern;
  43. public:
  44. ~TavernHeroesPool();
  45. /// Returns heroes currently availabe in tavern of a specific player
  46. std::vector<const CGHeroInstance *> getHeroesFor(PlayerColor color) const;
  47. /// returns heroes in pool without heroes that are available in taverns
  48. std::map<HeroTypeID, CGHeroInstance* > unusedHeroesFromPool() const;
  49. /// Returns true if hero is available to a specific player
  50. bool isHeroAvailableFor(HeroTypeID hero, PlayerColor color) const;
  51. TavernSlotRole getSlotRole(HeroTypeID hero) const;
  52. CGHeroInstance * takeHeroFromPool(HeroTypeID hero);
  53. /// reset mana and movement points for all heroes in pool
  54. void onNewDay();
  55. void addHeroToPool(CGHeroInstance * hero);
  56. /// Marks hero as available to only specific set of players
  57. void setAvailability(HeroTypeID hero, PlayerColor::Mask mask);
  58. /// Makes hero available in tavern of specified player
  59. void setHeroForPlayer(PlayerColor player, TavernHeroSlot slot, HeroTypeID hero, CSimpleArmy & army, TavernSlotRole role);
  60. template <typename Handler> void serialize(Handler &h, const int version)
  61. {
  62. h & heroesPool;
  63. h & perPlayerAvailability;
  64. h & currentTavern;
  65. }
  66. };
  67. VCMI_LIB_NAMESPACE_END