1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00
vcmi/AI/VCAI/Goals/BuyArmy.cpp

46 lines
1.2 KiB
C++
Raw Normal View History

2018-12-01 10:30:37 +02:00
/*
* BuyArmy.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#include "StdInc.h"
#include "BuyArmy.h"
#include "../FuzzyHelper.h"
#include "../AIhelper.h"
2019-04-07 06:31:47 +02:00
#include "../../../lib/mapObjects/CGTownInstance.h"
2018-12-01 10:30:37 +02:00
extern boost::thread_specific_ptr<CCallback> cb;
extern boost::thread_specific_ptr<VCAI> ai;
extern FuzzyHelper * fh;
using namespace Goals;
bool BuyArmy::operator==(const BuyArmy & other) const
{
return town == other.town && objid == other.objid;
}
bool BuyArmy::fulfillsMe(TSubgoal goal)
{
//if (hero && hero != goal->hero)
// return false;
return town == goal->town && goal->value >= value; //can always buy more army
}
TSubgoal BuyArmy::whatToDoToAchieve()
{
//TODO: calculate the actual cost of units instead
TResources price;
price[Res::GOLD] = static_cast<int>(value * 0.4f); //some approximate value
2018-12-01 10:30:37 +02:00
return ai->ah->whatToDo(price, iAmElementar()); //buy right now or gather resources
}
std::string BuyArmy::completeMessage() const
{
return boost::format("Bought army of value %d in town of %s") % value, town->name;
}