Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
DJWarmonger
authored and
DJWarmonger
committed
Jul 26, 2018
1 parent
75f8c8b
commit 273802c
Showing
28 changed files
with
1,889 additions
and
433 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* AIhelper.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 | ||
* | ||
*/ | ||
#include "StdInc.h" | ||
|
||
#include "AIhelper.h" | ||
#include "ResourceManager.h" | ||
|
||
boost::thread_specific_ptr<AIhelper> ah; | ||
|
||
AIhelper::AIhelper() | ||
{ | ||
resourceManager.reset(new ResourceManager); | ||
} | ||
|
||
AIhelper::~AIhelper() | ||
{ | ||
} | ||
|
||
bool AIhelper::notifyGoalCompleted(Goals::TSubgoal goal) | ||
{ | ||
return resourceManager->notifyGoalCompleted(goal); | ||
} | ||
|
||
void AIhelper::setCB(CPlayerSpecificInfoCallback * CB) | ||
{ | ||
resourceManager->setCB(CB); | ||
} | ||
|
||
void AIhelper::setAI(VCAI * AI) | ||
{ | ||
resourceManager->setAI(AI); | ||
} | ||
|
||
Goals::TSubgoal AIhelper::whatToDo(TResources & res, Goals::TSubgoal goal) | ||
{ | ||
return resourceManager->whatToDo(res, goal); | ||
} | ||
|
||
Goals::TSubgoal AIhelper::whatToDo() const | ||
{ | ||
return resourceManager->whatToDo(); | ||
} | ||
|
||
bool AIhelper::hasTasksLeft() const | ||
{ | ||
return resourceManager->hasTasksLeft(); | ||
} | ||
|
||
bool AIhelper::canAfford(const TResources & cost) const | ||
{ | ||
return resourceManager->canAfford(cost); | ||
} | ||
|
||
TResources AIhelper::reservedResources() const | ||
{ | ||
return resourceManager->reservedResources(); | ||
} | ||
|
||
TResources AIhelper::freeResources() const | ||
{ | ||
return resourceManager->freeResources(); | ||
} | ||
|
||
TResource AIhelper::freeGold() const | ||
{ | ||
return resourceManager->freeGold(); | ||
} | ||
|
||
TResources AIhelper::allResources() const | ||
{ | ||
return resourceManager->allResources(); | ||
} | ||
|
||
TResource AIhelper::allGold() const | ||
{ | ||
return resourceManager->allGold(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* AIhelper.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 | ||
|
||
/* | ||
!!! Note: Include THIS file at the end of include list to avoid "undefined base class" error | ||
*/ | ||
|
||
#include "ResourceManager.h" | ||
|
||
class ResourceManager; | ||
|
||
//indirection interface for various modules | ||
class DLL_EXPORT AIhelper : public IResourceManager | ||
{ | ||
friend class VCAI; | ||
friend struct SetGlobalState; //mess? | ||
|
||
//members are thread_specific. AIhelper is global | ||
std::shared_ptr<ResourceManager> resourceManager; | ||
std::shared_ptr<VCAI> ai; | ||
public: | ||
AIhelper(); | ||
~AIhelper(); | ||
|
||
//TODO: consider common interface with Resource Manager? | ||
bool canAfford(const TResources & cost) const; | ||
TResources reservedResources() const override; | ||
TResources freeResources() const override; | ||
TResource freeGold() const override; | ||
TResources allResources() const override; | ||
TResource allGold() const override; | ||
|
||
Goals::TSubgoal whatToDo(TResources &res, Goals::TSubgoal goal) override; | ||
Goals::TSubgoal whatToDo() const override; //peek highest-priority goal | ||
bool hasTasksLeft() const override; | ||
|
||
private: | ||
bool notifyGoalCompleted(Goals::TSubgoal goal); | ||
|
||
void setCB(CPlayerSpecificInfoCallback * CB) override; | ||
void setAI(VCAI * AI) override; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.