1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00
vcmi/AI/Nullkiller/Analyzers/BuildAnalyzer.h

107 lines
2.6 KiB
C
Raw Normal View History

/*
* BuildAnalyzer.h, 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
*
*/
#pragma once
2021-05-16 13:55:47 +02:00
#include "../AIUtility.h"
#include "../../../lib/ResourceSet.h"
2021-05-16 13:57:29 +02:00
class Nullkiller;
2021-05-16 13:22:33 +02:00
class DLL_EXPORT BuildingInfo
{
public:
BuildingID id;
TResources buildCost;
TResources buildCostWithPrerequisits;
int creatureGrows;
uint8_t creatureLevel;
TResources creatureCost;
CreatureID creatureID;
CreatureID baseCreatureID;
TResources dailyIncome;
uint8_t prerequisitesCount;
2021-05-16 13:57:29 +02:00
uint64_t armyStrength;
TResources armyCost;
std::string name;
bool exists = false;
bool canBuild = false;
bool notEnoughRes = false;
BuildingInfo();
2021-05-16 13:57:29 +02:00
BuildingInfo(
const CBuilding * building,
const CCreature * creature,
CreatureID baseCreature,
const CGTownInstance * town,
Nullkiller * ai);
std::string toString() const;
};
2021-05-16 13:22:33 +02:00
class DLL_EXPORT TownDevelopmentInfo
{
public:
const CGTownInstance* town;
std::vector<BuildingInfo> toBuild;
std::vector<BuildingInfo> existingDwellings;
TResources townDevelopmentCost;
TResources requiredResources;
TResources armyCost;
2021-05-16 13:57:29 +02:00
uint64_t armyStrength;
HeroRole townRole;
bool hasSomethingToBuild;
TownDevelopmentInfo(const CGTownInstance* town)
2021-05-16 13:57:29 +02:00
:town(town), armyStrength(0), toBuild(), townDevelopmentCost(), requiredResources(), townRole(HeroRole::SCOUT), hasSomethingToBuild(false)
{
}
TownDevelopmentInfo() : TownDevelopmentInfo(nullptr) {}
void addBuildingToBuild(const BuildingInfo & building);
void addExistingDwelling(const BuildingInfo & existingDwelling);
};
2021-05-16 13:22:33 +02:00
class DLL_EXPORT BuildAnalyzer
{
private:
TResources requiredResources;
TResources totalDevelopmentCost;
std::vector<TownDevelopmentInfo> developmentInfos;
TResources armyCost;
TResources dailyIncome;
float goldPreasure;
2021-05-16 13:57:29 +02:00
Nullkiller * ai;
public:
2021-05-16 13:57:29 +02:00
BuildAnalyzer(Nullkiller * ai) : ai(ai) {}
void update();
TResources getResourcesRequiredNow() const;
TResources getTotalResourcesRequired() const;
const std::vector<TownDevelopmentInfo> & getDevelopmentInfo() const { return developmentInfos; }
TResources getDailyIncome() const { return dailyIncome; }
float getGoldPreasure() const { return goldPreasure; }
2021-05-16 13:45:45 +02:00
bool hasAnyBuilding(int32_t alignment, BuildingID bid) const;
private:
BuildingInfo getBuildingOrPrerequisite(
const CGTownInstance* town,
BuildingID toBuild,
bool excludeDwellingDependencies = true) const;
void updateTownDwellings(TownDevelopmentInfo & developmentInfo);
void updateOtherBuildings(TownDevelopmentInfo & developmentInfo);
void updateDailyIncome();
void reset();
};