mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-11 11:31:52 +02:00
Move mechanics factory
This commit is contained in:
parent
226b737b6b
commit
c8f1e6d1a1
@ -537,38 +537,9 @@ void CSpell::setupMechanics()
|
||||
{
|
||||
logGlobal->errorStream() << "Spell " << this->name << " mechanics already set";
|
||||
delete mechanics;
|
||||
mechanics = nullptr;
|
||||
}
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case SpellID::CLONE:
|
||||
mechanics = new CloneMechanics(this);
|
||||
break;
|
||||
case SpellID::DISPEL_HELPFUL_SPELLS:
|
||||
mechanics = new DispellHelpfulMechanics(this);
|
||||
break;
|
||||
case SpellID::SACRIFICE:
|
||||
mechanics = new SacrificeMechanics(this);
|
||||
break;
|
||||
case SpellID::CHAIN_LIGHTNING:
|
||||
mechanics = new ChainLightningMechanics(this);
|
||||
break;
|
||||
case SpellID::FIRE_WALL:
|
||||
case SpellID::FORCE_FIELD:
|
||||
mechanics = new WallMechanics(this);
|
||||
break;
|
||||
case SpellID::LAND_MINE:
|
||||
case SpellID::QUICKSAND:
|
||||
mechanics = new ObstacleMechanics(this);
|
||||
default:
|
||||
if(isRisingSpell())
|
||||
mechanics = new SpecialRisingSpellMechanics(this);
|
||||
else
|
||||
mechanics = new DefaultSpellMechanics(this);
|
||||
break;
|
||||
}
|
||||
|
||||
mechanics = ISpellMechanics::createMechanics(this);
|
||||
}
|
||||
|
||||
///CSpell::TargetInfo
|
||||
|
@ -127,6 +127,32 @@ ISpellMechanics::ISpellMechanics(CSpell * s):
|
||||
|
||||
}
|
||||
|
||||
ISpellMechanics * ISpellMechanics::createMechanics(CSpell* s)
|
||||
{
|
||||
switch (s->id)
|
||||
{
|
||||
case SpellID::CLONE:
|
||||
return new CloneMechanics(s);
|
||||
case SpellID::DISPEL_HELPFUL_SPELLS:
|
||||
return new DispellHelpfulMechanics(s);
|
||||
case SpellID::SACRIFICE:
|
||||
return new SacrificeMechanics(s);
|
||||
case SpellID::CHAIN_LIGHTNING:
|
||||
return new ChainLightningMechanics(s);
|
||||
case SpellID::FIRE_WALL:
|
||||
case SpellID::FORCE_FIELD:
|
||||
return new WallMechanics(s);
|
||||
case SpellID::LAND_MINE:
|
||||
case SpellID::QUICKSAND:
|
||||
return new ObstacleMechanics(s);
|
||||
default:
|
||||
if(s->isRisingSpell())
|
||||
return new SpecialRisingSpellMechanics(s);
|
||||
else
|
||||
return new DefaultSpellMechanics(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///DefaultSpellMechanics
|
||||
|
||||
|
@ -51,6 +51,8 @@ public:
|
||||
//virtual bool adventureCast(const SpellCastContext & context) const = 0;
|
||||
virtual bool battleCast(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters) const = 0;
|
||||
|
||||
static ISpellMechanics * createMechanics(CSpell * s);
|
||||
|
||||
protected:
|
||||
CSpell * owner;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user