CGameInfoCallback.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. #pragma once
  2. #include "ResourceSet.h" // for Res::ERes
  3. #include "CBattleCallback.h" //for CCallbackBase
  4. /*
  5. * CGameInfoCallback.h, part of VCMI engine
  6. *
  7. * Authors: listed in file AUTHORS in main folder
  8. *
  9. * License: GNU General Public License v2.0 or later
  10. * Full text of license available in license.txt file, in main folder
  11. *
  12. */
  13. class CGObjectInstance;
  14. struct InfoWindow;
  15. struct PlayerSettings;
  16. struct CPackForClient;
  17. struct TerrainTile;
  18. struct PlayerState;
  19. class CTown;
  20. struct StartInfo;
  21. struct InfoAboutTown;
  22. struct UpgradeInfo;
  23. struct SThievesGuildInfo;
  24. class CGDwelling;
  25. class CMapHeader;
  26. struct TeamState;
  27. struct QuestInfo;
  28. class int3;
  29. class DLL_LINKAGE CGameInfoCallback : public virtual CCallbackBase
  30. {
  31. protected:
  32. CGameInfoCallback();
  33. CGameInfoCallback(CGameState *GS, boost::optional<PlayerColor> Player);
  34. bool hasAccess(boost::optional<PlayerColor> playerId) const;
  35. bool isVisible(int3 pos, boost::optional<PlayerColor> Player) const;
  36. bool isVisible(const CGObjectInstance *obj, boost::optional<PlayerColor> Player) const;
  37. bool isVisible(const CGObjectInstance *obj) const;
  38. bool canGetFullInfo(const CGObjectInstance *obj) const; //true we player owns obj or ally owns obj or privileged mode
  39. bool isOwnedOrVisited(const CGObjectInstance *obj) const;
  40. public:
  41. //various
  42. int getDate(Date::EDateType mode=Date::DAY)const; //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
  43. const StartInfo * getStartInfo(bool beforeRandomization = false)const;
  44. bool isAllowed(int type, int id); //type: 0 - spell; 1- artifact; 2 - secondary skill
  45. //player
  46. const PlayerState * getPlayer(PlayerColor color, bool verbose = true) const;
  47. int getResource(PlayerColor Player, Res::ERes which) const;
  48. bool isVisible(int3 pos) const;
  49. PlayerRelations::PlayerRelations getPlayerRelations(PlayerColor color1, PlayerColor color2) const;
  50. void getThievesGuildInfo(SThievesGuildInfo & thi, const CGObjectInstance * obj); //get thieves' guild info obtainable while visiting given object
  51. EPlayerStatus::EStatus getPlayerStatus(PlayerColor player, bool verbose = true) const; //-1 if no such player
  52. PlayerColor getCurrentPlayer() const; //player that currently makes move // TODO synchronous turns
  53. virtual PlayerColor getLocalPlayer() const; //player that is currently owning given client (if not a client, then returns current player)
  54. const PlayerSettings * getPlayerSettings(PlayerColor color) const;
  55. //armed object
  56. void getUpgradeInfo(const CArmedInstance *obj, SlotID stackPos, UpgradeInfo &out)const;
  57. //hero
  58. const CGHeroInstance* getHero(ObjectInstanceID objid) const;
  59. const CGHeroInstance* getHeroWithSubid(int subid) const;
  60. int getHeroCount(PlayerColor player, bool includeGarrisoned) const;
  61. bool getHeroInfo(const CGObjectInstance *hero, InfoAboutHero &dest) const;
  62. int getSpellCost(const CSpell * sp, const CGHeroInstance * caster) const; //when called during battle, takes into account creatures' spell cost reduction
  63. int estimateSpellDamage(const CSpell * sp, const CGHeroInstance * hero) const; //estimates damage of given spell; returns 0 if spell causes no dmg
  64. const CGHeroInstance* getSelectedHero(PlayerColor player) const; //nullptr if no hero is selected
  65. const CGHeroInstance* getSelectedHero() const; //of current (active) player
  66. const CArtifactInstance * getArtInstance(ArtifactInstanceID aid) const;
  67. const CGObjectInstance * getObjInstance(ObjectInstanceID oid) const;
  68. //objects
  69. const CGObjectInstance* getObj(ObjectInstanceID objid, bool verbose = true) const;
  70. std::vector <const CGObjectInstance * > getBlockingObjs(int3 pos)const;
  71. std::vector <const CGObjectInstance * > getVisitableObjs(int3 pos, bool verbose = true)const;
  72. std::vector <const CGObjectInstance * > getFlaggableObjects(int3 pos) const;
  73. const CGObjectInstance * getTopObj (int3 pos) const;
  74. std::vector <std::string > getObjDescriptions(int3 pos)const; //returns descriptions of objects at pos in order from the lowest to the highest
  75. PlayerColor getOwner(ObjectInstanceID heroID) const;
  76. const CGObjectInstance *getObjByQuestIdentifier(int identifier) const; //nullptr if object has been removed (eg. killed)
  77. //map
  78. int3 guardingCreaturePosition (int3 pos) const;
  79. std::vector<const CGObjectInstance*> getGuardingCreatures (int3 pos) const;
  80. const CMapHeader * getMapHeader()const;
  81. int3 getMapSize() const; //returns size of map - z is 1 for one - level map and 2 for two level map
  82. const TerrainTile * getTile(int3 tile, bool verbose = true) const;
  83. bool isInTheMap(const int3 &pos) const;
  84. //town
  85. const CGTownInstance* getTown(ObjectInstanceID objid) const;
  86. int howManyTowns(PlayerColor Player) const;
  87. const CGTownInstance * getTownInfo(int val, bool mode)const; //mode = 0 -> val = player town serial; mode = 1 -> val = object id (serial)
  88. std::vector<const CGHeroInstance *> getAvailableHeroes(const CGObjectInstance * townOrTavern) const; //heroes that can be recruited
  89. std::string getTavernGossip(const CGObjectInstance * townOrTavern) const;
  90. EBuildingState::EBuildingState canBuildStructure(const CGTownInstance *t, BuildingID ID);//// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
  91. virtual bool getTownInfo(const CGObjectInstance *town, InfoAboutTown &dest) const;
  92. const CTown *getNativeTown(PlayerColor color) const;
  93. //from gs
  94. const TeamState *getTeam(TeamID teamID) const;
  95. const TeamState *getPlayerTeam(PlayerColor color) const;
  96. EBuildingState::EBuildingState canBuildStructure(const CGTownInstance *t, BuildingID ID) const;// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
  97. };
  98. class DLL_LINKAGE CPlayerSpecificInfoCallback : public CGameInfoCallback
  99. {
  100. public:
  101. int howManyTowns() const;
  102. int howManyHeroes(bool includeGarrisoned = true) const;
  103. int3 getGrailPos(double &outKnownRatio);
  104. boost::optional<PlayerColor> getMyColor() const;
  105. std::vector <const CGTownInstance *> getTownsInfo(bool onlyOur = true) const; //true -> only owned; false -> all visible
  106. int getHeroSerial(const CGHeroInstance * hero, bool includeGarrisoned=true) const;
  107. const CGTownInstance* getTownBySerial(int serialId) const; // serial id is [0, number of towns)
  108. const CGHeroInstance* getHeroBySerial(int serialId, bool includeGarrisoned=true) const; // serial id is [0, number of heroes)
  109. std::vector <const CGHeroInstance *> getHeroesInfo(bool onlyOur = true) const; //true -> only owned; false -> all visible
  110. std::vector <const CGDwelling *> getMyDwellings() const; //returns all dwellings that belong to player
  111. std::vector <const CGObjectInstance * > getMyObjects() const; //returns all objects flagged by belonging player
  112. std::vector <QuestInfo> getMyQuests() const;
  113. int getResourceAmount(Res::ERes type) const;
  114. TResources getResourceAmount() const;
  115. const std::vector< std::vector< std::vector<ui8> > > & getVisibilityMap()const; //returns visibility map
  116. const PlayerSettings * getPlayerSettings(PlayerColor color) const;
  117. };
  118. class DLL_LINKAGE IGameEventRealizer
  119. {
  120. public:
  121. virtual void commitPackage(CPackForClient *pack) = 0;
  122. virtual void showInfoDialog(InfoWindow *iw);
  123. virtual void setObjProperty(ObjectInstanceID objid, int prop, si64 val);
  124. virtual void showInfoDialog(const std::string &msg, PlayerColor player);
  125. };