mock_IGameCallback.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * mock_IGameCallback.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 <vcmi/ServerCallback.h>
  12. #include "../../lib/IGameCallback.h"
  13. #include "../../lib/int3.h"
  14. class GameCallbackMock : public IGameCallback
  15. {
  16. public:
  17. using UpperCallback = ::ServerCallback;
  18. GameCallbackMock(UpperCallback * upperCallback_);
  19. virtual ~GameCallbackMock();
  20. void setGameState(CGameState * gameState);
  21. ///STUBS, to be removed as long as same methods moved from GameHandler
  22. //all calls to such methods should be replaced with other object calls or actual netpacks
  23. //currently they are declared in callbacks, overridden in GameHandler and stubbed in client
  24. //TODO: fail all stub calls
  25. void setObjPropertyValue(ObjectInstanceID objid, ObjProperty prop, int32_t value = 0) override {}
  26. void setObjPropertyID(ObjectInstanceID objid, ObjProperty prop, ObjPropertyID identifier) override {}
  27. void showInfoDialog(InfoWindow * iw) override {}
  28. void showInfoDialog(const std::string & msg, PlayerColor player) override {}
  29. void changeSpells(const CGHeroInstance * hero, bool give, const std::set<SpellID> &spells) override {}
  30. bool removeObject(const CGObjectInstance * obj, const PlayerColor & initiator) override {return false;}
  31. void createObject(const int3 & visitablePosition, const PlayerColor & initiator, MapObjectID type, MapObjectSubID subtype) override {};
  32. void setOwner(const CGObjectInstance * objid, PlayerColor owner) override {}
  33. void giveExperience(const CGHeroInstance * hero, TExpType val) override {}
  34. void changePrimSkill(const CGHeroInstance * hero, PrimarySkill which, si64 val, bool abs=false) override {}
  35. void changeSecSkill(const CGHeroInstance * hero, SecondarySkill which, int val, bool abs=false) override {}
  36. void showBlockingDialog(BlockingDialog *iw) override {}
  37. void showGarrisonDialog(ObjectInstanceID upobj, ObjectInstanceID hid, bool removableUnits) override {} //cb will be called when player closes garrison window
  38. void showTeleportDialog(TeleportDialog *iw) override {}
  39. void showObjectWindow(const CGObjectInstance * object, EOpenWindowMode window, const CGHeroInstance * visitor, bool addQuery) override {};
  40. void giveResource(PlayerColor player, GameResID which, int val) override {}
  41. void giveResources(PlayerColor player, TResources resources) override {}
  42. void giveCreatures(const CArmedInstance *objid, const CGHeroInstance * h, const CCreatureSet &creatures, bool remove) override {}
  43. void takeCreatures(ObjectInstanceID objid, const std::vector<CStackBasicDescriptor> &creatures) override {}
  44. bool changeStackCount(const StackLocation &sl, TQuantity count, bool absoluteValue = false) override {return false;}
  45. bool changeStackType(const StackLocation &sl, const CCreature *c) override {return false;}
  46. bool insertNewStack(const StackLocation &sl, const CCreature *c, TQuantity count = -1) override {return false;} //count -1 => moves whole stack
  47. bool eraseStack(const StackLocation &sl, bool forceRemoval = false) override {return false;}
  48. bool swapStacks(const StackLocation &sl1, const StackLocation &sl2) override {return false;}
  49. bool addToSlot(const StackLocation &sl, const CCreature *c, TQuantity count) override {return false;} //makes new stack or increases count of already existing
  50. void tryJoiningArmy(const CArmedInstance *src, const CArmedInstance *dst, bool removeObjWhenFinished, bool allowMerging) override {} //merges army from src do dst or opens a garrison window
  51. bool moveStack(const StackLocation &src, const StackLocation &dst, TQuantity count) override {return false;}
  52. void removeAfterVisit(const CGObjectInstance *object) override {} //object will be destroyed when interaction is over. Do not call when interaction is not ongoing!
  53. bool giveHeroNewArtifact(const CGHeroInstance * h, const CArtifact * artType, ArtifactPosition pos) override {return false;}
  54. bool putArtifact(const ArtifactLocation & al, const CArtifactInstance * art, std::optional<bool> askAssemble) override {return false;}
  55. void removeArtifact(const ArtifactLocation &al) override {}
  56. bool moveArtifact(const ArtifactLocation &al1, const ArtifactLocation &al2) override {return false;}
  57. void heroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero) override {}
  58. void stopHeroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero) override {}
  59. void visitCastleObjects(const CGTownInstance * obj, const CGHeroInstance * hero) override {}
  60. void startBattlePrimary(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool creatureBank = false, const CGTownInstance *town = nullptr) override {} //use hero=nullptr for no hero
  61. void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, bool creatureBank = false) override {} //if any of armies is hero, hero will be used
  62. void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, bool creatureBank = false) override {} //if any of armies is hero, hero will be used, visitable tile of second obj is place of battle
  63. bool moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, bool transit = false, PlayerColor asker = PlayerColor::NEUTRAL) override {return false;}
  64. bool swapGarrisonOnSiege(ObjectInstanceID tid) override {return false;}
  65. void giveHeroBonus(GiveBonus * bonus) override {}
  66. void setMovePoints(SetMovePoints * smp) override {}
  67. void setMovePoints(ObjectInstanceID hid, int val, bool absolute) override {};
  68. void setManaPoints(ObjectInstanceID hid, int val) override {}
  69. void giveHero(ObjectInstanceID id, PlayerColor player, ObjectInstanceID boatId = ObjectInstanceID()) override {}
  70. void changeObjPos(ObjectInstanceID objid, int3 newPos, const PlayerColor & initiator) override {}
  71. void heroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2) override {} //when two heroes meet on adventure map
  72. void changeFogOfWar(int3 center, ui32 radius, PlayerColor player, ETileVisibility mode) override {}
  73. void changeFogOfWar(std::unordered_set<int3> &tiles, PlayerColor player, ETileVisibility mode) override {}
  74. void castSpell(const spells::Caster * caster, SpellID spellID, const int3 &pos) override {}
  75. ///useful callback methods
  76. void sendAndApply(CPackForClient * pack) override;
  77. #if SCRIPTING_ENABLED
  78. MOCK_CONST_METHOD0(getGlobalContextPool, scripting::Pool *());
  79. #endif
  80. private:
  81. UpperCallback * upperCallback;
  82. };