PossiblePlayerBattleAction.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * CBattleInfoCallback.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. #include "../GameConstants.h"
  11. VCMI_LIB_NAMESPACE_BEGIN
  12. class PossiblePlayerBattleAction // actions performed at l-click
  13. {
  14. public:
  15. enum Actions {
  16. INVALID = -1,
  17. CREATURE_INFO,
  18. HERO_INFO,
  19. MOVE_TACTICS,
  20. CHOOSE_TACTICS_STACK,
  21. MOVE_STACK,
  22. ATTACK,
  23. WALK_AND_ATTACK,
  24. ATTACK_AND_RETURN,
  25. SHOOT,
  26. CATAPULT,
  27. HEAL,
  28. RANDOM_GENIE_SPELL, // random spell on a friendly creature
  29. NO_LOCATION, // massive spells that affect every possible target, automatic casts
  30. ANY_LOCATION,
  31. OBSTACLE,
  32. TELEPORT,
  33. SACRIFICE,
  34. FREE_LOCATION, // used with Force Field and Fire Wall - all tiles affected by spell must be free
  35. AIMED_SPELL_CREATURE, // spell targeted at creature
  36. };
  37. private:
  38. Actions action;
  39. SpellID spellToCast;
  40. public:
  41. bool spellcast() const
  42. {
  43. return action == ANY_LOCATION || action == NO_LOCATION || action == OBSTACLE || action == TELEPORT ||
  44. action == SACRIFICE || action == FREE_LOCATION || action == AIMED_SPELL_CREATURE;
  45. }
  46. Actions get() const
  47. {
  48. return action;
  49. }
  50. SpellID spell() const
  51. {
  52. return spellToCast;
  53. }
  54. PossiblePlayerBattleAction(Actions action, SpellID spellToCast = SpellID::NONE):
  55. action(static_cast<Actions>(action)),
  56. spellToCast(spellToCast)
  57. {
  58. assert((spellToCast != SpellID::NONE) == spellcast());
  59. }
  60. bool operator == (const PossiblePlayerBattleAction & other) const
  61. {
  62. return action == other.action && spellToCast == other.spellToCast;
  63. }
  64. };
  65. VCMI_LIB_NAMESPACE_END