ServerSpellCastEnvironment.cpp 2.1 KB

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