BattleFlowProcessor.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * BattleFlowProcessor.h, 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. #pragma once
  11. #include "../lib/battle/BattleSide.h"
  12. #include "../lib/battle/BattleUnitTurnReason.h"
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. class CStack;
  15. class BattleHex;
  16. class BattleHexArray;
  17. class BattleAction;
  18. class CBattleInfoCallback;
  19. struct CObstacleInstance;
  20. namespace battle
  21. {
  22. class Unit;
  23. }
  24. VCMI_LIB_NAMESPACE_END
  25. class CGameHandler;
  26. class BattleProcessor;
  27. /// Controls flow of battles - battle startup actions and switching to next stack or next round after actions
  28. class BattleFlowProcessor : boost::noncopyable
  29. {
  30. BattleProcessor * owner;
  31. CGameHandler * gameHandler;
  32. const CStack * getNextStack(const CBattleInfoCallback & battle);
  33. bool rollGoodMorale(const CBattleInfoCallback & battle, const CStack * stack);
  34. bool tryMakeAutomaticAction(const CBattleInfoCallback & battle, const CStack * stack);
  35. void summonGuardiansHelper(const CBattleInfoCallback & battle, BattleHexArray & output, const BattleHex & targetPosition, BattleSide side, bool targetIsTwoHex);
  36. void trySummonGuardians(const CBattleInfoCallback & battle, const CStack * stack);
  37. void tryPlaceMoats(const CBattleInfoCallback & battle);
  38. void castOpeningSpells(const CBattleInfoCallback & battle);
  39. void activateNextStack(const CBattleInfoCallback & battle);
  40. void startNextRound(const CBattleInfoCallback & battle, bool isFirstRound);
  41. void stackEnchantedTrigger(const CBattleInfoCallback & battle, const CStack * stack);
  42. void removeObstacle(const CBattleInfoCallback & battle, const CObstacleInstance & obstacle);
  43. void stackTurnTrigger(const CBattleInfoCallback & battle, const CStack * stack);
  44. void setActiveStack(const CBattleInfoCallback & battle, const battle::Unit * stack, BattleUnitTurnReason reason);
  45. void makeStackDoNothing(const CBattleInfoCallback & battle, const CStack * next);
  46. bool makeAutomaticAction(const CBattleInfoCallback & battle, const CStack * stack, BattleAction & ba); //used when action is taken by stack without volition of player (eg. unguided catapult attack)
  47. public:
  48. explicit BattleFlowProcessor(BattleProcessor * owner, CGameHandler * newGameHandler);
  49. void onBattleStarted(const CBattleInfoCallback & battle);
  50. void onTacticsEnded(const CBattleInfoCallback & battle);
  51. void onActionMade(const CBattleInfoCallback & battle, const BattleAction & ba);
  52. };