BWAPI::Force class

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

Contents

Normally this is considered a team.

Base classes

template<typename Interface, typename Data>
struct InterfaceDataWrapper<Force, ForceData>

Public functions

auto getName() const -> std::string_view
Retrieves the name of the Force.
auto getPlayers() const -> Playerset
Retrieves the set of players that belong to this Force.

Function documentation

std::string_view BWAPI::Force::getName() const

Retrieves the name of the Force.

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

Example usage:

BWAPI::Force myForce = game.self().getForce();
if ( myForce.getName() == "Observers" )
  game << "Looks like we're observing a match." << std::endl;

Playerset BWAPI::Force::getPlayers() const

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 enemyForce = game.enemy() ? game.enemy().getForce() : nullptr;
if ( enemyForce )
{
  Broodwar << "Those on the enemy force are..." << std::endl;
  for ( BWAPI::Player enemy : enemyForce )
    Broodwar << "  - " << enemy.getName() << std::endl;
}