BWAPI
Public Member Functions | Private Member Functions | Private Attributes
Condition Struct Reference

#include <Condition.h>

Collaboration diagram for Condition:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Condition ()
 Condition (ConditionTest type, bool expectedValue=true)
 Condition (ConditionTest type, int extraValue)
 Condition (ConditionTest type, bool expectedValue, int extraValue)
 Condition (ConditionTest type, double extraValue)
 Condition (ConditionTest type, bool expectedValue, double extraValue)
 Condition (ConditionTest type, BWAPI::UnitType unitType, int count=1)
 Condition (ConditionTest type, BWAPI::TechType tech)
 Condition (ConditionTest type, BWAPI::UpgradeType upgrade, int level=1)
 Condition (ConditionTest type, std::string string)
 Condition (const Condition &other)
Conditionoperator= (const Condition &other)
bool evauluate () const
Condition operator&& (const Condition &other) const
Condition operator|| (const Condition &other) const

Private Member Functions

bool passesValue () const
 Condition (const Condition &left, OperatorType::type opType, const Condition &right)

Private Attributes

ConditionTest mType
OperatorType mOperatorType
boost::scoped_ptr< ConditionmLCondition
boost::scoped_ptr< ConditionmRCondition
bool mNeededValue
int mExtraInt
double mExtraDouble
BWAPI::UnitType mUnitType
BWAPI::TechType mTech
BWAPI::UpgradeType mUpgrade
std::string mString

Detailed Description

Definition at line 46 of file Condition.h.


Constructor & Destructor Documentation

Condition::Condition ( ) [inline]

Definition at line 49 of file Condition.h.

Referenced by operator&&(), and operator||().

Here is the caller graph for this function:

Condition::Condition ( ConditionTest  type,
bool  expectedValue = true 
)
Condition::Condition ( ConditionTest  type,
int  extraValue 
)
Condition::Condition ( ConditionTest  type,
bool  expectedValue,
int  extraValue 
)
Condition::Condition ( ConditionTest  type,
double  extraValue 
)
Condition::Condition ( ConditionTest  type,
bool  expectedValue,
double  extraValue 
)
Condition::Condition ( ConditionTest  type,
BWAPI::UnitType  unitType,
int  count = 1 
)
Condition::Condition ( ConditionTest  type,
BWAPI::UpgradeType  upgrade,
int  level = 1 
)
Condition::Condition ( ConditionTest  type,
std::string  string 
)
Condition::Condition ( const Condition other) [inline]

Definition at line 60 of file Condition.h.

                : mType(other.mType)
                , mOperatorType(other.mOperatorType)
                , mLCondition(other.mLCondition ? new Condition(*other.mLCondition) : NULL)
                , mRCondition(other.mRCondition ? new Condition(*other.mRCondition) : NULL)
                , mNeededValue(other.mNeededValue)
                , mExtraInt(other.mExtraInt)
                , mExtraDouble(other.mExtraDouble)
                , mUnitType(other.mUnitType)
                , mTech(other.mTech)
                , mUpgrade(other.mUpgrade)
                , mString(other.mString)
        {
        }
Condition::Condition ( const Condition left,
OperatorType::type  opType,
const Condition right 
) [inline, private]

Member Function Documentation

bool Condition::evauluate ( ) const [inline]

Definition at line 93 of file Condition.h.

References OperatorTypeDef::And, mLCondition, mOperatorType, mRCondition, OperatorTypeDef::None, OperatorTypeDef::Or, and passesValue().

