IGameCallback.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #ifndef __IGAMECALLBACK_H__
  2. #define __IGAMECALLBACK_H__
  3. #include "../global.h"
  4. #include <vector>
  5. #include <set>
  6. #include "../client/FunctionList.h"
  7. /*
  8. * IGameCallback.h, part of VCMI engine
  9. *
  10. * Authors: listed in file AUTHORS in main folder
  11. *
  12. * License: GNU General Public License v2.0 or later
  13. * Full text of license available in license.txt file, in main folder
  14. *
  15. */
  16. struct SetMovePoints;
  17. struct GiveBonus;
  18. class CGObjectInstance;
  19. class CGTownInstance;
  20. class CGHeroInstance;
  21. struct BlockingDialog;
  22. struct InfoWindow;
  23. struct MetaString;
  24. struct ShowInInfobox;
  25. struct BattleResult;
  26. struct Component;
  27. class CGameState;
  28. struct PlayerSettings;
  29. struct CPackForClient;
  30. class CArtHandler;
  31. class CArtifact;
  32. class CArmedInstance;
  33. struct TerrainTile;
  34. class DLL_EXPORT IGameCallback
  35. {
  36. protected:
  37. CGameState *gs;
  38. public:
  39. virtual ~IGameCallback(){};
  40. CGameState *const gameState ();
  41. virtual int getOwner(int heroID);
  42. virtual int getResource(int player, int which);
  43. virtual int getDate(int mode=0); ////mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
  44. virtual const CGObjectInstance* getObj(int objid);
  45. virtual const CGHeroInstance* getHero(int objid);
  46. virtual const CGTownInstance* getTown(int objid);
  47. virtual const CGHeroInstance* getSelectedHero(int player); //NULL if no hero is selected
  48. virtual int getCurrentPlayer()=0;
  49. virtual int getSelectedHero()=0;
  50. virtual const PlayerSettings * getPlayerSettings(int color);
  51. virtual int getHeroCount(int player, bool includeGarrisoned);
  52. virtual void getTilesInRange(std::set<int3> &tiles, int3 pos, int radious, int player=-1, int mode=0); //mode 1 - only unrevealed tiles; mode 0 - all, mode -1 - only unrevealed
  53. virtual void getAllTiles (std::set<int3> &tiles, int player=-1, int level=-1, int surface=0); //returns all tiles on given level (-1 - both levels, otherwise number of level); surface: 0 - land and water, 1 - only land, 2 - only water
  54. virtual bool isAllowed(int type, int id); //type: 0 - spell; 1- artifact
  55. virtual ui16 getRandomArt (int flags);
  56. virtual void getAllowedArts(std::vector<CArtifact*> &out, std::vector<CArtifact*> CArtHandler::*arts, int flag);
  57. virtual void getAllowed(std::vector<CArtifact*> &out, int flags); //flags: bitfield uses EartClass
  58. virtual void getAllowedSpells(std::vector<ui16> &out, ui16 level);
  59. virtual int3 getMapSize(); //returns size of the map
  60. virtual TerrainTile * getTile(int3 pos);
  61. //do sth
  62. virtual void changeSpells(int hid, bool give, const std::set<ui32> &spells)=0;
  63. virtual bool removeObject(int objid)=0;
  64. virtual void setBlockVis(int objid, bool bv)=0;
  65. virtual void setOwner(int objid, ui8 owner)=0;
  66. virtual void setHoverName(int objid, MetaString * name)=0;
  67. virtual void setObjProperty(int objid, int prop, si64 val)=0;
  68. virtual void changePrimSkill(int ID, int which, si64 val, bool abs=false)=0;
  69. virtual void changeSecSkill(int ID, int which, int val, bool abs=false)=0;
  70. virtual void showInfoDialog(InfoWindow *iw)=0;
  71. virtual void showBlockingDialog(BlockingDialog *iw, const CFunctionList<void(ui32)> &callback)=0;
  72. virtual ui32 showBlockingDialog(BlockingDialog *iw) =0; //synchronous version of above //TODO:
  73. virtual void showGarrisonDialog(int upobj, int hid, bool removableUnits, const boost::function<void()> &cb) =0; //cb will be called when player closes garrison window
  74. virtual void giveResource(int player, int which, int val)=0;
  75. virtual void giveCreatures (int objid, const CGHeroInstance * h, CCreatureSet creatures) =0;
  76. virtual void showCompInfo(ShowInInfobox * comp)=0;
  77. virtual void heroVisitCastle(int obj, int heroID)=0;
  78. virtual void stopHeroVisitCastle(int obj, int heroID)=0;
  79. virtual void giveHeroArtifact(int artid, int hid, int position)=0; //pos==-1 - first free slot in backpack=0; pos==-2 - default if available or backpack
  80. virtual void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool creatureBank = false, boost::function<void(BattleResult*)> cb = 0, const CGTownInstance *town = NULL)=0; //use hero=NULL for no hero
  81. virtual void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, boost::function<void(BattleResult*)> cb = 0, bool creatureBank = false)=0; //if any of armies is hero, hero will be used
  82. virtual void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, boost::function<void(BattleResult*)> cb = 0, bool creatureBank = false)=0; //if any of armies is hero, hero will be used, visitable tile of second obj is place of battle
  83. //virtual void startBattleI(int heroID, CCreatureSet army, int3 tile, boost::function<void(BattleResult*)> cb)=0; //for hero<=>neutral army
  84. virtual void setAmount(int objid, ui32 val)=0;
  85. virtual bool moveHero(si32 hid, int3 dst, ui8 instant, ui8 asker = 255)=0;
  86. virtual void giveHeroBonus(GiveBonus * bonus)=0;
  87. virtual void setMovePoints(SetMovePoints * smp)=0;
  88. virtual void setManaPoints(int hid, int val)=0;
  89. virtual void giveHero(int id, int player)=0;
  90. virtual void changeObjPos(int objid, int3 newPos, ui8 flags)=0;
  91. virtual void sendAndApply(CPackForClient * info)=0;
  92. virtual void heroExchange(si32 hero1, si32 hero2)=0; //when two heroes meet on adventure map
  93. friend struct CPack;
  94. friend struct CPackForClient;
  95. friend struct CPackForServer;
  96. };
  97. #endif // __IGAMECALLBACK_H__