CGameInfoCallback.h 5.9 KB

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