BuyArmy.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * BuyArmy.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 "BuyArmy.h"
  12. #include "../FuzzyHelper.h"
  13. #include "../AIhelper.h"
  14. #include "../../../lib/mapObjects/CGTownInstance.h"
  15. using namespace Goals;
  16. bool BuyArmy::operator==(const BuyArmy & other) const
  17. {
  18. return town == other.town && objid == other.objid;
  19. }
  20. bool BuyArmy::fulfillsMe(TSubgoal goal)
  21. {
  22. //if (hero && hero != goal->hero)
  23. // return false;
  24. return town == goal->town && goal->value >= value; //can always buy more army
  25. }
  26. TSubgoal BuyArmy::whatToDoToAchieve()
  27. {
  28. //TODO: calculate the actual cost of units instead
  29. TResources price;
  30. price[EGameResID::GOLD] = static_cast<int>(value * 0.4f); //some approximate value
  31. return ai->ah->whatToDo(price, iAmElementar()); //buy right now or gather resources
  32. }
  33. std::string BuyArmy::completeMessage() const
  34. {
  35. return boost::format("Bought army of value %d in town of %s") % value, town->getNameTranslated();
  36. }