| 
									
										
										
										
											2015-03-18 22:22:52 +03:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Magic.h, part of VCMI engine | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Authors: listed in file AUTHORS in main folder | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * License: GNU General Public License v2.0 or later | 
					
						
							|  |  |  |  * Full text of license available in license.txt file, in main folder | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * High-level interface for spells subsystem | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class CSpell; | 
					
						
							| 
									
										
										
										
											2015-09-17 09:29:57 +03:00
										 |  |  | class PlayerColor; | 
					
						
							| 
									
										
										
										
											2016-09-10 18:23:55 +03:00
										 |  |  | struct MetaString; | 
					
						
							| 
									
										
										
										
											2017-07-20 07:08:49 +03:00
										 |  |  | struct CPackForClient; | 
					
						
							| 
									
										
										
										
											2015-03-18 22:22:52 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-20 07:08:49 +03:00
										 |  |  | namespace battle | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	class Unit; | 
					
						
							|  |  |  | 	class Destination; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace spells | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Mechanics; | 
					
						
							|  |  |  | class BattleCast; | 
					
						
							|  |  |  | using Destination = ::battle::Destination; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using Target = std::vector<Destination>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct SchoolInfo; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | enum class Mode | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	//ACTIVE, //todo: use
 | 
					
						
							|  |  |  | 	HERO, //deprecated
 | 
					
						
							|  |  |  | 	MAGIC_MIRROR, | 
					
						
							|  |  |  | 	CREATURE_ACTIVE, //deprecated
 | 
					
						
							|  |  |  | 	ENCHANTER, | 
					
						
							|  |  |  | 	SPELL_LIKE_ATTACK, | 
					
						
							|  |  |  | 	PASSIVE//f.e. opening battle spells
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | enum class AimType | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	NO_TARGET, | 
					
						
							|  |  |  | 	CREATURE, | 
					
						
							|  |  |  | 	OBSTACLE, | 
					
						
							|  |  |  | 	LOCATION | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DLL_LINKAGE PacketSender | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	virtual ~PacketSender(){}; | 
					
						
							| 
									
										
										
										
											2018-02-26 00:16:15 +08:00
										 |  |  | 	virtual void sendAndApply(CPackForClient * pack) const = 0; | 
					
						
							| 
									
										
										
										
											2017-07-20 07:08:49 +03:00
										 |  |  | 	virtual void complain(const std::string & problem) const = 0; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DLL_LINKAGE Problem | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	typedef int Severity; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	enum ESeverity | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		LOWEST = std::numeric_limits<Severity>::min(), | 
					
						
							|  |  |  | 		NORMAL = 0, | 
					
						
							|  |  |  | 		CRITICAL = std::numeric_limits<Severity>::max() | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	virtual ~Problem() = default; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	virtual void add(MetaString && description, Severity severity = CRITICAL) = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	virtual void getAll(std::vector<std::string> & target) const = 0; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DLL_LINKAGE Spell | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	virtual ~Spell() = default; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	virtual int32_t getIndex() const = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-02 13:22:51 +03:00
										 |  |  | 	virtual int32_t getLevel() const = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-20 07:08:49 +03:00
										 |  |  | 	virtual void forEachSchool(const std::function<void (const SchoolInfo &, bool &)> & cb) const = 0; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DLL_LINKAGE Caster | 
					
						
							| 
									
										
										
										
											2015-03-18 22:22:52 +03:00
										 |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2017-07-20 07:08:49 +03:00
										 |  |  | 	virtual ~Caster() = default; | 
					
						
							| 
									
										
										
										
											2016-02-15 13:34:37 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-04 11:13:07 +03:00
										 |  |  | 	virtual int32_t getCasterUnitId() const = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-18 22:22:52 +03:00
										 |  |  | 	/// returns level on which given spell would be cast by this(0 - none, 1 - basic etc);
 | 
					
						
							| 
									
										
										
										
											2016-02-15 13:34:37 +03:00
										 |  |  | 	/// caster may not know this spell at all
 | 
					
						
							| 
									
										
										
										
											2015-03-18 22:22:52 +03:00
										 |  |  | 	/// optionally returns number of selected school by arg - 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic
 | 
					
						
							| 
									
										
										
										
											2017-07-20 07:08:49 +03:00
										 |  |  | 	virtual ui8 getSpellSchoolLevel(const Spell * spell, int * outSelectedSchool = nullptr) const = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	///default spell school level for effect calculation
 | 
					
						
							|  |  |  | 	virtual int getEffectLevel(const Spell * spell) const = 0; | 
					
						
							| 
									
										
										
										
											2015-09-17 08:42:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	///applying sorcery secondary skill etc
 | 
					
						
							| 
									
										
										
										
											2017-07-20 07:08:49 +03:00
										 |  |  | 	virtual int64_t getSpellBonus(const Spell * spell, int64_t base, const battle::Unit * affectedStack) const = 0; | 
					
						
							| 
									
										
										
										
											2016-02-15 13:34:37 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-20 07:08:49 +03:00
										 |  |  | 	///only bonus for particular spell
 | 
					
						
							|  |  |  | 	virtual int64_t getSpecificSpellBonus(const Spell * spell, int64_t base) const = 0; | 
					
						
							| 
									
										
										
										
											2015-09-17 08:42:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	///default spell-power for damage/heal calculation
 | 
					
						
							| 
									
										
										
										
											2017-07-20 07:08:49 +03:00
										 |  |  | 	virtual int getEffectPower(const Spell * spell) const = 0; | 
					
						
							| 
									
										
										
										
											2015-09-17 08:42:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	///default spell-power for timed effects duration
 | 
					
						
							| 
									
										
										
										
											2017-07-20 07:08:49 +03:00
										 |  |  | 	virtual int getEnchantPower(const Spell * spell) const = 0; | 
					
						
							| 
									
										
										
										
											2015-09-17 08:42:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	///damage/heal override(ignores spell configuration, effect level and effect power)
 | 
					
						
							| 
									
										
										
										
											2017-07-20 07:08:49 +03:00
										 |  |  | 	virtual int64_t getEffectValue(const Spell * spell) const = 0; | 
					
						
							| 
									
										
										
										
											2016-02-15 13:34:37 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-17 09:29:57 +03:00
										 |  |  | 	virtual const PlayerColor getOwner() const = 0; | 
					
						
							| 
									
										
										
										
											2016-09-10 18:23:55 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-17 23:04:23 +03:00
										 |  |  | 	///only name substitution
 | 
					
						
							| 
									
										
										
										
											2016-09-10 18:23:55 +03:00
										 |  |  | 	virtual void getCasterName(MetaString & text) const = 0; | 
					
						
							| 
									
										
										
										
											2016-09-17 23:04:23 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	///full default text
 | 
					
						
							| 
									
										
										
										
											2017-07-20 07:08:49 +03:00
										 |  |  | 	virtual void getCastDescription(const Spell * spell, const std::vector<const battle::Unit *> & attacked, MetaString & text) const = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	virtual void spendMana(const PacketSender * server, const int spellCost) const = 0; | 
					
						
							| 
									
										
										
										
											2015-03-18 22:22:52 +03:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2017-07-20 07:08:49 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | } |