CEmptyAI.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * CEmptyAI.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 "CEmptyAI.h"
  12. #include "../../lib/CRandomGenerator.h"
  13. #include "../../lib/CStack.h"
  14. #include "../../lib/battle/BattleAction.h"
  15. void CEmptyAI::saveGame(BinarySerializer & h, const int version)
  16. {
  17. }
  18. void CEmptyAI::loadGame(BinaryDeserializer & h, const int version)
  19. {
  20. }
  21. void CEmptyAI::initGameInterface(std::shared_ptr<Environment> ENV, std::shared_ptr<CCallback> CB)
  22. {
  23. cb = CB;
  24. env = ENV;
  25. human=false;
  26. playerID = *cb->getMyColor();
  27. }
  28. void CEmptyAI::yourTurn()
  29. {
  30. cb->endTurn();
  31. }
  32. void CEmptyAI::activeStack(const CStack * stack)
  33. {
  34. cb->battleMakeUnitAction(BattleAction::makeDefend(stack));
  35. }
  36. void CEmptyAI::yourTacticPhase(int distance)
  37. {
  38. cb->battleMakeTacticAction(BattleAction::makeEndOFTacticPhase(cb->battleGetTacticsSide()));
  39. }
  40. void CEmptyAI::heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID)
  41. {
  42. cb->selectionMade(CRandomGenerator::getDefault().nextInt((int)skills.size() - 1), queryID);
  43. }
  44. void CEmptyAI::commanderGotLevel(const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID)
  45. {
  46. cb->selectionMade(CRandomGenerator::getDefault().nextInt((int)skills.size() - 1), queryID);
  47. }
  48. void CEmptyAI::showBlockingDialog(const std::string &text, const std::vector<Component> &components, QueryID askID, const int soundID, bool selection, bool cancel)
  49. {
  50. cb->selectionMade(0, askID);
  51. }
  52. void CEmptyAI::showTeleportDialog(TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID)
  53. {
  54. cb->selectionMade(0, askID);
  55. }
  56. void CEmptyAI::showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, QueryID queryID)
  57. {
  58. cb->selectionMade(0, queryID);
  59. }
  60. void CEmptyAI::showMapObjectSelectDialog(QueryID askID, const Component & icon, const MetaString & title, const MetaString & description, const std::vector<ObjectInstanceID> & objects)
  61. {
  62. cb->selectionMade(0, askID);
  63. }
  64. std::optional<BattleAction> CEmptyAI::makeSurrenderRetreatDecision(const BattleStateInfoForRetreat & battleState)
  65. {
  66. return std::nullopt;
  67. }