ISpellMechanics.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * ISpellMechanics.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "ISpellMechanics.h"
  12. #include "CDefaultSpellMechanics.h"
  13. #include "AdventureSpellMechanics.h"
  14. #include "BattleSpellMechanics.h"
  15. #include "CreatureSpellMechanics.h"
  16. BattleSpellCastParameters::BattleSpellCastParameters(const BattleInfo* cb)
  17. : spellLvl(0), destination(BattleHex::INVALID), casterSide(0),casterColor(PlayerColor::CANNOT_DETERMINE),casterHero(nullptr), secHero(nullptr),
  18. usedSpellPower(0),mode(ECastingMode::HERO_CASTING), casterStack(nullptr), selectedStack(nullptr), cb(cb)
  19. {
  20. }
  21. ///ISpellMechanics
  22. ISpellMechanics::ISpellMechanics(CSpell * s):
  23. owner(s)
  24. {
  25. }
  26. ISpellMechanics * ISpellMechanics::createMechanics(CSpell * s)
  27. {
  28. switch (s->id)
  29. {
  30. case SpellID::ANTI_MAGIC:
  31. return new AntimagicMechanics(s);
  32. case SpellID::ACID_BREATH_DAMAGE:
  33. return new AcidBreathDamageMechanics(s);
  34. case SpellID::CHAIN_LIGHTNING:
  35. return new ChainLightningMechanics(s);
  36. case SpellID::CLONE:
  37. return new CloneMechanics(s);
  38. case SpellID::CURE:
  39. return new CureMechanics(s);
  40. case SpellID::DEATH_STARE:
  41. return new DeathStareMechanics(s);
  42. case SpellID::DISPEL:
  43. return new DispellMechanics(s);
  44. case SpellID::DISPEL_HELPFUL_SPELLS:
  45. return new DispellHelpfulMechanics(s);
  46. case SpellID::EARTHQUAKE:
  47. return new EarthquakeMechanics(s);
  48. case SpellID::FIRE_WALL:
  49. case SpellID::FORCE_FIELD:
  50. return new WallMechanics(s);
  51. case SpellID::HYPNOTIZE:
  52. return new HypnotizeMechanics(s);
  53. case SpellID::LAND_MINE:
  54. case SpellID::QUICKSAND:
  55. return new ObstacleMechanics(s);
  56. case SpellID::REMOVE_OBSTACLE:
  57. return new RemoveObstacleMechanics(s);
  58. case SpellID::SACRIFICE:
  59. return new SacrificeMechanics(s);
  60. case SpellID::SUMMON_FIRE_ELEMENTAL:
  61. return new SummonMechanics(s, CreatureID::FIRE_ELEMENTAL);
  62. case SpellID::SUMMON_EARTH_ELEMENTAL:
  63. return new SummonMechanics(s, CreatureID::EARTH_ELEMENTAL);
  64. case SpellID::SUMMON_WATER_ELEMENTAL:
  65. return new SummonMechanics(s, CreatureID::WATER_ELEMENTAL);
  66. case SpellID::SUMMON_AIR_ELEMENTAL:
  67. return new SummonMechanics(s, CreatureID::AIR_ELEMENTAL);
  68. case SpellID::TELEPORT:
  69. return new TeleportMechanics(s);
  70. case SpellID::SUMMON_BOAT:
  71. return new SummonBoatMechanics(s);
  72. case SpellID::SCUTTLE_BOAT:
  73. return new ScuttleBoatMechanics(s);
  74. case SpellID::DIMENSION_DOOR:
  75. return new DimensionDoorMechanics(s);
  76. case SpellID::FLY:
  77. case SpellID::WATER_WALK:
  78. case SpellID::VISIONS:
  79. case SpellID::DISGUISE:
  80. return new DefaultSpellMechanics(s); //implemented using bonus system
  81. case SpellID::TOWN_PORTAL:
  82. return new TownPortalMechanics(s);
  83. case SpellID::VIEW_EARTH:
  84. return new ViewEarthMechanics(s);
  85. case SpellID::VIEW_AIR:
  86. return new ViewAirMechanics(s);
  87. default:
  88. if(s->isRisingSpell())
  89. return new SpecialRisingSpellMechanics(s);
  90. else
  91. return new DefaultSpellMechanics(s);
  92. }
  93. }