Referenced by UnitToProduce::canBuildFactory(), UnitToProduce::canBuildUnit(), and BuildOrder::isStartBuild().

        {
                if(mOperatorType == OperatorType::None)
                        return passesValue();
                else if(mOperatorType == OperatorType::And)
                        return mLCondition->evauluate() && mRCondition->evauluate();
                else if(mOperatorType == OperatorType::Or)
                        return mLCondition->evauluate() || mRCondition->evauluate();

                return false;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

Condition Condition::operator&& ( const Condition other) const [inline]

Definition at line 105 of file Condition.h.

References OperatorTypeDef::And, and Condition().

        {
                return Condition(*this, OperatorType::And, other);
        }

Here is the call graph for this function:

Condition& Condition::operator= ( const Condition other) [inline]

Definition at line 75 of file Condition.h.

References mExtraDouble, mExtraInt, mLCondition, mNeededValue, mOperatorType, mRCondition, mString, mTech, mType, mUnitType, and mUpgrade.

        {
                mType = other.mType;
                mOperatorType = other.mOperatorType;
                mNeededValue = other.mNeededValue;
                mExtraInt = other.mExtraInt;
                mExtraDouble = other.mExtraDouble;
                mUnitType = other.mUnitType;
                mTech = other.mTech;
                mUpgrade = other.mUpgrade;
                mString = other.mString;

                mLCondition.reset(other.mLCondition ? new Condition(*other.mLCondition) : NULL);
                mRCondition.reset(other.mRCondition ? new Condition(*other.mRCondition) : NULL);

                return *this;
        }
Condition Condition::operator|| ( const Condition other) const [inline]

Definition at line 110 of file Condition.h.

References Condition(), and OperatorTypeDef::Or.

        {
                return Condition(*this, OperatorType::Or, other);
        }

Here is the call graph for this function:

bool Condition::passesValue ( ) const [private]

Definition at line 144 of file Condition.cpp.

References BWAPI::Broodwar, ConditionTestDef::canForgeExpand, BWAPI::Player::deadUnitCount(), ConditionTestDef::enemyDoesntHasUnitLessThan, ConditionTestDef::enemyHasResearched, ConditionTestDef::enemyUnitCountGreaterEqualThan, BWAPI::Game::getStartLocations(), BWAPI::Player::getUpgradeLevel(), BWAPI::Player::hasResearched(), Singleton< T >::Instance(), ConditionTestDef::isEnemyProtoss, ConditionTestDef::isEnemyTerran, ConditionTestDef::isEnemyZerg, ConditionTestDef::isResearched, ConditionTestDef::isResearching, BWAPI::Player::isResearching(), ConditionTestDef::isUpgraded, ConditionTestDef::isUpgrading, BWAPI::Player::isUpgrading(), MapHelper::mapIs(), ConditionTestDef::mapIs, ConditionTestDef::mapSize, mExtraInt, ConditionTestDef::minDistanceBetweenMainsGreaterThan, ConditionTestDef::minDistanceBetweenMainsLessThan, mNeededValue, mString, mTech, mType, mUnitType, mUpgrade, ConditionTestDef::myPlannedUnitTotalGreaterEqualThan, ConditionTestDef::myPlannedUnitTotalLessThan, ConditionTestDef::myUnitTotalBuildCountGreaterEqualThan, ConditionTestDef::myUnitTotalBuildCountLessThan, ConditionTestDef::None, ConditionTestDef::numberOfEnemies, BWAPI::Races::Protoss, BWAPI::Game::self(), BWAPI::Races::Terran, SafeEnum< def, inner >::underlying(), and BWAPI::Races::Zerg.

Referenced by evauluate().

{
        switch(mType.underlying())
        {
        case ConditionTest::myUnitTotalBuildCountGreaterEqualThan:
                return BWAPI::Broodwar->self()->deadUnitCount(mUnitType) + MacroManager::Instance().getPlannedTotal(mUnitType) >= mExtraInt;
        case ConditionTest::myUnitTotalBuildCountLessThan:
                return BWAPI::Broodwar->self()->deadUnitCount(mUnitType) + MacroManager::Instance().getPlannedTotal(mUnitType) < mExtraInt;
        case ConditionTest::enemyUnitCountGreaterEqualThan:
                return PlayerTracker::Instance().enemyUnitCount(mUnitType) >= mExtraInt;
        case ConditionTest::enemyDoesntHasUnitLessThan:
                return PlayerTracker::Instance().enemyUnitCount(mUnitType) < mExtraInt;
        case ConditionTest::minDistanceBetweenMainsLessThan:
                //return MapInformation::Instance().minMainDistance() < mExtraFloat;
        case ConditionTest::minDistanceBetweenMainsGreaterThan:
                //return MapInformation::Instance().minMainDistance() > mExtraFloat;
        case ConditionTest::None:
                return mNeededValue;
        case ConditionTest::isEnemyProtoss:
                return PlayerTracker::Instance().isEnemyRace(BWAPI::Races::Protoss) == mNeededValue;
        case ConditionTest::isEnemyZerg:
                return PlayerTracker::Instance().isEnemyRace(BWAPI::Races::Zerg) == mNeededValue;
        case ConditionTest::isEnemyTerran:
                return PlayerTracker::Instance().isEnemyRace(BWAPI::Races::Terran) == mNeededValue;
        case ConditionTest::enemyHasResearched:
                return PlayerTracker::Instance().enemyHasReseached(mTech);
        case ConditionTest::mapSize:
                return BWAPI::Broodwar->getStartLocations().size() == mExtraInt;
        case ConditionTest::numberOfEnemies:
                return PlayerTracker::Instance().getEnemies().size() == mExtraInt;
        case ConditionTest::canForgeExpand:
                return WallTracker::Instance().canForgeExpand();
        case ConditionTest::myPlannedUnitTotalGreaterEqualThan:
                return MacroManager::Instance().getPlannedTotal(mUnitType) >= mExtraInt;
        case ConditionTest::myPlannedUnitTotalLessThan:
                return MacroManager::Instance().getPlannedTotal(mUnitType) < mExtraInt;
        case ConditionTest::mapIs:
                return MapHelper::mapIs(mString);
        case ConditionTest::isResearching:
                return BWAPI::Broodwar->self()->isResearching(mTech) || BWAPI::Broodwar->self()->hasResearched(mTech);
        case ConditionTest::isResearched:
                return BWAPI::Broodwar->self()->hasResearched(mTech);
        case ConditionTest::isUpgrading:
                return BWAPI::Broodwar->self()->isUpgrading(mUpgrade) && (mExtraInt == 1 || BWAPI::Broodwar->self()->getUpgradeLevel(mUpgrade) == mExtraInt-1);
        case ConditionTest::isUpgraded:
                return BWAPI::Broodwar->self()->getUpgradeLevel(mUpgrade) == mExtraInt;
        }
        return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

double Condition::mExtraDouble [private]

Definition at line 124 of file Condition.h.

Referenced by operator=().

int Condition::mExtraInt [private]

Definition at line 123 of file Condition.h.

Referenced by operator=(), and passesValue().

boost::scoped_ptr<Condition> Condition::mLCondition [private]

Definition at line 119 of file Condition.h.

Referenced by evauluate(), and operator=().

bool Condition::mNeededValue [private]

Definition at line 122 of file Condition.h.

Referenced by operator=(), and passesValue().

Definition at line 118 of file Condition.h.

Referenced by evauluate(), and operator=().

boost::scoped_ptr<Condition> Condition::mRCondition [private]

Definition at line 120 of file Condition.h.

Referenced by evauluate(), and operator=().

std::string Condition::mString [private]

Definition at line 129 of file Condition.h.

Referenced by operator=(), and passesValue().

Definition at line 127 of file Condition.h.

Referenced by operator=(), and passesValue().

Definition at line 116 of file Condition.h.

Referenced by operator=(), and passesValue().

Definition at line 126 of file Condition.h.

Referenced by operator=(), and passesValue().

Definition at line 128 of file Condition.h.

Referenced by operator=(), and passesValue().


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