PossiblePlayerBattleAction.h 1.9 KB

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