PossiblePlayerBattleAction.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. RANDOM_GENIE_SPELL, // random spell on a friendly creature
  30. NO_LOCATION, // massive spells that affect every possible target, automatic casts
  31. ANY_LOCATION,
  32. OBSTACLE,
  33. TELEPORT,
  34. SACRIFICE,
  35. FREE_LOCATION, // used with Force Field and Fire Wall - all tiles affected by spell must be free
  36. AIMED_SPELL_CREATURE, // spell targeted at creature
  37. };
  38. private:
  39. Actions action;
  40. SpellID spellToCast;
  41. public:
  42. bool spellcast() const
  43. {
  44. return action == ANY_LOCATION || action == NO_LOCATION || action == OBSTACLE || action == TELEPORT ||
  45. action == SACRIFICE || action == FREE_LOCATION || action == AIMED_SPELL_CREATURE;
  46. }
  47. Actions get() const
  48. {
  49. return action;
  50. }
  51. SpellID spell() const
  52. {
  53. return spellToCast;
  54. }
  55. PossiblePlayerBattleAction(Actions action, SpellID spellToCast = SpellID::NONE):
  56. action(static_cast<Actions>(action)),
  57. spellToCast(spellToCast)
  58. {
  59. assert((spellToCast != SpellID::NONE) == spellcast());
  60. }
  61. bool operator == (const PossiblePlayerBattleAction & other) const
  62. {
  63. return action == other.action && spellToCast == other.spellToCast;
  64. }
  65. bool operator != (const PossiblePlayerBattleAction & other) const
  66. {
  67. return action != other.action || spellToCast != other.spellToCast;
  68. }
  69. };
  70. VCMI_LIB_NAMESPACE_END