StackWithBonuses.cpp 919 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * StackWithBonuses.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 "StackWithBonuses.h"
  12. #include "../../lib/BattleState.h"
  13. const TBonusListPtr StackWithBonuses::getAllBonuses(const CSelector &selector, const CSelector &limit,
  14. const CBonusSystemNode *root /*= nullptr*/, const std::string &cachingStr /*= ""*/) const
  15. {
  16. TBonusListPtr ret = std::make_shared<BonusList>();
  17. const TBonusListPtr originalList = stack->getAllBonuses(selector, limit, root, cachingStr);
  18. range::copy(*originalList, std::back_inserter(*ret));
  19. for(auto &bonus : bonusesToAdd)
  20. {
  21. auto b = std::make_shared<Bonus>(bonus);
  22. if(selector(b.get()) && (!limit || !limit(b.get())))
  23. ret->push_back(b);
  24. }
  25. //TODO limiters?
  26. return ret;
  27. }