Propagators.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Propagators.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 "Propagators.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. const std::map<std::string, TPropagatorPtr> bonusPropagatorMap =
  14. {
  15. {"BATTLE_WIDE", std::make_shared<CPropagatorNodeType>(BonusNodeType::BATTLE_WIDE)},
  16. {"TOWN_AND_VISITOR", std::make_shared<CPropagatorNodeType>(BonusNodeType::TOWN_AND_VISITOR)},
  17. {"PLAYER", std::make_shared<CPropagatorNodeType>(BonusNodeType::PLAYER)},
  18. {"HERO", std::make_shared<CPropagatorNodeType>(BonusNodeType::HERO)},
  19. {"TOWN", std::make_shared<CPropagatorNodeType>(BonusNodeType::TOWN)},
  20. {"ARMY", std::make_shared<CPropagatorNodeType>(BonusNodeType::ARMY)},
  21. {"TEAM", std::make_shared<CPropagatorNodeType>(BonusNodeType::TEAM)},
  22. {"GLOBAL_EFFECT", std::make_shared<CPropagatorNodeType>(BonusNodeType::GLOBAL_EFFECTS)},
  23. // deprecated, for compatibility
  24. {"VISITED_TOWN_AND_VISITOR", std::make_shared<CPropagatorNodeType>(BonusNodeType::TOWN_AND_VISITOR)},
  25. {"PLAYER_PROPAGATOR", std::make_shared<CPropagatorNodeType>(BonusNodeType::PLAYER)},
  26. {"TEAM_PROPAGATOR", std::make_shared<CPropagatorNodeType>(BonusNodeType::TEAM)},
  27. };
  28. bool IPropagator::shouldBeAttached(CBonusSystemNode *dest) const
  29. {
  30. return false;
  31. }
  32. BonusNodeType IPropagator::getPropagatorType() const
  33. {
  34. return BonusNodeType::NONE;
  35. }
  36. CPropagatorNodeType::CPropagatorNodeType(BonusNodeType NodeType)
  37. : nodeType(NodeType)
  38. {
  39. }
  40. BonusNodeType CPropagatorNodeType::getPropagatorType() const
  41. {
  42. return nodeType;
  43. }
  44. bool CPropagatorNodeType::shouldBeAttached(CBonusSystemNode *dest) const
  45. {
  46. if (nodeType == dest->getNodeType())
  47. return true;
  48. if (nodeType == BonusNodeType::ARMY)
  49. return dest->getNodeType() == BonusNodeType::HERO || dest->getNodeType() == BonusNodeType::TOWN;
  50. return false;
  51. }
  52. VCMI_LIB_NAMESPACE_END