mock_IGameCallback.h 6.8 KB

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