BWAPI
Public Member Functions | Private Member Functions | Private Attributes
SupplyManager Class Reference

#include <SupplyManager.h>

Inheritance diagram for SupplyManager:
Inheritance graph
[legend]
Collaboration diagram for SupplyManager:
Collaboration graph
[legend]

List of all members.

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

Detailed Description

Definition at line 10 of file SupplyManager.h.


Constructor & Destructor Documentation

Definition at line 15 of file SupplyManager.cpp.


Member Function Documentation

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();
}

Here is the call graph for this function:

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;
}

Here is the caller graph for this function:

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();
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 13 of file SupplyManager.h.

Referenced by update().

Definition at line 14 of file SupplyManager.h.

Referenced by plannedSupply(), and update().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines