CBattleActionsController.h 2.3 KB

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