Magic.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Magic.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. /**
  12. * High-level interface for spells subsystem
  13. */
  14. class CSpell;
  15. class PlayerColor;
  16. struct MetaString;
  17. struct CPackForClient;
  18. namespace battle
  19. {
  20. class Unit;
  21. class Destination;
  22. }
  23. namespace spells
  24. {
  25. class Mechanics;
  26. class BattleCast;
  27. using Destination = ::battle::Destination;
  28. using Target = std::vector<Destination>;
  29. struct SchoolInfo;
  30. enum class Mode
  31. {
  32. //ACTIVE, //todo: use
  33. HERO, //deprecated
  34. MAGIC_MIRROR,
  35. CREATURE_ACTIVE, //deprecated
  36. ENCHANTER,
  37. SPELL_LIKE_ATTACK,
  38. PASSIVE//f.e. opening battle spells
  39. };
  40. enum class AimType
  41. {
  42. NO_TARGET,
  43. CREATURE,
  44. OBSTACLE,
  45. LOCATION
  46. };
  47. class DLL_LINKAGE PacketSender
  48. {
  49. public:
  50. virtual ~PacketSender(){};
  51. virtual void sendAndApply(CPackForClient * info) const = 0;
  52. virtual void complain(const std::string & problem) const = 0;
  53. };
  54. class DLL_LINKAGE Problem
  55. {
  56. public:
  57. typedef int Severity;
  58. enum ESeverity
  59. {
  60. LOWEST = std::numeric_limits<Severity>::min(),
  61. NORMAL = 0,
  62. CRITICAL = std::numeric_limits<Severity>::max()
  63. };
  64. virtual ~Problem() = default;
  65. virtual void add(MetaString && description, Severity severity = CRITICAL) = 0;
  66. virtual void getAll(std::vector<std::string> & target) const = 0;
  67. };
  68. class DLL_LINKAGE Spell
  69. {
  70. public:
  71. virtual ~Spell() = default;
  72. virtual int32_t getIndex() const = 0;
  73. virtual int32_t getLevel() const = 0;
  74. virtual void forEachSchool(const std::function<void (const SchoolInfo &, bool &)> & cb) const = 0;
  75. };
  76. class DLL_LINKAGE Caster
  77. {
  78. public:
  79. virtual ~Caster() = default;
  80. /// returns level on which given spell would be cast by this(0 - none, 1 - basic etc);
  81. /// caster may not know this spell at all
  82. /// optionally returns number of selected school by arg - 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic
  83. virtual ui8 getSpellSchoolLevel(const Spell * spell, int * outSelectedSchool = nullptr) const = 0;
  84. ///default spell school level for effect calculation
  85. virtual int getEffectLevel(const Spell * spell) const = 0;
  86. ///applying sorcery secondary skill etc
  87. virtual int64_t getSpellBonus(const Spell * spell, int64_t base, const battle::Unit * affectedStack) const = 0;
  88. ///only bonus for particular spell
  89. virtual int64_t getSpecificSpellBonus(const Spell * spell, int64_t base) const = 0;
  90. ///default spell-power for damage/heal calculation
  91. virtual int getEffectPower(const Spell * spell) const = 0;
  92. ///default spell-power for timed effects duration
  93. virtual int getEnchantPower(const Spell * spell) const = 0;
  94. ///damage/heal override(ignores spell configuration, effect level and effect power)
  95. virtual int64_t getEffectValue(const Spell * spell) const = 0;
  96. virtual const PlayerColor getOwner() const = 0;
  97. ///only name substitution
  98. virtual void getCasterName(MetaString & text) const = 0;
  99. ///full default text
  100. virtual void getCastDescription(const Spell * spell, const std::vector<const battle::Unit *> & attacked, MetaString & text) const = 0;
  101. virtual void spendMana(const PacketSender * server, const int spellCost) const = 0;
  102. };
  103. }