2014-11-12 10:36:34 +02:00
|
|
|
/*
|
2015-02-02 11:22:19 +02:00
|
|
|
* ISpellMechanics.h, part of VCMI engine
|
2014-11-12 10:36:34 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
2015-02-26 19:59:18 +02:00
|
|
|
|
2014-11-12 10:36:34 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "CSpellHandler.h"
|
2015-02-02 10:25:26 +02:00
|
|
|
#include "../BattleHex.h"
|
2015-03-09 21:07:28 +02:00
|
|
|
#include "../BattleState.h"
|
|
|
|
#include "../NetPacks.h"
|
2014-11-12 10:36:34 +02:00
|
|
|
|
2015-09-16 09:50:33 +02:00
|
|
|
///callback to be provided by server
|
|
|
|
class DLL_LINKAGE SpellCastEnvironment
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~SpellCastEnvironment(){};
|
|
|
|
virtual void sendAndApply(CPackForClient * info) const = 0;
|
|
|
|
|
|
|
|
virtual CRandomGenerator & getRandomGenerator() const = 0;
|
|
|
|
virtual void complain(const std::string & problem) const = 0;
|
|
|
|
|
|
|
|
virtual const CMap * getMap() const = 0;
|
|
|
|
virtual const CGameInfoCallback * getCb() const = 0;
|
|
|
|
|
|
|
|
virtual bool moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, PlayerColor asker = PlayerColor::NEUTRAL) const =0; //TODO: remove
|
|
|
|
};
|
|
|
|
|
|
|
|
///helper struct
|
|
|
|
struct DLL_LINKAGE BattleSpellCastParameters
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BattleSpellCastParameters(const BattleInfo * cb);
|
2015-09-17 04:47:32 +02:00
|
|
|
///spell school level , 0-use default
|
2015-09-16 09:50:33 +02:00
|
|
|
int spellLvl;
|
|
|
|
BattleHex destination;
|
|
|
|
ui8 casterSide;
|
|
|
|
PlayerColor casterColor;
|
|
|
|
const CGHeroInstance * casterHero; //deprecated
|
|
|
|
ECastingMode::ECastingMode mode;
|
|
|
|
const CStack * casterStack;
|
|
|
|
const CStack * selectedStack;
|
|
|
|
const BattleInfo * cb;
|
2015-09-17 04:47:32 +02:00
|
|
|
|
|
|
|
///spell school level to use for effects, 0-use spellLvl
|
|
|
|
int effectLevel;
|
|
|
|
///actual spell-power affecting effect values, 0-use default
|
|
|
|
int effectPower;
|
|
|
|
///actual spell-power affecting effect duration, 0-use default
|
|
|
|
int enchantPower;
|
|
|
|
///for Archangel-like casting, 0-use default
|
|
|
|
int effectValue;
|
2015-09-16 09:50:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct DLL_LINKAGE AdventureSpellCastParameters
|
|
|
|
{
|
|
|
|
const CGHeroInstance * caster;
|
|
|
|
int3 pos;
|
|
|
|
};
|
|
|
|
|
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
|
|
|
{
|
2015-02-26 19:59:18 +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;
|
2015-02-26 19:59:18 +02:00
|
|
|
|
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
|
|
|
{};
|
2015-02-26 19:59:18 +02:00
|
|
|
|
2014-11-13 06:34:20 +02:00
|
|
|
};
|
|
|
|
public:
|
|
|
|
ISpellMechanics(CSpell * s);
|
2015-02-26 19:59:18 +02:00
|
|
|
virtual ~ISpellMechanics(){};
|
|
|
|
|
|
|
|
virtual std::vector<BattleHex> rangeInHexes(BattleHex centralHex, ui8 schoolLvl, ui8 side, bool * outDroppedHexes = nullptr) const = 0;
|
2014-11-13 06:34:20 +02:00
|
|
|
virtual std::set<const CStack *> getAffectedStacks(SpellTargetingContext & ctx) const = 0;
|
2015-03-18 15:39:07 +02:00
|
|
|
|
2015-03-18 16:48:32 +02:00
|
|
|
virtual ESpellCastProblem::ESpellCastProblem canBeCasted(const CBattleInfoCallback * cb, PlayerColor player) const = 0;
|
2015-03-18 15:39:07 +02:00
|
|
|
|
2014-11-13 06:34:20 +02:00
|
|
|
virtual ESpellCastProblem::ESpellCastProblem isImmuneByStack(const CGHeroInstance * caster, const CStack * obj) const = 0;
|
2015-03-18 15:39:07 +02:00
|
|
|
|
2015-03-09 21:07:28 +02:00
|
|
|
virtual void applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const = 0;
|
2015-02-26 19:59:18 +02:00
|
|
|
virtual bool adventureCast(const SpellCastEnvironment * env, AdventureSpellCastParameters & parameters) const = 0;
|
|
|
|
virtual void battleCast(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters) const = 0;
|
|
|
|
|
2015-03-22 12:27:11 +02:00
|
|
|
virtual void battleLogSingleTarget(std::vector<std::string> & logLines, const BattleSpellCast * packet,
|
|
|
|
const std::string & casterName, const CStack * attackedStack, bool & displayDamage) const = 0;
|
|
|
|
|
2014-11-25 13:58:42 +02:00
|
|
|
static ISpellMechanics * createMechanics(CSpell * s);
|
2014-11-13 06:34:20 +02:00
|
|
|
protected:
|
2015-02-26 19:59:18 +02:00
|
|
|
CSpell * owner;
|
2014-11-13 06:34:20 +02:00
|
|
|
};
|