mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-22 22:13:35 +02:00
0fecb40039
* healing effects are too specific to be allowed for any spell * mixing heal with direct damage does not make sence * mixing heal with timed effect can be easy allowed if needed
64 lines
2.4 KiB
C++
64 lines
2.4 KiB
C++
/*
|
|
* 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){};
|
|
std::vector<const CStack *> & attackedCres;
|
|
BattleSpellCast & sc;
|
|
StacksInjured & si;
|
|
};
|
|
|
|
enum class ESpellCastResult
|
|
{
|
|
OK,
|
|
CANCEL,//cast failed but it is not an error
|
|
ERROR//internal error occurred
|
|
};
|
|
|
|
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;
|
|
|
|
ESpellCastProblem::ESpellCastProblem canBeCasted(const CBattleInfoCallback * cb, PlayerColor player) const override;
|
|
|
|
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const CGHeroInstance * caster, const CStack * obj) const override;
|
|
|
|
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;
|
|
|
|
void battleLogSingleTarget(std::vector<std::string> & logLines, const BattleSpellCast * packet,
|
|
const std::string & casterName, const CStack * attackedStack, bool & displayDamage) const override;
|
|
protected:
|
|
virtual void applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const;
|
|
|
|
virtual int calculateDuration(const CGHeroInstance * caster, int usedSpellPower) const;
|
|
int calculateEffectLevel(const BattleSpellCastParameters & parameters) const;
|
|
|
|
///actual adventure cast implementation
|
|
virtual ESpellCastResult applyAdventureEffects(const SpellCastEnvironment * env, AdventureSpellCastParameters & parameters) const;
|
|
|
|
void doDispell(BattleInfo * battle, const BattleSpellCast * packet, const CSelector & selector) const;
|
|
};
|