2
0

CEmptyAI.cpp 2.4 KB

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