CGameInterface.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef CGAMEINTERFACE_H
  2. #define CGAMEINTERFACE_H
  3. #include "global.h"
  4. #include "CCallback.h"
  5. BOOST_TRIBOOL_THIRD_STATE(outOfRange)
  6. using namespace boost::logic;
  7. class CCallback;
  8. class CGlobalAI;
  9. class CGHeroInstance;
  10. class CSelectableComponent;
  11. class CObstacle
  12. {
  13. int ID;
  14. int position;
  15. //TODO: add some kind of the blockmap
  16. };
  17. struct Action
  18. {
  19. bool side; //who made this action: false - left, true - right player
  20. int stackNumber;//stack ID, -1 left hero, -2 right hero,
  21. int actionType; // 0 = Cancel Action 1 = Hero cast a spell 2 = Walk 3 = Defend 4 = Retreat from the battle 5 = Surrender 6 = Walk and Attack 7 = Shoot 8 = Wait 9 = Catapult 10 = Monster casts a spell (i.e. Faerie Dragons)
  22. int destinationTile;
  23. int additionalInfo; // e.g. spell number if type is 1 || 10
  24. };
  25. class CGameInterface
  26. {
  27. public:
  28. bool human;
  29. int playerID, serialID;
  30. virtual void init(ICallback * CB)=0{};
  31. virtual void yourTurn()=0{};
  32. virtual void heroKilled(const CGHeroInstance*)=0{};
  33. virtual void heroCreated(const CGHeroInstance*)=0{};
  34. virtual void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val)=0{};
  35. virtual void heroMoved(const HeroMoveDetails & details)=0{};
  36. virtual void heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town){};
  37. virtual void tileRevealed(int3 pos){};
  38. virtual void tileHidden(int3 pos){};
  39. virtual void receivedResource(int type, int val){};
  40. virtual void showSelDialog(std::string text, std::vector<CSelectableComponent*> & components, int askID)=0{};
  41. virtual void garrisonChanged(const CGObjectInstance * obj){};
  42. virtual void buildChanged(const CGTownInstance *town, int buildingID, int what){}; //what: 1 - built, 2 - demolished
  43. //battle call-ins
  44. virtual void battleStart(CCreatureSet * army1, CCreatureSet * army2, int3 tile, CGHeroInstance *hero1, CGHeroInstance *hero2, bool side){}; //called by engine when battle starts; side=0 - left, side=1 - right
  45. virtual void battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles){}; //called when battlefield is prepared, prior the battle beginning
  46. virtual void battleNewRound(int round){}; //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
  47. virtual void actionStarted(Action action){};//occurs BEFORE every action taken by any stack or by the hero
  48. virtual void actionFinished(Action action){};//occurs AFTER every action taken by any stack or by the hero
  49. virtual void activeStack(int stackID){}; //called when it's turn of that stack
  50. virtual void battleEnd(CCreatureSet * army1, CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2, std::vector<int> capturedArtifacts, int expForWinner, bool winner){};
  51. //
  52. };
  53. class CAIHandler
  54. {
  55. public:
  56. static CGlobalAI * getNewAI(CCallback * cb, std::string dllname);
  57. };
  58. class CGlobalAI : public CGameInterface // AI class (to derivate)
  59. {
  60. public:
  61. //CGlobalAI();
  62. virtual void yourTurn(){};
  63. virtual void heroKilled(const CGHeroInstance*){};
  64. virtual void heroCreated(const CGHeroInstance*){};
  65. };
  66. #endif //CGAMEINTERFACE_H