|
|
@@ -1,5 +1,5 @@
|
|
|
/*
|
|
|
- * CBattleActionsController.h, part of VCMI engine
|
|
|
+ * BattleActionsController.h, part of VCMI engine
|
|
|
*
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
*
|
|
|
@@ -25,39 +25,72 @@ enum class MouseHoveredHexContext
|
|
|
OCCUPIED_HEX
|
|
|
};
|
|
|
|
|
|
+/// Class that controls actions that can be performed by player, e.g. moving stacks, attacking, etc
|
|
|
+/// As well as all relevant feedback for these actions in user interface
|
|
|
class BattleActionsController
|
|
|
{
|
|
|
BattleInterface * owner;
|
|
|
|
|
|
- std::vector<PossiblePlayerBattleAction> possibleActions; //all actions possible to call at the moment by player
|
|
|
- std::vector<PossiblePlayerBattleAction> localActions; //actions possible to take on hovered hex
|
|
|
- std::vector<PossiblePlayerBattleAction> illegalActions; //these actions display message in case of illegal target
|
|
|
- PossiblePlayerBattleAction currentAction; //action that will be performed on l-click
|
|
|
- PossiblePlayerBattleAction selectedAction; //last action chosen (and saved) by player
|
|
|
- PossiblePlayerBattleAction illegalAction; //most likely action that can't be performed here
|
|
|
+ /// all actions possible to call at the moment by player
|
|
|
+ std::vector<PossiblePlayerBattleAction> possibleActions;
|
|
|
|
|
|
- bool creatureCasting; //if true, stack currently aims to cats a spell
|
|
|
- bool spellDestSelectMode; //if true, player is choosing destination for his spell - only for GUI / console
|
|
|
- std::shared_ptr<BattleAction> spellToCast; //spell for which player is choosing destination
|
|
|
- const CSpell *currentSpell; //spell pointer for convenience
|
|
|
+ /// actions possible to take on hovered hex
|
|
|
+ std::vector<PossiblePlayerBattleAction> localActions;
|
|
|
|
|
|
- bool isCastingPossibleHere (const CStack *sactive, const CStack *shere, BattleHex myNumber);
|
|
|
- bool canStackMoveHere (const CStack *sactive, BattleHex MyNumber); //TODO: move to BattleState / callback
|
|
|
+ /// these actions display message in case of illegal target
|
|
|
+ std::vector<PossiblePlayerBattleAction> illegalActions;
|
|
|
|
|
|
- std::vector<PossiblePlayerBattleAction> getPossibleActionsForStack (const CStack *stack); //called when stack gets its turn
|
|
|
- void reorderPossibleActionsPriority(const CStack * stack, MouseHoveredHexContext context);
|
|
|
+ /// action that will be performed on l-click
|
|
|
+ PossiblePlayerBattleAction currentAction;
|
|
|
+
|
|
|
+ /// last action chosen (and saved) by player
|
|
|
+ PossiblePlayerBattleAction selectedAction;
|
|
|
+
|
|
|
+ /// if there are not possible actions to choose from, this action should be show as "illegal" in UI
|
|
|
+ PossiblePlayerBattleAction illegalAction;
|
|
|
+
|
|
|
+ /// if true, stack currently aims to cats a spell
|
|
|
+ bool creatureCasting;
|
|
|
|
|
|
+ /// if true, player is choosing destination for his spell - only for GUI / console
|
|
|
+ bool spellDestSelectMode;
|
|
|
+
|
|
|
+ /// spell for which player is choosing destination
|
|
|
+ std::shared_ptr<BattleAction> spellToCast;
|
|
|
+
|
|
|
+ /// spell for which player is choosing destination, pointer for convenience
|
|
|
+ const CSpell *currentSpell;
|
|
|
+
|
|
|
+ /// cached message that was set by this class in status bar
|
|
|
std::string currentConsoleMsg;
|
|
|
+
|
|
|
+ bool isCastingPossibleHere (const CStack *sactive, const CStack *shere, BattleHex myNumber);
|
|
|
+ bool canStackMoveHere (const CStack *sactive, BattleHex MyNumber) const; //TODO: move to BattleState / callback
|
|
|
+ std::vector<PossiblePlayerBattleAction> getPossibleActionsForStack (const CStack *stack) const; //called when stack gets its turn
|
|
|
+ void reorderPossibleActionsPriority(const CStack * stack, MouseHoveredHexContext context);
|
|
|
+
|
|
|
public:
|
|
|
BattleActionsController(BattleInterface * owner);
|
|
|
|
|
|
+ /// initialize list of potential actions for new active stack
|
|
|
void activateStack();
|
|
|
- void endCastingSpell(); //ends casting spell (eg. when spell has been cast or canceled)
|
|
|
+
|
|
|
+ /// initialize potential actions for spells that can be cast by active stack
|
|
|
void enterCreatureCastingMode();
|
|
|
|
|
|
- SpellID selectedSpell();
|
|
|
- bool spellcastingModeActive();
|
|
|
- void castThisSpell(SpellID spellID); //called when player has chosen a spell from spellbook
|
|
|
+ /// initialize potential actions for selected spell
|
|
|
+ void castThisSpell(SpellID spellID);
|
|
|
+
|
|
|
+ /// ends casting spell (eg. when spell has been cast or canceled)
|
|
|
+ void endCastingSpell();
|
|
|
+
|
|
|
+ /// update UI (e.g. status bar/cursor) according to new active hex
|
|
|
void handleHex(BattleHex myNumber, int eventType);
|
|
|
|
|
|
+ /// returns currently selected spell or SpellID::NONE on error
|
|
|
+ SpellID selectedSpell() const;
|
|
|
+
|
|
|
+ /// returns true if UI is currently in target selection mode
|
|
|
+ bool spellcastingModeActive() const;
|
|
|
+
|
|
|
};
|