|
BWAPI
|
#include <SupplyManager.h>


Public Member Functions | |
| SupplyManager () | |
| virtual void | update () |
| virtual void | draw () |
| virtual const std::string & | getName () const |
Private Member Functions | |
| int | plannedSupply () const |
Private Attributes | |
| int | depotCount |
| int | plannedDepotCount |
Definition at line 10 of file SupplyManager.h.
Definition at line 15 of file SupplyManager.cpp.
: depotCount(0) , plannedDepotCount(0) { }
| void SupplyManager::draw | ( | ) | [virtual] |
Reimplemented from Manager.
Definition at line 52 of file SupplyManager.cpp.
References BWAPI::Broodwar, and plannedSupply().
{
Broodwar->drawTextScreen(2, 10, "\x1E SM : %d planned", plannedSupply()/2);
Manager::draw();
}
| virtual const std::string& SupplyManager::getName | ( | ) | const [inline, virtual] |
Reimplemented from Manager.
Definition at line 25 of file SupplyManager.h.
{
static const std::string name("SupplyMgr");
return name;
}
| int SupplyManager::plannedSupply | ( | ) | const [private] |
Definition at line 44 of file SupplyManager.cpp.
References BWAPI::Broodwar, and plannedDepotCount.
Referenced by draw(), and update().
{
// Note: supplyProvided() returns double the onscreen supply count
const int plannedSupply = plannedDepotCount * UnitTypes::Terran_Supply_Depot.supplyProvided();
const int totalSupply = Broodwar->self()->supplyTotal();
return plannedSupply + totalSupply;
}

| void SupplyManager::update | ( | ) | [virtual] |
Reimplemented from Manager.
Definition at line 20 of file SupplyManager.cpp.
References BWAPI::Broodwar, BuildManager::build(), Strategizer::buildManager, depotCount, Strategizer::instance(), plannedDepotCount, and plannedSupply().
{
/* Build supply if running low */
int currentSupply = Broodwar->self()->supplyUsed();
if (plannedSupply() - currentSupply < 12)
{
Broodwar->sendText("SM: Nearing capacity (%d/%d), Supply Depot ordered",
currentSupply, plannedSupply());
plannedDepotCount++;
Strategizer::instance().buildManager.build(UnitTypes::Terran_Supply_Depot, true);
}
/* Detect Supply Depot completion */
int completedDepots = Broodwar->self()->completedUnitCount(UnitTypes::Terran_Supply_Depot);
if (completedDepots > depotCount)
{
depotCount++;
plannedDepotCount--;
}
/* Base class updates Agents */
Manager::update();
}

int SupplyManager::depotCount [private] |
Definition at line 13 of file SupplyManager.h.
Referenced by update().
int SupplyManager::plannedDepotCount [private] |
Definition at line 14 of file SupplyManager.h.
Referenced by plannedSupply(), and update().
1.7.6.1