1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-16 10:19:47 +02:00
vcmi/lib/spells/CDefaultSpellMechanics.h

67 lines
2.6 KiB
C
Raw Normal View History

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"
class ISpellMechanics;
class BattleSpellCast;
class StacksInjured;
struct SpellCastContext
{
SpellCastContext(std::vector<const CStack *> & attackedCres, BattleSpellCast & sc, StacksInjured & si):
attackedCres(attackedCres), sc(sc), si(si)
{
};
2015-03-10 19:32:05 +02:00
std::vector<const CStack *> & attackedCres;
BattleSpellCast & sc;
StacksInjured & si;
2015-03-10 19:32:05 +02:00
};
2015-04-13 05:12:23 +02:00
enum class ESpellCastResult
{
OK,
CANCEL,//cast failed but it is not an error
ERROR//internal error occurred
};
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;
std::set<const CStack *> getAffectedStacks(SpellTargetingContext & ctx) const override;
2015-09-21 11:19:35 +02:00
ESpellCastProblem::ESpellCastProblem canBeCast(const CBattleInfoCallback * cb, PlayerColor player) const override;
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;
bool adventureCast(const SpellCastEnvironment * env, AdventureSpellCastParameters & parameters) const override final;
void battleCast(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters) const override final;
2015-03-10 19:32:05 +02:00
void battleLogSingleTarget(std::vector<std::string> & logLines, const BattleSpellCast * packet,
const std::string & casterName, const CStack * attackedStack, bool & displayDamage) 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
///actual adventure cast implementation
2015-04-13 05:12:23 +02:00
virtual ESpellCastResult applyAdventureEffects(const SpellCastEnvironment * env, AdventureSpellCastParameters & parameters) const;
2015-04-11 15:27:14 +02:00
void doDispell(BattleInfo * battle, const BattleSpellCast * packet, const CSelector & selector) const;
private:
void castMagicMirror(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters) const;
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
};