mock_IGameCallback.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 setBankObjectConfiguration(ObjectInstanceID objid, const BankConfig & configuration) override {}
  28. void setRewardableObjectConfiguration(ObjectInstanceID mapObjectID, const Rewardable::Configuration & configuration) override {}
  29. void setRewardableObjectConfiguration(ObjectInstanceID townInstanceID, BuildingID buildingID, const Rewardable::Configuration & configuration) override {}
  30. void showInfoDialog(InfoWindow * iw) override {}
  31. void changeSpells(const CGHeroInstance * hero, bool give, const std::set<SpellID> &spells) override {}
  32. bool removeObject(const CGObjectInstance * obj, const PlayerColor & initiator) override {return false;}
  33. void createBoat(const int3 & visitablePosition, BoatId type, PlayerColor initiator) override {}
  34. void setOwner(const CGObjectInstance * objid, PlayerColor owner) override {}
  35. void giveExperience(const CGHeroInstance * hero, TExpType val) override {}
  36. void changePrimSkill(const CGHeroInstance * hero, PrimarySkill which, si64 val, bool abs=false) override {}
  37. void changeSecSkill(const CGHeroInstance * hero, SecondarySkill which, int val, bool abs=false) override {}
  38. void showBlockingDialog(const IObjectInterface * caller, BlockingDialog *iw) override {}
  39. void showGarrisonDialog(ObjectInstanceID upobj, ObjectInstanceID hid, bool removableUnits) override {} //cb will be called when player closes garrison window
  40. void showTeleportDialog(TeleportDialog *iw) override {}
  41. void showObjectWindow(const CGObjectInstance * object, EOpenWindowMode window, const CGHeroInstance * visitor, bool addQuery) override {};
  42. void giveResource(PlayerColor player, GameResID which, int val) override {}
  43. void giveResources(PlayerColor player, TResources resources) override {}
  44. void giveCreatures(const CArmedInstance *objid, const CGHeroInstance * h, const CCreatureSet &creatures, bool remove) override {}
  45. void takeCreatures(ObjectInstanceID objid, const std::vector<CStackBasicDescriptor> &creatures) override {}
  46. bool changeStackCount(const StackLocation &sl, TQuantity count, bool absoluteValue = false) override {return false;}
  47. bool changeStackType(const StackLocation &sl, const CCreature *c) override {return false;}
  48. bool insertNewStack(const StackLocation &sl, const CCreature *c, TQuantity count = -1) override {return false;} //count -1 => moves whole stack
  49. bool eraseStack(const StackLocation &sl, bool forceRemoval = false) override {return false;}
  50. bool swapStacks(const StackLocation &sl1, const StackLocation &sl2) override {return false;}
  51. bool addToSlot(const StackLocation &sl, const CCreature *c, TQuantity count) override {return false;} //makes new stack or increases count of already existing
  52. void tryJoiningArmy(const CArmedInstance *src, const CArmedInstance *dst, bool removeObjWhenFinished, bool allowMerging) override {} //merges army from src do dst or opens a garrison window
  53. bool moveStack(const StackLocation &src, const StackLocation &dst, TQuantity count) override {return false;}
  54. void removeAfterVisit(const CGObjectInstance *object) override {} //object will be destroyed when interaction is over. Do not call when interaction is not ongoing!
  55. bool giveHeroNewArtifact(const CGHeroInstance * h, const ArtifactID & artId, const ArtifactPosition & pos) override {return false;}
  56. bool giveHeroNewScroll(const CGHeroInstance * h, const SpellID & spellId, const ArtifactPosition & pos) override {return false;}
  57. bool putArtifact(const ArtifactLocation & al, const ArtifactInstanceID & id, std::optional<bool> askAssemble) override {return false;}
  58. void removeArtifact(const ArtifactLocation &al) override {}
  59. bool moveArtifact(const PlayerColor & player, const ArtifactLocation & al1, const ArtifactLocation & al2) override {return false;}
  60. void heroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero) override {}
  61. void stopHeroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero) override {}
  62. void visitCastleObjects(const CGTownInstance * obj, const CGHeroInstance * hero) override {}
  63. void startBattle(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, const BattleLayout & layout, const CGTownInstance *town) override {} //use hero=nullptr for no hero
  64. void startBattle(const CArmedInstance *army1, const CArmedInstance *army2) override {}
  65. bool moveHero(ObjectInstanceID hid, int3 dst, EMovementMode movementMode, bool transit = false, PlayerColor asker = PlayerColor::NEUTRAL) override {return false;}
  66. bool swapGarrisonOnSiege(ObjectInstanceID tid) override {return false;}
  67. void giveHeroBonus(GiveBonus * bonus) override {}
  68. void setMovePoints(SetMovePoints * smp) override {}
  69. void setMovePoints(ObjectInstanceID hid, int val, bool absolute) override {};
  70. void setManaPoints(ObjectInstanceID hid, int val) override {}
  71. void giveHero(ObjectInstanceID id, PlayerColor player, ObjectInstanceID boatId = ObjectInstanceID()) override {}
  72. void changeObjPos(ObjectInstanceID objid, int3 newPos, const PlayerColor & initiator) override {}
  73. void heroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2) override {} //when two heroes meet on adventure map
  74. void changeFogOfWar(int3 center, ui32 radius, PlayerColor player, ETileVisibility mode) override {}
  75. void changeFogOfWar(const std::unordered_set<int3> &tiles, PlayerColor player, ETileVisibility mode) override {}
  76. void castSpell(const spells::Caster * caster, SpellID spellID, const int3 &pos) override {}
  77. ///useful callback methods
  78. void sendAndApply(CPackForClient * pack) override;
  79. vstd::RNG & getRandomGenerator() override;
  80. #if SCRIPTING_ENABLED
  81. MOCK_CONST_METHOD0(getGlobalContextPool, scripting::Pool *());
  82. #endif
  83. private:
  84. UpperCallback * upperCallback;
  85. };