2
0

ServerSpellCastEnvironment.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * ServerSpellCastEnvironment.cpp, 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. #include "StdInc.h"
  11. #include "ServerSpellCastEnvironment.h"
  12. #include "CGameHandler.h"
  13. #include "queries/QueriesProcessor.h"
  14. #include "queries/CQuery.h"
  15. #include "../lib/gameState/CGameState.h"
  16. #include "../lib/networkPacks/PacksForClientBattle.h"
  17. #include "../lib/networkPacks/SetStackEffect.h"
  18. ///ServerSpellCastEnvironment
  19. ServerSpellCastEnvironment::ServerSpellCastEnvironment(CGameHandler * gh)
  20. : gh(gh)
  21. {
  22. }
  23. bool ServerSpellCastEnvironment::describeChanges() const
  24. {
  25. return true;
  26. }
  27. void ServerSpellCastEnvironment::complain(const std::string & problem)
  28. {
  29. gh->complain(problem);
  30. }
  31. vstd::RNG * ServerSpellCastEnvironment::getRNG()
  32. {
  33. return &gh->getRandomGenerator();
  34. }
  35. void ServerSpellCastEnvironment::apply(CPackForClient & pack)
  36. {
  37. gh->sendAndApply(pack);
  38. }
  39. void ServerSpellCastEnvironment::apply(BattleLogMessage & pack)
  40. {
  41. gh->sendAndApply(pack);
  42. }
  43. void ServerSpellCastEnvironment::apply(BattleStackMoved & pack)
  44. {
  45. gh->sendAndApply(pack);
  46. }
  47. void ServerSpellCastEnvironment::apply(BattleUnitsChanged & pack)
  48. {
  49. gh->sendAndApply(pack);
  50. }
  51. void ServerSpellCastEnvironment::apply(SetStackEffect & pack)
  52. {
  53. gh->sendAndApply(pack);
  54. }
  55. void ServerSpellCastEnvironment::apply(StacksInjured & pack)
  56. {
  57. gh->sendAndApply(pack);
  58. }
  59. void ServerSpellCastEnvironment::apply(BattleObstaclesChanged & pack)
  60. {
  61. gh->sendAndApply(pack);
  62. }
  63. void ServerSpellCastEnvironment::apply(CatapultAttack & pack)
  64. {
  65. gh->sendAndApply(pack);
  66. }
  67. const CGameInfoCallback * ServerSpellCastEnvironment::getCb() const
  68. {
  69. return gh;
  70. }
  71. const CMap * ServerSpellCastEnvironment::getMap() const
  72. {
  73. return &gh->gameState()->getMap();
  74. }
  75. bool ServerSpellCastEnvironment::moveHero(ObjectInstanceID hid, int3 dst, EMovementMode mode)
  76. {
  77. return gh->moveHero(hid, dst, mode, false);
  78. }
  79. void ServerSpellCastEnvironment::createBoat(const int3 & visitablePosition, BoatId type, PlayerColor initiator)
  80. {
  81. return gh->createBoat(visitablePosition, type, initiator);
  82. }
  83. void ServerSpellCastEnvironment::genericQuery(Query * request, PlayerColor color, std::function<void(std::optional<int32_t>)> callback)
  84. {
  85. auto query = std::make_shared<CGenericQuery>(gh, color, callback);
  86. request->queryID = query->queryID;
  87. gh->queries->addQuery(query);
  88. gh->sendAndApply(*request);
  89. }