CGameInfoCallback.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * CGameInfoCallback.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 "IGameInfoCallback.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. struct SThievesGuildInfo;
  14. class Player;
  15. class DLL_LINKAGE CGameInfoCallback : public IGameInfoCallback
  16. {
  17. protected:
  18. bool hasAccess(std::optional<PlayerColor> playerId) const;
  19. bool canGetFullInfo(const CGObjectInstance *obj) const; //true we player owns obj or ally owns obj or privileged mode
  20. public:
  21. //various
  22. int getDate(Date mode=Date::DAY)const override; //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
  23. const StartInfo * getStartInfo() const override;
  24. const StartInfo * getInitialStartInfo() const;
  25. bool isAllowed(SpellID id) const override;
  26. bool isAllowed(ArtifactID id) const override;
  27. bool isAllowed(SecondarySkill id) const override;
  28. const IGameSettings & getSettings() const override;
  29. //player
  30. virtual std::optional<PlayerColor> getPlayerID() const;
  31. const Player * getPlayer(PlayerColor color) const;
  32. const PlayerState * getPlayerState(PlayerColor color, bool verbose = true) const override;
  33. int getResource(PlayerColor Player, GameResID which) const override;
  34. PlayerRelations getPlayerRelations(PlayerColor color1, PlayerColor color2) const override;
  35. void getThievesGuildInfo(SThievesGuildInfo & thi, const CGObjectInstance * obj);
  36. EPlayerStatus getPlayerStatus(PlayerColor player, bool verbose = true) const override;
  37. bool isPlayerMakingTurn(PlayerColor player) const;
  38. const PlayerSettings * getPlayerSettings(PlayerColor color) const override;
  39. TurnTimerInfo getPlayerTurnTime(PlayerColor color) const;
  40. //map
  41. bool isVisibleFor(int3 pos, PlayerColor player) const override;
  42. bool isVisibleFor(const CGObjectInstance * obj, PlayerColor player) const override;
  43. bool isVisible(const CGObjectInstance * obj) const;
  44. bool isVisible(int3 pos) const;
  45. //armed object
  46. void fillUpgradeInfo(const CArmedInstance *obj, SlotID stackPos, UpgradeInfo &out) const;
  47. //hero
  48. const CGHeroInstance * getHero(ObjectInstanceID objid) const override;
  49. int getHeroCount(PlayerColor player, bool includeGarrisoned) const override;
  50. bool getHeroInfo(const CGObjectInstance * hero, InfoAboutHero & dest, const CGObjectInstance * selectedObject = nullptr) const;
  51. int32_t getSpellCost(const spells::Spell * sp, const CGHeroInstance * caster) const;
  52. int64_t estimateSpellDamage(const CSpell * sp, const CGHeroInstance * hero) const;
  53. const CArtifactInstance * getArtInstance(ArtifactInstanceID aid) const override;
  54. const CGObjectInstance * getObjInstance(ObjectInstanceID oid) const override;
  55. const CArtifactSet * getArtSet(const ArtifactLocation & loc) const;
  56. //objects
  57. const CGObjectInstance * getObj(ObjectInstanceID objid, bool verbose = true) const override;
  58. std::vector<const CGObjectInstance *> getBlockingObjs(int3 pos) const;
  59. std::vector<const CGObjectInstance *> getVisitableObjs(int3 pos, bool verbose = true) const;
  60. std::vector<const CGObjectInstance *> getAllVisitableObjs() const;
  61. std::vector<const CGObjectInstance *> getFlaggableObjects(int3 pos) const;
  62. const CGObjectInstance * getTopObj(int3 pos) const override;
  63. PlayerColor getOwner(ObjectInstanceID heroID) const;
  64. const IMarket * getMarket(ObjectInstanceID objid) const;
  65. //map
  66. int3 guardingCreaturePosition (int3 pos) const;
  67. std::vector<const CGObjectInstance*> getGuardingCreatures (int3 pos) const;
  68. bool isTileGuardedUnchecked(int3 tile) const;
  69. const CMapHeader * getMapHeader()const override;
  70. int3 getMapSize() const override;
  71. const TerrainTile * getTile(int3 tile, bool verbose = true) const override;
  72. const TerrainTile * getTileUnchecked(int3 tile) const override;
  73. bool isInTheMap(const int3 &pos) const override;
  74. void getVisibleTilesInRange(std::unordered_set<int3> &tiles, int3 pos, int radious, int3::EDistanceFormula distanceFormula = int3::DIST_2D) const;
  75. void calculatePaths(const std::shared_ptr<PathfinderConfig> & config) const override;
  76. EDiggingStatus getTileDigStatus(int3 tile, bool verbose = true) const override;
  77. //town
  78. const CGTownInstance* getTown(ObjectInstanceID objid) const override;
  79. int howManyTowns(PlayerColor Player) const;
  80. std::vector<const CGHeroInstance *> getAvailableHeroes(const CGObjectInstance * townOrTavern) const;
  81. std::string getTavernRumor(const CGObjectInstance * townOrTavern) const;
  82. EBuildingState canBuildStructure(const CGTownInstance *t, BuildingID ID);
  83. bool getTownInfo(const CGObjectInstance * town, InfoAboutTown & dest, const CGObjectInstance * selectedObject = nullptr) const;
  84. //from gs
  85. const TeamState *getTeam(TeamID teamID) const override;
  86. const TeamState *getPlayerTeam(PlayerColor color) const override;
  87. //teleport
  88. std::vector<ObjectInstanceID> getVisibleTeleportObjects(std::vector<ObjectInstanceID> ids, PlayerColor player) const override;
  89. std::vector<ObjectInstanceID> getTeleportChannelEntrances(TeleportChannelID id, PlayerColor Player = PlayerColor::UNFLAGGABLE) const override;
  90. std::vector<ObjectInstanceID> getTeleportChannelExits(TeleportChannelID id, PlayerColor Player = PlayerColor::UNFLAGGABLE) const override;
  91. ETeleportChannelType getTeleportChannelType(TeleportChannelID id, PlayerColor player = PlayerColor::UNFLAGGABLE) const;
  92. bool isTeleportChannelImpassable(TeleportChannelID id, PlayerColor player = PlayerColor::UNFLAGGABLE) const override;
  93. bool isTeleportChannelBidirectional(TeleportChannelID id, PlayerColor player = PlayerColor::UNFLAGGABLE) const override;
  94. bool isTeleportChannelUnidirectional(TeleportChannelID id, PlayerColor player = PlayerColor::UNFLAGGABLE) const override;
  95. bool isTeleportEntrancePassable(const CGTeleport * obj, PlayerColor player) const override;
  96. //used for random spawns
  97. void getFreeTiles(std::vector<int3> &tiles) const;
  98. void getTilesInRange(std::unordered_set<int3> & tiles, const int3 & pos, int radius, ETileVisibility mode, std::optional<PlayerColor> player = std::optional<PlayerColor>(), int3::EDistanceFormula formula = int3::DIST_2D) const override;
  99. void getAllTiles(std::unordered_set<int3> &tiles, std::optional<PlayerColor> player, int level, std::function<bool(const TerrainTile *)> filter) const override;
  100. void pickAllowedArtsSet(std::vector<ArtifactID> & out, vstd::RNG & rand) override;
  101. void getAllowedSpells(std::vector<SpellID> &out, std::optional<ui16> level = std::nullopt);
  102. #if SCRIPTING_ENABLED
  103. virtual scripting::Pool * getGlobalContextPool() const override;
  104. #endif
  105. };
  106. VCMI_LIB_NAMESPACE_END