2014-11-12 10:36:34 +02:00
|
|
|
/*
|
|
|
|
* SpellMechanics.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 "CSpellHandler.h"
|
2014-11-13 11:22:20 +02:00
|
|
|
#include "BattleHex.h"
|
2014-11-12 10:36:34 +02:00
|
|
|
|
2014-11-13 06:34:20 +02:00
|
|
|
class DLL_LINKAGE ISpellMechanics
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2014-11-13 11:22:20 +02:00
|
|
|
struct DLL_LINKAGE SpellTargetingContext
|
2014-11-13 06:34:20 +02:00
|
|
|
{
|
2014-11-13 11:22:20 +02:00
|
|
|
const CBattleInfoCallback * cb;
|
2014-11-13 06:34:20 +02:00
|
|
|
CSpell::TargetInfo ti;
|
2014-11-13 11:22:20 +02:00
|
|
|
ECastingMode::ECastingMode mode;
|
|
|
|
BattleHex destination;
|
|
|
|
PlayerColor casterColor;
|
2014-11-13 06:34:20 +02:00
|
|
|
int schoolLvl;
|
2014-11-13 11:22:20 +02:00
|
|
|
|
|
|
|
SpellTargetingContext(const CSpell * s, const CBattleInfoCallback * c, ECastingMode::ECastingMode m, PlayerColor cc, int lvl, BattleHex dest)
|
2014-11-13 13:35:58 +02:00
|
|
|
: cb(c), ti(s,lvl, m), mode(m), destination(dest), casterColor(cc), schoolLvl(lvl)
|
2014-11-13 11:22:20 +02:00
|
|
|
{};
|
|
|
|
|
2014-11-13 06:34:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
ISpellMechanics(CSpell * s);
|
|
|
|
virtual ~ISpellMechanics(){};
|
|
|
|
|
|
|
|
virtual std::vector<BattleHex> rangeInHexes(BattleHex centralHex, ui8 schoolLvl, ui8 side, bool *outDroppedHexes = nullptr) const = 0;
|
|
|
|
virtual std::set<const CStack *> getAffectedStacks(SpellTargetingContext & ctx) const = 0;
|
|
|
|
|
|
|
|
virtual ESpellCastProblem::ESpellCastProblem isImmuneByStack(const CGHeroInstance * caster, const CStack * obj) const = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/** \brief
|
|
|
|
*
|
|
|
|
* \param
|
|
|
|
* \return true if no error
|
|
|
|
*
|
|
|
|
*/
|
2014-11-23 13:10:29 +02:00
|
|
|
virtual bool adventureCast(const SpellCastContext & context) const = 0;
|
|
|
|
virtual bool battleCast(const SpellCastContext & context) const = 0;
|
2014-11-13 06:34:20 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
CSpell * owner;
|
|
|
|
};
|
|
|
|
|
2014-11-12 10:36:34 +02:00
|
|
|
class DefaultSpellMechanics: public ISpellMechanics
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DefaultSpellMechanics(CSpell * s): ISpellMechanics(s){};
|
|
|
|
|
2014-11-13 06:34:20 +02:00
|
|
|
std::vector<BattleHex> rangeInHexes(BattleHex centralHex, ui8 schoolLvl, ui8 side, bool *outDroppedHexes = nullptr) const override;
|
2014-11-13 03:53:25 +02:00
|
|
|
std::set<const CStack *> getAffectedStacks(SpellTargetingContext & ctx) const override;
|
|
|
|
|
|
|
|
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const CGHeroInstance * caster, const CStack * obj) const override;
|
|
|
|
|
2014-11-23 13:10:29 +02:00
|
|
|
bool adventureCast(const SpellCastContext & context) const override;
|
|
|
|
bool battleCast(const SpellCastContext & context) const override;
|
2014-11-12 10:36:34 +02:00
|
|
|
};
|
|
|
|
|
2014-11-13 06:34:20 +02:00
|
|
|
class WallMechanics: public DefaultSpellMechanics
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
WallMechanics(CSpell * s): DefaultSpellMechanics(s){};
|
|
|
|
std::vector<BattleHex> rangeInHexes(BattleHex centralHex, ui8 schoolLvl, ui8 side, bool *outDroppedHexes = nullptr) const override;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-11-13 04:40:52 +02:00
|
|
|
class ChainLightningMechanics: public DefaultSpellMechanics
|
2014-11-12 10:36:34 +02:00
|
|
|
{
|
|
|
|
public:
|
2014-11-13 04:40:52 +02:00
|
|
|
ChainLightningMechanics(CSpell * s): DefaultSpellMechanics(s){};
|
2014-11-13 11:22:20 +02:00
|
|
|
std::set<const CStack *> getAffectedStacks(SpellTargetingContext & ctx) const override;
|
2014-11-13 03:53:25 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class CloneMechanics: public DefaultSpellMechanics
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CloneMechanics(CSpell * s): DefaultSpellMechanics(s){};
|
|
|
|
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const CGHeroInstance * caster, const CStack * obj) const override;
|
2014-11-12 10:36:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class DispellHelpfulMechanics: public DefaultSpellMechanics
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DispellHelpfulMechanics(CSpell * s): DefaultSpellMechanics(s){};
|
2014-11-13 03:53:25 +02:00
|
|
|
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const CGHeroInstance * caster, const CStack * obj) const override;
|
2014-11-12 10:36:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class HypnotizeMechanics: public DefaultSpellMechanics
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
HypnotizeMechanics(CSpell * s): DefaultSpellMechanics(s){};
|
2014-11-13 03:53:25 +02:00
|
|
|
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const CGHeroInstance * caster, const CStack * obj) const override;
|
|
|
|
};
|
2014-11-12 10:36:34 +02:00
|
|
|
|
|
|
|
///all rising spells
|
|
|
|
class RisingSpellMechanics: public DefaultSpellMechanics
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RisingSpellMechanics(CSpell * s): DefaultSpellMechanics(s){};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
///all rising spells but SACRIFICE
|
|
|
|
class SpecialRisingSpellMechanics: public RisingSpellMechanics
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SpecialRisingSpellMechanics(CSpell * s): RisingSpellMechanics(s){};
|
2014-11-13 03:53:25 +02:00
|
|
|
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const CGHeroInstance * caster, const CStack * obj) const override;
|
2014-11-12 10:36:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class SacrificeMechanics: public RisingSpellMechanics
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SacrificeMechanics(CSpell * s): RisingSpellMechanics(s){};
|
|
|
|
};
|