2021-05-16 13:14:17 +02:00
|
|
|
/*
|
|
|
|
* 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"
|
2021-05-16 13:14:17 +02:00
|
|
|
#include "../../../lib/ResourceSet.h"
|
|
|
|
|
2022-09-26 20:01:07 +02:00
|
|
|
namespace NKAI
|
|
|
|
{
|
|
|
|
|
2021-05-16 13:57:29 +02:00
|
|
|
class Nullkiller;
|
2021-05-16 13:15:03 +02:00
|
|
|
|
2021-05-16 13:22:33 +02:00
|
|
|
class DLL_EXPORT BuildingInfo
|
2021-05-16 13:15:03 +02:00
|
|
|
{
|
|
|
|
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;
|
2021-05-16 13:15:03 +02:00
|
|
|
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);
|
2021-05-16 13:15:03 +02:00
|
|
|
|
|
|
|
std::string toString() const;
|
|
|
|
};
|
|
|
|
|
2021-05-16 13:22:33 +02:00
|
|
|
class DLL_EXPORT TownDevelopmentInfo
|
2021-05-16 13:15:03 +02:00
|
|
|
{
|
|
|
|
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;
|
2021-05-16 13:15:03 +02:00
|
|
|
HeroRole townRole;
|
|
|
|
bool hasSomethingToBuild;
|
|
|
|
|
2023-04-17 23:11:16 +02:00
|
|
|
TownDevelopmentInfo(const CGTownInstance * town):
|
|
|
|
town(town),
|
|
|
|
armyStrength(0),
|
|
|
|
townRole(HeroRole::SCOUT),
|
|
|
|
hasSomethingToBuild(false)
|
2021-05-16 13:15:03 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2021-05-16 13:14:17 +02:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
TResources requiredResources;
|
2021-05-16 13:15:03 +02:00
|
|
|
TResources totalDevelopmentCost;
|
|
|
|
std::vector<TownDevelopmentInfo> developmentInfos;
|
|
|
|
TResources armyCost;
|
2021-05-16 13:19:00 +02:00
|
|
|
TResources dailyIncome;
|
|
|
|
float goldPreasure;
|
2021-05-16 13:57:29 +02:00
|
|
|
Nullkiller * ai;
|
2021-05-16 13:14:17 +02:00
|
|
|
|
|
|
|
public:
|
2021-05-16 13:57:29 +02:00
|
|
|
BuildAnalyzer(Nullkiller * ai) : ai(ai) {}
|
2021-05-16 13:15:03 +02:00
|
|
|
void update();
|
|
|
|
|
|
|
|
TResources getResourcesRequiredNow() const;
|
|
|
|
TResources getTotalResourcesRequired() const;
|
|
|
|
const std::vector<TownDevelopmentInfo> & getDevelopmentInfo() const { return developmentInfos; }
|
2021-05-16 13:19:00 +02:00
|
|
|
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;
|
2021-05-16 13:15:03 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
BuildingInfo getBuildingOrPrerequisite(
|
|
|
|
const CGTownInstance* town,
|
|
|
|
BuildingID toBuild,
|
|
|
|
bool excludeDwellingDependencies = true) const;
|
|
|
|
|
|
|
|
|
|
|
|
void updateTownDwellings(TownDevelopmentInfo & developmentInfo);
|
|
|
|
void updateOtherBuildings(TownDevelopmentInfo & developmentInfo);
|
2021-05-16 13:19:00 +02:00
|
|
|
void updateDailyIncome();
|
2021-05-16 13:14:17 +02:00
|
|
|
void reset();
|
|
|
|
};
|
2022-09-26 20:01:07 +02:00
|
|
|
|
|
|
|
}
|