ServerSpellCastEnvironment.cpp 2.1 KB

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