BWAPI  4.1.2
An API for interacting with Starcraft: Broodwar (1.16.1)
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules
Public Member Functions | List of all members
BWAPI::ForceInterface Class Referenceabstract
Inheritance diagram for BWAPI::ForceInterface:
Inheritance graph

Public Member Functions

virtual int getID () const =0
 
virtual std::string getName () const =0
 
virtual Playerset getPlayers () const =0
 

Detailed Description

The Force class is used to get information about each force in a match.

Normally this is considered a team.

Note
It is not called a team because players on the same force do not necessarily need to be allied at the beginning of a match.

Member Function Documentation

virtual int BWAPI::ForceInterface::getID ( ) const
pure virtual

Retrieves the unique ID that represents this Force.

Returns
An integer containing the ID for the Force.
virtual std::string BWAPI::ForceInterface::getName ( ) const
pure virtual

Retrieves the name of the Force.

Returns
A std::string object containing the name of the force.

Example usage:

BWAPI::Force myForce = BWAPI::Broodwar->self()->getForce();
if ( myForce->getName() == "Observers" )
BWAPI::Broodwar << "Looks like we're observing a match." << std::endl;
Note
Don't forget to use std::string::c_str() when passing this parameter to Game::sendText and other variadic functions.
virtual Playerset BWAPI::ForceInterface::getPlayers ( ) const
pure virtual

Retrieves the set of players that belong to this Force.

Returns
A Playerset object containing the players that are part of this Force.

Example usage:

// Get the enemy force, but make sure we have an enemy
BWAPI::Force myEnemyForce = BWAPI::Broodwar->enemy() ? BWAPI::Broodwar->enemy()->getForce() : nullptr;
if ( myEnemyForce != nullptr )
{
Broodwar << "The allies of my enemy are..." << std::endl;
for ( auto i = myEnemyForce.begin(); i != myEnemyForce.end(); ++i )
Broodwar << " - " << i->getName() << std::endl;
}