Effect.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Effect.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 "Effect.h"
  12. #include "Registry.h"
  13. #include "../../serializer/JsonSerializeFormat.h"
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. namespace spells
  16. {
  17. namespace effects
  18. {
  19. bool Effect::applicable(Problem & problem, const Mechanics * m) const
  20. {
  21. return true;
  22. }
  23. bool Effect::applicable(Problem & problem, const Mechanics * m, const EffectTarget & target) const
  24. {
  25. return true;
  26. }
  27. void Effect::serializeJson(JsonSerializeFormat & handler)
  28. {
  29. handler.serializeBool("indirect", indirect, false);
  30. handler.serializeBool("optional", optional, false);
  31. serializeJsonEffect(handler);
  32. }
  33. std::shared_ptr<Effect> Effect::create(const Registry * registry, const std::string & type)
  34. {
  35. const auto *factory = registry->find(type);
  36. if(factory)
  37. {
  38. std::shared_ptr<Effect> ret;
  39. ret.reset(factory->create());
  40. return ret;
  41. }
  42. else
  43. {
  44. logGlobal->error("Unknown effect type '%s'", type);
  45. return std::shared_ptr<Effect>();
  46. }
  47. }
  48. }
  49. }
  50. VCMI_LIB_NAMESPACE_END