BattleActionProcessor.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * BattleActionProcessor.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. VCMI_LIB_NAMESPACE_BEGIN
  12. struct BattleLogMessage;
  13. struct BattleAttack;
  14. class BattleAction;
  15. struct BattleHex;
  16. class CStack;
  17. class PlayerColor;
  18. enum class BonusType;
  19. namespace battle
  20. {
  21. class Unit;
  22. class CUnitState;
  23. }
  24. VCMI_LIB_NAMESPACE_END
  25. class CGameHandler;
  26. class BattleProcessor;
  27. /// Processes incoming battle action queries and applies requested action(s)
  28. class BattleActionProcessor : boost::noncopyable
  29. {
  30. using FireShieldInfo = std::vector<std::pair<const CStack *, int64_t>>;
  31. BattleProcessor * owner;
  32. CGameHandler * gameHandler;
  33. int moveStack(int stack, BattleHex dest); //returned value - travelled distance
  34. void makeAttack(const CStack * attacker, const CStack * defender, int distance, BattleHex targetHex, bool first, bool ranged, bool counter);
  35. void handleAttackBeforeCasting(bool ranged, const CStack * attacker, const CStack * defender);
  36. void handleAfterAttackCasting(bool ranged, const CStack * attacker, const CStack * defender);
  37. void attackCasting(bool ranged, BonusType attackMode, const battle::Unit * attacker, const battle::Unit * defender);
  38. // damage, drain life & fire shield; returns amount of drained life
  39. int64_t applyBattleEffects(BattleAttack & bat, std::shared_ptr<battle::CUnitState> attackerState, FireShieldInfo & fireShield, const CStack * def, int distance, bool secondary);
  40. void sendGenericKilledLog(const CStack * defender, int32_t killed, bool multiple);
  41. void addGenericKilledLog(BattleLogMessage & blm, const CStack * defender, int32_t killed, bool multiple);
  42. bool canStackAct(const CStack * stack);
  43. bool doEmptyAction(const BattleAction & ba);
  44. bool doEndTacticsAction(const BattleAction & ba);
  45. bool doRetreatAction(const BattleAction & ba);
  46. bool doSurrenderAction(const BattleAction & ba);
  47. bool doHeroSpellAction(const BattleAction & ba);
  48. bool doWalkAction(const BattleAction & ba);
  49. bool doWaitAction(const BattleAction & ba);
  50. bool doDefendAction(const BattleAction & ba);
  51. bool doAttackAction(const BattleAction & ba);
  52. bool doShootAction(const BattleAction & ba);
  53. bool doCatapultAction(const BattleAction & ba);
  54. bool doUnitSpellAction(const BattleAction & ba);
  55. bool doHealAction(const BattleAction & ba);
  56. bool dispatchBattleAction(const BattleAction & ba);
  57. bool makeBattleActionImpl(const BattleAction & ba);
  58. public:
  59. explicit BattleActionProcessor(BattleProcessor * owner);
  60. void setGameHandler(CGameHandler * newGameHandler);
  61. bool makeAutomaticBattleAction(const BattleAction & ba);
  62. bool makePlayerBattleAction(PlayerColor player, const BattleAction & ba);
  63. };