CBattleActionsController.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * CBattleActionsController.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/CBattleInfoCallback.h"
  12. class BattleAction;
  13. class CBattleInterface;
  14. enum class MouseHoveredHexContext
  15. {
  16. UNOCCUPIED_HEX,
  17. OCCUPIED_HEX
  18. };
  19. class CBattleActionsController
  20. {
  21. CBattleInterface * owner;
  22. std::vector<PossiblePlayerBattleAction> possibleActions; //all actions possible to call at the moment by player
  23. std::vector<PossiblePlayerBattleAction> localActions; //actions possible to take on hovered hex
  24. std::vector<PossiblePlayerBattleAction> illegalActions; //these actions display message in case of illegal target
  25. PossiblePlayerBattleAction currentAction; //action that will be performed on l-click
  26. PossiblePlayerBattleAction selectedAction; //last action chosen (and saved) by player
  27. PossiblePlayerBattleAction illegalAction; //most likely action that can't be performed here
  28. bool creatureCasting; //if true, stack currently aims to cats a spell
  29. bool spellDestSelectMode; //if true, player is choosing destination for his spell - only for GUI / console
  30. std::shared_ptr<BattleAction> spellToCast; //spell for which player is choosing destination
  31. const CSpell *sp; //spell pointer for convenience
  32. bool isCastingPossibleHere (const CStack *sactive, const CStack *shere, BattleHex myNumber);
  33. bool canStackMoveHere (const CStack *sactive, BattleHex MyNumber); //TODO: move to BattleState / callback
  34. std::vector<PossiblePlayerBattleAction> getPossibleActionsForStack (const CStack *stack); //called when stack gets its turn
  35. void reorderPossibleActionsPriority(const CStack * stack, MouseHoveredHexContext context);
  36. public:
  37. CBattleActionsController(CBattleInterface * owner);
  38. void activateStack();
  39. void endCastingSpell(); //ends casting spell (eg. when spell has been cast or canceled)
  40. void enterCreatureCastingMode();
  41. SpellID selectedSpell();
  42. bool spellcastingModeActive();
  43. void castThisSpell(SpellID spellID); //called when player has chosen a spell from spellbook
  44. void handleHex(BattleHex myNumber, int eventType);
  45. };