2015-03-10 19:32:05 +02:00
|
|
|
/*
|
|
|
|
* CDefaultSpellMechanics.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
|
|
|
|
|
|
|
|
#include "ISpellMechanics.h"
|
|
|
|
|
2016-08-30 04:13:45 +02:00
|
|
|
struct StacksInjured;
|
2015-03-10 19:32:05 +02:00
|
|
|
|
|
|
|
struct SpellCastContext
|
|
|
|
{
|
|
|
|
SpellCastContext(std::vector<const CStack *> & attackedCres, BattleSpellCast & sc, StacksInjured & si):
|
2016-02-15 12:34:37 +02:00
|
|
|
attackedCres(attackedCres), sc(sc), si(si)
|
2015-09-16 14:43:39 +02:00
|
|
|
{
|
|
|
|
};
|
2015-03-10 19:32:05 +02:00
|
|
|
std::vector<const CStack *> & attackedCres;
|
|
|
|
BattleSpellCast & sc;
|
2015-09-16 14:43:39 +02:00
|
|
|
StacksInjured & si;
|
2015-03-10 19:32:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE DefaultSpellMechanics : public ISpellMechanics
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DefaultSpellMechanics(CSpell * s): ISpellMechanics(s){};
|
|
|
|
|
|
|
|
std::vector<BattleHex> rangeInHexes(BattleHex centralHex, ui8 schoolLvl, ui8 side, bool * outDroppedHexes = nullptr) const override;
|
2016-09-04 04:15:37 +02:00
|
|
|
std::set<const CStack *> getAffectedStacks(const CBattleInfoCallback * cb, SpellTargetingContext & ctx) const override;
|
2015-03-10 19:32:05 +02:00
|
|
|
|
2016-03-01 06:32:02 +02:00
|
|
|
ESpellCastProblem::ESpellCastProblem canBeCast(const CBattleInfoCallback * cb, const ISpellCaster * caster) const override;
|
2016-09-04 04:15:37 +02:00
|
|
|
ESpellCastProblem::ESpellCastProblem canBeCast(const CBattleInfoCallback * cb, const SpellTargetingContext & ctx) const override;
|
2016-02-15 12:34:37 +02:00
|
|
|
|
2015-09-26 19:09:54 +02:00
|
|
|
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const ISpellCaster * caster, const CStack * obj) const override;
|
2015-03-10 19:32:05 +02:00
|
|
|
|
|
|
|
virtual void applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const override;
|
2016-09-04 07:19:28 +02:00
|
|
|
|
2015-09-16 16:00:58 +02:00
|
|
|
void battleCast(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters) const override final;
|
2015-03-10 19:32:05 +02:00
|
|
|
|
2016-02-15 12:34:37 +02:00
|
|
|
void battleLogSingleTarget(std::vector<std::string> & logLines, const BattleSpellCast * packet,
|
|
|
|
const std::string & casterName, const CStack * attackedStack, bool & displayDamage) const override;
|
2016-09-05 10:36:25 +02:00
|
|
|
|
|
|
|
bool requiresCreatureTarget() const override;
|
2015-03-10 19:32:05 +02:00
|
|
|
protected:
|
2015-09-26 20:35:30 +02:00
|
|
|
virtual void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const;
|
2015-03-10 19:32:05 +02:00
|
|
|
|
2015-09-16 16:00:58 +02:00
|
|
|
void doDispell(BattleInfo * battle, const BattleSpellCast * packet, const CSelector & selector) const;
|
|
|
|
private:
|
2015-09-17 04:47:32 +02:00
|
|
|
void castMagicMirror(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters) const;
|
2015-09-16 16:00:58 +02:00
|
|
|
void handleResistance(const SpellCastEnvironment * env, std::vector<const CStack*> & attackedCres, BattleSpellCast & sc) const;
|
|
|
|
void prepareBattleCast(const BattleSpellCastParameters & parameters, BattleSpellCast & sc) const;
|
2015-03-10 19:32:05 +02:00
|
|
|
};
|