BattleProcessor.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * BattleProcessor.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/GameConstants.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class CGHeroInstance;
  14. class CGTownInstance;
  15. class CArmedInstance;
  16. class BattleAction;
  17. class int3;
  18. class BattleInfo;
  19. struct BattleResult;
  20. VCMI_LIB_NAMESPACE_END
  21. class CGameHandler;
  22. class CBattleQuery;
  23. class BattleActionProcessor;
  24. class BattleFlowProcessor;
  25. class BattleResultProcessor;
  26. /// Main class for battle handling. Contains all public interface for battles that is accessible from outside, e.g. for CGameHandler
  27. class BattleProcessor : boost::noncopyable
  28. {
  29. friend class BattleActionProcessor;
  30. friend class BattleFlowProcessor;
  31. friend class BattleResultProcessor;
  32. CGameHandler * gameHandler;
  33. std::unique_ptr<BattleActionProcessor> actionsProcessor;
  34. std::unique_ptr<BattleFlowProcessor> flowProcessor;
  35. std::unique_ptr<BattleResultProcessor> resultProcessor;
  36. void updateGateState();
  37. void engageIntoBattle(PlayerColor player);
  38. bool checkBattleStateChanges();
  39. void setupBattle(int3 tile, const CArmedInstance *armies[2], const CGHeroInstance *heroes[2], bool creatureBank, const CGTownInstance *town);
  40. bool makeAutomaticBattleAction(const BattleAction & ba);
  41. void setBattleResult(EBattleResult resultType, int victoriusSide);
  42. public:
  43. explicit BattleProcessor(CGameHandler * gameHandler);
  44. BattleProcessor();
  45. ~BattleProcessor();
  46. void setGameHandler(CGameHandler * gameHandler);
  47. /// Starts battle with specified parameters
  48. void startBattlePrimary(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool creatureBank = false, const CGTownInstance *town = nullptr);
  49. /// Starts battle between two armies (which can also be heroes) at specified tile
  50. void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, bool creatureBank = false);
  51. /// Starts battle between two armies (which can also be heroes) at position of 2nd object
  52. void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, bool creatureBank = false);
  53. /// Processing of incoming battle action netpack
  54. bool makePlayerBattleAction(PlayerColor player, const BattleAction & ba);
  55. /// Applies results of a battle once player agrees to them
  56. void endBattleConfirm(const BattleInfo * battleInfo);
  57. /// Applies results of a battle after potential levelup
  58. void battleAfterLevelUp(const BattleResult & result);
  59. template <typename Handler> void serialize(Handler &h, const int version)
  60. {
  61. }
  62. };