remove bwapi/bwta headers, include them from user's environment

This commit is contained in:
gered 2017-04-11 22:52:34 -04:00
parent 6e8b93f32b
commit 9cefd694d6
95 changed files with 15 additions and 13386 deletions

View file

@ -1,70 +0,0 @@
#pragma once
#ifndef __BWAPI_H__
#define __BWAPI_H__
#include <BWAPI/InterfaceEvent.h>
#include <BWAPI/Interface.h>
#include <BWAPI/AIModule.h>
#include <BWAPI/Bullet.h>
#include <BWAPI/Bulletset.h>
#include <BWAPI/BulletType.h>
#include <BWAPI/Color.h>
#include <BWAPI/Constants.h>
#include <BWAPI/CoordinateType.h>
#include <BWAPI/DamageType.h>
#include <BWAPI/Error.h>
#include <BWAPI/Event.h>
#include <BWAPI/EventType.h>
#include <BWAPI/ExplosionType.h>
#include <BWAPI/Filters.h>
#include <BWAPI/Flag.h>
#include <BWAPI/Force.h>
#include <BWAPI/Forceset.h>
#include <BWAPI/Game.h>
#include <BWAPI/GameType.h>
#include <BWAPI/Input.h>
#include <BWAPI/Latency.h>
#include <BWAPI/Order.h>
#include <BWAPI/Player.h>
#include <BWAPI/Playerset.h>
#include <BWAPI/PlayerType.h>
#include <BWAPI/Position.h>
#include <BWAPI/PositionUnit.h>
#include <BWAPI/Race.h>
#include <BWAPI/Region.h>
#include <BWAPI/Regionset.h>
#include <BWAPI/TechType.h>
#include <BWAPI/TournamentAction.h>
#include <BWAPI/Type.h>
#include <BWAPI/Unit.h>
#include <BWAPI/UnitCommand.h>
#include <BWAPI/UnitCommandType.h>
#include <BWAPI/Unitset.h>
#include <BWAPI/UnitSizeType.h>
#include <BWAPI/UnitType.h>
#include <BWAPI/UpgradeType.h>
#include <BWAPI/WeaponType.h>
#include <BWAPI/WindowsTypes.h>
/// <summary>The primary namespace for the BWAPI interface.</summary> Everything that is BWAPI is
/// contained within it.
namespace BWAPI
{
/// <summary>Retrieves the revision of the BWAPILIB module currently being used.</summary>
///
/// @returns
/// An integer representing the revision number of the library.
///
/// @threadsafe
int BWAPI_getRevision();
/// <summary>Checks if the BWAPILIB module was compiled in DEBUG mode.</summary>
///
/// @retval true if this is a DEBUG build
/// @retval false if this is a RELEASE build
///
/// @threadsafe
bool BWAPI_isDebug();
}
#endif

View file

@ -1,252 +0,0 @@
#pragma once
#include <BWAPI/Position.h>
#include <BWAPI/TournamentAction.h>
#include <BWAPI/Unit.h>
#include <string>
namespace BWAPI
{
// Forward declarations
class PlayerInterface;
typedef PlayerInterface *Player;
class Color;
/// <summary>AIModule is a virtual class that is intended to be implemented or inherited by a
/// custom AI class.</summary> The Broodwar interface is guaranteed to be initialized if any of
/// these predefined interface functions are invoked by BWAPI.
///
/// @warning
/// Using BWAPI in any thread other than the thread that invokes these functions can produce
/// unexpected behaviour and possibly crash your bot. Multi-threaded AIs are possible so
/// long as all BWAPI interaction is limited to the calling thread.
///
/// @note
/// Replays are considered games and call all of the same callbacks as a standard game would.
///
/// @ingroup Interface
class AIModule
{
public:
AIModule();
virtual ~AIModule();
/// <summary>Called only once at the beginning of a game.</summary> It is intended that the
/// AI module do any data initialization in this function.
///
/// @warning
/// Using the Broodwar interface before this function is called can produce undefined
/// behaviour and crash your bot. (During static initialization of a class for example)
virtual void onStart();
/// <summary>Called once at the end of a game.</summary>
///
/// <param name="isWinner">
/// A boolean value to determine if the current player has won the match. This value will
/// be true if the current player has won, and false if either the player has lost or the
/// game is actually a replay.
/// </param>
virtual void onEnd(bool isWinner);
/// <summary>Called once for every execution of a logical frame in Broodwar.</summary>
/// Users will generally put most of their code in this function.
virtual void onFrame();
/// <summary>Called when the user attempts to send a text message.</summary> This function
/// can be used to make the bot execute text commands entered by the user for debugging
/// purposes.
///
/// <param name="text">
/// A string containing the exact text message that was sent by the user.
/// </param>
///
/// @note
/// If Flag::UserInput is disabled, then this function is not called.
virtual void onSendText(std::string text);
/// <summary>Called when the client receives a message from another Player.</summary> This
/// function can be used to retrieve information from allies in team games, or just to
/// respond to other players.
///
/// <param name="player">
/// The Player interface object representing the owner of the text message.
/// </param>
/// <param name="text">
/// The text message that the \p player sent.
/// </param>
///
/// @note
/// Messages sent by the current player will never invoke this function.
virtual void onReceiveText(Player player, std::string text);
/// <summary>Called when a Player leaves the game.</summary> All of their units are
/// automatically given to the neutral player with their colour and alliance parameters
/// preserved.
///
/// <param name="player">
/// The Player interface object representing the player that left the game.
/// </param>
virtual void onPlayerLeft(Player player);
/// <summary>Called when a @Nuke has been launched somewhere on the map.</summary>
///
/// <param name="target">
/// A Position object containing the target location of the @Nuke. If the target location
/// is not visible and Flag::CompleteMapInformation is disabled, then target will be
/// Positions::Unknown.
/// </param>
virtual void onNukeDetect(Position target);
/// <summary>Called when a Unit becomes accessible.</summary>
///
/// <param name="unit">
/// The Unit interface object representing the unit that has just become accessible.
/// </param>
///
/// @note
/// This function INCLUDES the state of Flag::CompleteMapInformation.
///
/// @see onUnitShow
virtual void onUnitDiscover(Unit unit);
/// <summary>Called when a Unit becomes inaccessible.</summary>
///
/// <param name="unit">
/// The Unit interface object representing the unit that has just become inaccessible.
/// </param>
///
/// @note
/// This function INCLUDES the state of Flag::CompleteMapInformation.
///
/// @see onUnitHide
virtual void onUnitEvade(Unit unit);
/// <summary>Called when a previously invisible unit becomes visible.</summary>
///
/// <param name="unit">
/// The Unit interface object representing the unit that has just become visible.
/// </param>
///
/// @note
/// This function EXCLUDES the state of Flag::CompleteMapInformation.
///
/// @see onUnitDiscover
virtual void onUnitShow(Unit unit);
/// <summary>Called just as a visible unit is becoming invisible.</summary>
///
/// <param name="unit">
/// The Unit interface object representing the unit that is about to go out of scope.
/// </param>
///
/// @note
/// This function EXCLUDES the state of Flag::CompleteMapInformation.
///
/// @see onUnitEvade
virtual void onUnitHide(Unit unit);
/// <summary>Called when any unit is created.</summary>
///
/// <param name="unit">
/// The Unit interface object representing the unit that has just been created.
/// </param>
///
/// @note
/// Due to the internal workings of Broodwar, this function excludes Zerg morphing and
/// the construction of structures over a @Geyser .
///
/// @see onUnitMorph
virtual void onUnitCreate(Unit unit);
/// <summary>Called when a unit is removed from the game either through death or other means.</summary>
///
/// <param name="unit">
/// Unit object representing the unit that has just been destroyed or otherwise completely
/// removed from the game.
/// </param>
///
/// @note
/// When a @Drone morphs into an @Extractor, the @Drone is removed from the game and the
/// @Geyser morphs into an @Extractor.
///
/// @note
/// If a unit is visible and destroyed, then onUnitHide is called just before this.
virtual void onUnitDestroy(Unit unit);
/// <summary>Called when a unit changes its UnitType.</summary> For example, when a @Drone
/// transforms into a @Hatchery, a @SiegeTank uses @SiegeMode, or a @Geyser receives a
/// @Refinery.
///
/// <param name="unit">
/// Unit object representing the unit that had its UnitType change.
/// </param>
///
/// @note
/// This is NOT called if the unit type changes to or from UnitTypes::Unknown.
virtual void onUnitMorph(Unit unit);
/// <summary>Called when a unit changes ownership.</summary> This occurs when the @Protoss
/// ability @MindControl is used, or if a unit changes ownership in @UseMapSettings .
///
/// <param name="unit">
/// Unit interface object pertaining to the unit that has just changed ownership.
/// </param>
virtual void onUnitRenegade(Unit unit);
/// <summary>Called when the state of the Broodwar game is saved to file.</summary>
///
/// <param name="gameName">
/// A String object containing the file name that the game was saved as.
/// </param>
virtual void onSaveGame(std::string gameName);
/// <summary>Called when the state of a unit changes from incomplete to complete.</summary>
///
/// <param name="unit">
/// The Unit object representing the Unit that has just finished training or constructing.
/// </param>
virtual void onUnitComplete(Unit unit);
};
/// <summary>TournamentModule is a virtual class that is intended to be implemented or inherited
/// by a custom Tournament class.</summary> Like AIModule, the Broodwar interface is guaranteed
/// to be initialized if any of these predefined interface functions are invoked by BWAPI.
///
/// @note
/// The TournamentModule is to be implemented by Tournament Modules ONLY. A standard AI module
/// should never implement it. The Tournament Module is invoked only if it is explicitly
/// defined in the configuration file. Tournament Modules also contain an AI Module interface
/// so that it can monitor the time an AI module spent during its calls using
/// Game::getLastEventTime.
///
/// @ingroup Interface
class TournamentModule
{
public:
TournamentModule();
virtual ~TournamentModule();
/// <summary>This function regulates the functions involving game settings that an AI module
/// is allowed to execute.</summary> For example, if the tournament forbids the enabling of
/// Flag::CompleteMapInformation, then this function can deny the request.
///
/// <param name="actionType">
/// An ActionID containing the action that the AI module is requesting.
/// </param>
///
/// <param name="parameter">
/// An optional parameter that pertains to certain action requests. For example, if
/// \p actionType is Tournament::ActionID::SendText, then \p parameter is a pointer to a
/// null-terminated character array containing the message. If \p actionType is
/// Tournament::ActionID::SetLocalSpeed, then parameter is a pointer to an integer.
/// </param>
///
/// @see BWAPI::Tournament::ActionID
virtual bool onAction(BWAPI::Tournament::ActionID actionType, void *parameter = nullptr);
/// <summary>This function is called if the current player is chosen to advertise the BWAPI
/// revision.</summary> When tournament mode is enabled, to reduce spam, only one bot sends
/// the revision message. The bot that is chosen depends on its player ID. Only one of the
/// bots can call this function during a tournament game.
virtual void onFirstAdvertisement();
};
}

View file

@ -1,58 +0,0 @@
#pragma once
#include <functional>
#include "ComparisonFilter.h"
namespace BWAPI
{
/// <summary>The BestFilter is used to compare two objects with each other.</summary> Each
/// function object compares two of the same object and returns the most desirable one.
///
/// @note: A function object should return one of the two given parameters, never nullptr. Both
/// parameters being given should never be nullptr.
template<typename _PARAM>
class BestFilter
{
private:
std::function<_PARAM(_PARAM,_PARAM)> pred;
public:
// Constructor
template <typename _T>
BestFilter(const _T &predicate) : pred(predicate)
{};
// Assignment
template <typename _T>
BestFilter<_PARAM> &operator =(const _T &other)
{
this->pred = other;
return *this;
};
// Bitwise operators
template <typename _T>
inline BestFilter<_PARAM> operator &&(const _T &other) const
{
return [=](_PARAM p1, _PARAM p2)->_PARAM{ return other( (*this)(p1, p2) ); };
};
// call
inline _PARAM operator()(const _PARAM &p1, const _PARAM &p2) const
{
return this->pred(p1, p2);
};
};
template <typename _PARAM>
BestFilter<_PARAM> Lowest(const CompareFilter<_PARAM,int> &filter)
{
return [=](_PARAM p1, _PARAM p2)->_PARAM{ return filter(p2) < filter(p1) ? p2 : p1; };
};
template <typename _PARAM>
BestFilter<_PARAM> Highest(const CompareFilter<_PARAM,int> &filter)
{
return [=](_PARAM p1, _PARAM p2)->_PARAM{ return filter(p2) > filter(p1) ? p2 : p1; };
};
}

View file

@ -1,169 +0,0 @@
#pragma once
#include <BWAPI.h>
namespace BWAPI
{
// Forward declarations
class PlayerInterface;
typedef PlayerInterface *Player;
class BulletType;
class BulletInterface;
typedef BulletInterface *Bullet;
/// <summary>An interface object representing a bullet or missile spawned from an attack.</summary>
///
/// The Bullet interface allows you to detect bullets, missiles, and other types
/// of non-melee attacks or special abilities that would normally be visible through
/// human eyes (A lurker spike or a Queen's flying parasite), allowing quicker reaction
/// to unavoidable consequences.
///
/// For example, ordering medics to restore units that are about to receive a lockdown
/// to compensate for latency and minimize its effects. You can't know entirely which unit
/// will be receiving a lockdown unless you can detect the lockdown missile using the
/// Bullet class.
///
/// Bullet objects are re-used after they are destroyed, however their ID is updated when it
/// represents a new Bullet.
///
/// If Flag::CompleteMapInformation is disabled, then a Bullet is accessible if and only if
/// it is visible. Otherwise if Flag::CompleteMapInformation is enabled, then all Bullets
/// in the game are accessible.
/// @see Game::getBullets, BulletInterface::exists
/// @ingroup Interface
class BulletInterface : public Interface<BulletInterface>
{
protected:
virtual ~BulletInterface() {};
public:
/// <summary>Retrieves a unique identifier for the current Bullet.</summary>
///
/// @returns
/// An integer value containing the identifier.
virtual int getID() const = 0;
/// <summary>Checks if the Bullet exists in the view of the BWAPI player.</summary>
///
/// @retval true If the bullet exists or is visible.
/// @retval false If the bullet was destroyed or has gone out of scope.
///
/// If Flag::CompleteMapInformation is disabled, and a Bullet is not visible, then the
/// return value will be false regardless of the Bullet's true existence. This is because
/// absolutely no state information on invisible enemy bullets is made available to the AI.
///
/// If Flag::CompleteMapInformation is enabled, then this function is accurate for all
/// Bullet information.
/// @see isVisible, UnitInterface::exists
virtual bool exists() const = 0;
/// <summary>Retrieves the Player interface that owns the Bullet.</summary>
///
/// @retval nullptr If the Player object for this Bullet is inaccessible.
///
/// @returns
/// The owning Player interface object.
virtual Player getPlayer() const = 0;
/// <summary>Retrieves the type of this Bullet.</summary>
///
/// @retval BulletTypes::Unknown if the Bullet is inaccessible.
///
/// @returns
/// A BulletType representing the Bullet's type.
virtual BulletType getType() const = 0;
/// <summary>Retrieves the Unit interface that the Bullet spawned from.</summary>
///
/// @retval nullptr If the source can not be identified or is inaccessible.
///
/// @returns
/// The owning Unit interface object.
/// @see getTarget
virtual Unit getSource() const = 0;
/// <summary>Retrieves the Bullet's current position.</summary>
///
/// @retval Positions::Unknown If the Bullet is inaccessible.
///
/// @returns
/// A Position containing the Bullet's current coordinates.
/// @see getTargetPosition
virtual Position getPosition() const = 0;
/// <summary>Retrieve's the direction the Bullet is facing.</summary> If the angle is 0, then
/// the Bullet is facing right.
///
/// @retval 0.0 If the bullet is inaccessible.
///
/// @returns
/// A double representing the direction the Bullet is facing.
virtual double getAngle() const = 0;
/// <summary>Retrieves the X component of the Bullet's velocity, measured in pixels per frame.</summary>
///
/// @retval 0.0 if the Bullet is inaccessible.
///
/// @returns
/// A double representing the number of pixels moved on the X axis per frame.
///
/// @see getVelocityY, getAngle
virtual double getVelocityX() const = 0;
/// <summary>Retrieves the Y component of the Bullet's velocity, measured in pixels per frame.</summary>
///
/// @retval 0.0 if the Bullet is inaccessible.
///
/// @returns
/// A double representing the number of pixels moved on the Y axis per frame.
///
/// @see getVelocityX, getAngle
virtual double getVelocityY() const = 0;
/// <summary>Retrieves the Unit interface that the Bullet is heading to.</summary>
///
/// @retval nullptr If the Bullet's target Unit is inaccessible, the Bullet is targetting the
/// ground, or if the Bullet itself is inaccessible.
///
/// @returns
/// The target Unit interface object, if one exists.
/// @see getTargetPosition, getSource
virtual Unit getTarget() const = 0;
/// <summary>Retrieves the target position that the Bullet is heading to.</summary>
///
/// @retval Positions::Unknown If the bullet is inaccessible.
///
/// @returns
/// A Position indicating where the Bullet is headed.
/// @see getTarget, getPosition
virtual Position getTargetPosition() const = 0;
/// <summary>Retrieves the timer that indicates the Bullet's life span.</summary>
///
/// Bullets are not permanent objects, so they will often have a limited life span.
/// This life span is measured in frames. Normally a Bullet will reach its target
/// before being removed.
///
/// @retval 0 If the Bullet is inaccessible.
///
/// @returns
/// An integer representing the remaining number of frames until the Bullet self-destructs.
virtual int getRemoveTimer() const = 0;
/// <summary>Retrieves the visibility state of the Bullet.</summary>
///
/// <param name="player"> (optional)
/// If this parameter is specified, then the Bullet's visibility to the given player is
/// checked. If this parameter is omitted, then a default value of nullptr is used, which
/// will check if the BWAPI player has vision of the Bullet.
/// </param>
///
/// @note If \c player is nullptr and Broodwar->self() is also nullptr, then the visibility of
/// the Bullet is determined by checking if at least one other player has vision of the
/// Bullet.
///
/// @retval true If the Bullet is visible to the specified player.
/// @retval false If the Bullet is not visible to the specified player.
virtual bool isVisible(Player player = nullptr) const = 0;
};
}

View file

@ -1,127 +0,0 @@
#pragma once
#include <BWAPI/Type.h>
namespace BWAPI
{
/// <summary>Namespace containing bullet types.</summary>
/// @see BulletType
namespace BulletTypes
{
/// <summary>Enumeration of bullet types.</summary>
/// @see BulletType
namespace Enum
{
/// <summary>Enumeration of bullet types.</summary>
/// @see BulletType
enum Enum
{
Melee = 0,
Fusion_Cutter_Hit = 141,
Gauss_Rifle_Hit,
C_10_Canister_Rifle_Hit,
Gemini_Missiles,
Fragmentation_Grenade,
Longbolt_Missile,
Unused_Lockdown,
ATS_ATA_Laser_Battery,
Burst_Lasers,
Arclite_Shock_Cannon_Hit,
EMP_Missile,
Dual_Photon_Blasters_Hit,
Particle_Beam_Hit,
Anti_Matter_Missile,
Pulse_Cannon,
Psionic_Shockwave_Hit,
Psionic_Storm,
Yamato_Gun,
Phase_Disruptor,
STA_STS_Cannon_Overlay,
Sunken_Colony_Tentacle,
Venom_Unused,
Acid_Spore,
Plasma_Drip_Unused,
Glave_Wurm,
Seeker_Spores,
Queen_Spell_Carrier,
Plague_Cloud,
Consume,
Ensnare,
Needle_Spine_Hit,
Invisible,
Optical_Flare_Grenade = 201,
Halo_Rockets,
Subterranean_Spines,
Corrosive_Acid_Shot,
Corrosive_Acid_Hit,
Neutron_Flare,
None = 209,
Unknown,
MAX
};
}
}
/// <summary>This class represents a type of bullet. </summary>
///
/// @note Internally, these are the same IDs as flingy types in Broodwar.
///
/// @see BulletTypes
/// @ingroup TypeClasses
class BulletType : public Type<BulletType, BulletTypes::Enum::Unknown>
{
public:
/// @copydoc Type::Type(int)
BulletType(int id = BulletTypes::Enum::None);
};
/// @ingroup Types
namespace BulletTypes
{
/// <summary>Retrieves the set of all the BulletTypes.</summary>
///
/// @returns Set of BulletTypes.
const BulletType::set& allBulletTypes();
extern const BulletType Melee;
extern const BulletType Fusion_Cutter_Hit;
extern const BulletType Gauss_Rifle_Hit;
extern const BulletType C_10_Canister_Rifle_Hit;
extern const BulletType Gemini_Missiles;
extern const BulletType Fragmentation_Grenade;
extern const BulletType Longbolt_Missile;
extern const BulletType ATS_ATA_Laser_Battery;
extern const BulletType Burst_Lasers;
extern const BulletType Arclite_Shock_Cannon_Hit;
extern const BulletType EMP_Missile;
extern const BulletType Dual_Photon_Blasters_Hit;
extern const BulletType Particle_Beam_Hit;
extern const BulletType Anti_Matter_Missile;
extern const BulletType Pulse_Cannon;
extern const BulletType Psionic_Shockwave_Hit;
extern const BulletType Psionic_Storm;
extern const BulletType Yamato_Gun;
extern const BulletType Phase_Disruptor;
extern const BulletType STA_STS_Cannon_Overlay;
extern const BulletType Sunken_Colony_Tentacle;
extern const BulletType Acid_Spore;
extern const BulletType Glave_Wurm;
extern const BulletType Seeker_Spores;
extern const BulletType Queen_Spell_Carrier;
extern const BulletType Plague_Cloud;
extern const BulletType Consume;
extern const BulletType Ensnare;
extern const BulletType Needle_Spine_Hit;
extern const BulletType Invisible;
extern const BulletType Optical_Flare_Grenade;
extern const BulletType Halo_Rockets;
extern const BulletType Subterranean_Spines;
extern const BulletType Corrosive_Acid_Shot;
extern const BulletType Neutron_Flare;
extern const BulletType None;
extern const BulletType Unknown;
};
static_assert(sizeof(BulletType) == sizeof(int), "Expected type to resolve to primitive size.");
}

View file

@ -1,16 +0,0 @@
#pragma once
#include "SetContainer.h"
namespace BWAPI
{
// Forward Declarations
class BulletInterface;
typedef BulletInterface *Bullet;
/// <summary>A container for a set of Bullet objects.</summary>
class Bulletset : public SetContainer<Bullet, std::hash<void*>>
{
public:
};
}

View file

@ -1,17 +0,0 @@
#pragma once
#include <BWAPI/Client/Client.h>
#include <BWAPI/Client/Command.h>
#include <BWAPI/Client/CommandType.h>
#include <BWAPI/Client/Event.h>
#include <BWAPI/Client/ForceData.h>
#include <BWAPI/Client/ForceImpl.h>
#include <BWAPI/Client/GameData.h>
#include <BWAPI/Client/GameImpl.h>
#include <BWAPI/Client/GameTable.h>
#include <BWAPI/Client/PlayerData.h>
#include <BWAPI/Client/PlayerImpl.h>
#include <BWAPI/Client/Shape.h>
#include <BWAPI/Client/ShapeType.h>
#include <BWAPI/Client/UnitCommand.h>
#include <BWAPI/Client/UnitData.h>
#include <BWAPI/Client/UnitImpl.h>

View file

@ -1,23 +0,0 @@
#pragma once
namespace BWAPI
{
struct BulletData
{
int id;
int player;
int type;
int source;
int positionX;
int positionY;
double angle;
double velocityX;
double velocityY;
int target;
int targetPositionX;
int targetPositionY;
int removeTimer;
bool exists;
bool isVisible[9];
};
}

View file

@ -1,33 +0,0 @@
#pragma once
#include <BWAPI.h>
#include "BulletData.h"
#include <string>
namespace BWAPI
{
class PlayerInterface;
typedef PlayerInterface *Player;
class BulletImpl : public BulletInterface
{
private:
const BulletData* self;
int index;
public:
BulletImpl(int index);
virtual int getID() const override;
virtual bool exists() const override;
virtual Player getPlayer() const override;
virtual BulletType getType() const override;
virtual Unit getSource() const override;
virtual Position getPosition() const override;
virtual double getAngle() const override;
virtual double getVelocityX() const override;
virtual double getVelocityY() const override;
virtual Unit getTarget() const override;
virtual Position getTargetPosition() const override;
virtual int getRemoveTimer() const override;
virtual bool isVisible(Player player = nullptr) const override;
};
}

View file

@ -1,35 +0,0 @@
#pragma once
#include "GameData.h"
#include "GameImpl.h"
#include "ForceImpl.h"
#include "PlayerImpl.h"
#include "UnitImpl.h"
#include "GameTable.h"
#include "../WindowsTypes.h"
namespace BWAPI
{
class Client
{
public:
Client();
~Client();
bool isConnected() const;
bool connect();
void disconnect();
void update();
GameData* data = nullptr;
private:
HANDLE pipeObjectHandle;
HANDLE mapFileHandle;
HANDLE gameTableFileHandle;
GameTable* gameTable = nullptr;
bool connected = false;
};
extern Client BWAPIClient;
}

View file

@ -1,23 +0,0 @@
#pragma once
#include "CommandType.h"
namespace BWAPIC
{
struct Command
{
Command()
: type( CommandType::None )
, value1( 0 )
, value2( 0 )
{ }
Command(CommandType::Enum _commandType, int _value1=0, int _value2=0)
: type( _commandType )
, value1( _value1 )
, value2( _value2 )
{ }
CommandType::Enum type;
int value1;
int value2;
};
}

View file

@ -1,33 +0,0 @@
#pragma once
/**
* Used in UnitCommand
*/
namespace BWAPIC
{
namespace CommandType
{
enum Enum
{
None,
SetScreenPosition,
PingMinimap,
EnableFlag,
Printf,
SendText,
PauseGame,
ResumeGame,
LeaveGame,
RestartGame,
SetLocalSpeed,
SetLatCom,
SetGui,
SetFrameSkip,
SetMap,
SetAllies,
SetVision,
SetCommandOptimizerLevel,
SetRevealAll
};
}
}

View file

@ -1,14 +0,0 @@
#pragma once
#include <BWAPI/Event.h>
#include <BWAPI/EventType.h>
namespace BWAPIC
{
struct Event
{
BWAPI::EventType::Enum type;
int v1;
int v2;
};
}

View file

@ -1,9 +0,0 @@
#pragma once
namespace BWAPI
{
struct ForceData
{
char name[32];
};
}

View file

@ -1,19 +0,0 @@
#pragma once
#include <BWAPI.h>
#include "ForceData.h"
#include <string>
namespace BWAPI
{
class ForceImpl : public ForceInterface
{
private:
const ForceData* self;
int id;
public:
ForceImpl(int id);
virtual int getID() const override;
virtual std::string getName() const override;
virtual Playerset getPlayers() const override;
};
}

View file

@ -1,163 +0,0 @@
#pragma once
#include "UnitCommand.h"
#include "ForceData.h"
#include "PlayerData.h"
#include "RegionData.h"
#include "UnitData.h"
#include "BulletData.h"
#include "Event.h"
#include "Command.h"
#include "Shape.h"
namespace BWAPIC
{
struct Position
{
Position() {x=0;y=0;}
int x;
int y;
};
}
namespace BWAPI
{
struct unitFinder
{
int unitIndex;
int searchValue;
};
struct GameData
{
//revision and debug will stay at the top of struct so they don't move in memory from revision to revision.
int revision;
bool isDebug;
int instanceID;
int botAPM_noselects;
int botAPM_selects;
//forces
int forceCount;
ForceData forces[5];
//players
int playerCount;
PlayerData players[12];
//units
int initialUnitCount;
UnitData units[10000];
//unit table
int unitArray[1700];
//bullets
BulletData bullets[100];
// nuke dots
int nukeDotCount;
BWAPIC::Position nukeDots[200];
int gameType;
int latency;
int latencyFrames;
int latencyTime;
int remainingLatencyFrames;
int remainingLatencyTime;
bool hasLatCom;
bool hasGUI;
int replayFrameCount;
int frameCount;
int elapsedTime;
int countdownTimer;
int fps;
double averageFPS;
// user input
int mouseX;
int mouseY;
bool mouseState[M_MAX];
bool keyState[K_MAX];
int screenX;
int screenY;
bool flags[BWAPI::Flag::Max];
// map
int mapWidth;
int mapHeight;
char mapFileName[261]; //size based on broodwar memory
char mapPathName[261]; //size based on broodwar memory
char mapName[33]; //size based on broodwar memory
char mapHash[41];
//tile data
int getGroundHeight[256][256];
bool isWalkable[1024][1024];
bool isBuildable[256][256];
bool isVisible[256][256];
bool isExplored[256][256];
bool hasCreep[256][256];
bool isOccupied[256][256];
unsigned short mapTileRegionId[256][256];
unsigned short mapSplitTilesMiniTileMask[5000];
unsigned short mapSplitTilesRegion1[5000];
unsigned short mapSplitTilesRegion2[5000];
int regionCount;
RegionData regions[5000];
// start locations
int startLocationCount;
BWAPIC::Position startLocations[8];
// match mode
bool isInGame;
bool isMultiplayer;
bool isBattleNet;
bool isPaused;
bool isReplay;
//selected units
int selectedUnitCount;
int selectedUnits[12];
// players
int self;
int enemy;
int neutral;
static const int MAX_EVENTS = 10000;
static const int MAX_EVENT_STRINGS = 1000;
static const int MAX_STRINGS = 20000;
static const int MAX_SHAPES = 20000;
static const int MAX_COMMANDS = 20000;
static const int MAX_UNIT_COMMANDS = 20000;
//events from server to client
int eventCount;
BWAPIC::Event events[MAX_EVENTS];
//strings used in events
int eventStringCount;
char eventStrings[MAX_EVENT_STRINGS][256];
//strings (used in shapes and commands)
int stringCount;
char strings[MAX_STRINGS][1024];
//shapes, commands, unitCommands, from client to server
int shapeCount;
BWAPIC::Shape shapes[MAX_SHAPES];
int commandCount;
BWAPIC::Command commands[MAX_COMMANDS];
int unitCommandCount;
BWAPIC::UnitCommand unitCommands[MAX_UNIT_COMMANDS];
int unitSearchSize;
unitFinder xUnitSearch[1700*2];
unitFinder yUnitSearch[1700*2];
};
}

View file

@ -1,200 +0,0 @@
#pragma once
#include <BWAPI.h>
#include "GameData.h"
#include "Client.h"
#include "Shape.h"
#include "Command.h"
#include "UnitCommand.h"
#include "ForceImpl.h"
#include "PlayerImpl.h"
#include "RegionImpl.h"
#include "UnitImpl.h"
#include "BulletImpl.h"
#include <list>
#include <vector>
#include <array>
namespace BWAPI
{
class ForceInterface;
typedef ForceInterface *Force;
class PlayerInterface;
typedef PlayerInterface *Player;
class GameImpl : public Game
{
private :
int addShape(const BWAPIC::Shape &s);
int addString(const char* text);
int addText(BWAPIC::Shape &s, const char* text);
int addCommand(const BWAPIC::Command &c);
void processInterfaceEvents();
void clearAll();
GameData* data;
std::vector<ForceImpl> forceVector;
std::vector<PlayerImpl> playerVector;
std::vector<UnitImpl> unitVector;
std::vector<BulletImpl> bulletVector;
std::array<RegionImpl*,5000> regionArray;
Forceset forces;
Playerset playerSet;
Unitset accessibleUnits;//all units that are accessible (and definitely alive)
//notDestroyedUnits - accessibleUnits = all units that may or may not be alive (status unknown)
Unitset minerals;
Unitset geysers;
Unitset neutralUnits;
Unitset staticMinerals;
Unitset staticGeysers;
Unitset staticNeutralUnits;
Bulletset bullets;
Position::list nukeDots;
Unitset selectedUnits;
Unitset pylons;
Regionset regionsList;
TilePosition::list startLocations;
std::list< Event > events;
Player thePlayer;
Player theEnemy;
Player theNeutral;
Playerset _allies;
Playerset _enemies;
Playerset _observers;
mutable Error lastError;
Text::Size::Enum textSize;
public :
Event makeEvent(BWAPIC::Event e);
int addUnitCommand(BWAPIC::UnitCommand& c);
bool inGame;
GameImpl(GameData* data);
void onMatchStart();
void onMatchEnd();
void onMatchFrame();
const GameData* getGameData() const;
Unit _unitFromIndex(int index);
virtual const Forceset& getForces() const override;
virtual const Playerset& getPlayers() const override;
virtual const Unitset& getAllUnits() const override;
virtual const Unitset& getMinerals() const override;
virtual const Unitset& getGeysers() const override;
virtual const Unitset& getNeutralUnits() const override;
virtual const Unitset& getStaticMinerals() const override;
virtual const Unitset& getStaticGeysers() const override;
virtual const Unitset& getStaticNeutralUnits() const override;
virtual const Bulletset& getBullets() const override;
virtual const Position::list& getNukeDots() const override;
virtual const std::list< Event>& getEvents() const override;
virtual Force getForce(int forceID) const override;
virtual Player getPlayer(int playerID) const override;
virtual Unit getUnit(int unitID) const override;
virtual Unit indexToUnit(int unitIndex) const override;
virtual Region getRegion(int regionID) const override;
virtual GameType getGameType() const override;
virtual int getLatency() const override;
virtual int getFrameCount() const override;
virtual int getReplayFrameCount() const override;
virtual int getFPS() const override;
virtual double getAverageFPS() const override;
virtual BWAPI::Position getMousePosition() const override;
virtual bool getMouseState(MouseButton button) const override;
virtual bool getKeyState(Key key) const override;
virtual BWAPI::Position getScreenPosition() const override;
virtual void setScreenPosition(int x, int y) override;
virtual void pingMinimap(int x, int y) override;
virtual bool isFlagEnabled(int flag) const override;
virtual void enableFlag(int flag) override;
virtual Unitset getUnitsInRectangle(int left, int top, int right, int bottom, const UnitFilter &pred = nullptr) const override;
virtual Unit getClosestUnitInRectangle(Position center, const UnitFilter &pred = nullptr, int left = 0, int top = 0, int right = 999999, int bottom = 999999) const override;
virtual Unit getBestUnit(const BestUnitFilter &best, const UnitFilter &pred, Position center = Positions::None, int radius = 999999) const override;
virtual Error getLastError() const override;
virtual bool setLastError(BWAPI::Error e = Errors::None) const override;
virtual int mapWidth() const override;
virtual int mapHeight() const override;
virtual std::string mapFileName() const override;
virtual std::string mapPathName() const override;
virtual std::string mapName() const override;
virtual std::string mapHash() const override;
virtual bool isWalkable(int x, int y) const override;
virtual int getGroundHeight(int x, int y) const override;
virtual bool isBuildable(int x, int y, bool includeBuildings = false) const override;
virtual bool isVisible(int x, int y) const override;
virtual bool isExplored(int x, int y) const override;
virtual bool hasCreep(int x, int y) const override;
virtual bool hasPowerPrecise(int x, int y, UnitType unitType = UnitTypes::None ) const override;
virtual bool canBuildHere(TilePosition position, UnitType type, Unit builder = nullptr, bool checkExplored = false) override;
virtual bool canMake(UnitType type, Unit builder = nullptr) const override;
virtual bool canResearch(TechType type, Unit unit = nullptr, bool checkCanIssueCommandType = true) override;
virtual bool canUpgrade(UpgradeType type, Unit unit = nullptr, bool checkCanIssueCommandType = true) override;
virtual const TilePosition::list& getStartLocations() const override;
virtual void vPrintf(const char* format, va_list arg) override;
virtual void vSendTextEx(bool toAllies, const char *format, va_list arg) override;
virtual bool isInGame() const override;
virtual bool isMultiplayer() const override;
virtual bool isBattleNet() const override;
virtual bool isPaused() const override;
virtual bool isReplay() const override;
virtual void pauseGame() override;
virtual void resumeGame() override;
virtual void leaveGame() override;
virtual void restartGame() override;
virtual void setLocalSpeed(int speed = -1) override;
virtual bool issueCommand(const Unitset& units, UnitCommand command) override;
virtual const Unitset& getSelectedUnits() const override;
virtual Player self() const override;
virtual Player enemy() const override;
virtual Player neutral() const override;
virtual Playerset& allies() override;
virtual Playerset& enemies() override;
virtual Playerset& observers() override;
virtual void setTextSize(Text::Size::Enum size = Text::Size::Default) override;
virtual void vDrawText(CoordinateType::Enum ctype, int x, int y, const char *format, va_list arg) override;
virtual void drawBox(CoordinateType::Enum ctype, int left, int top, int right, int bottom, Color color, bool isSolid = false) override;
virtual void drawTriangle(CoordinateType::Enum ctype, int ax, int ay, int bx, int by, int cx, int cy, Color color, bool isSolid = false) override;
virtual void drawCircle(CoordinateType::Enum ctype, int x, int y, int radius, Color color, bool isSolid = false) override;
virtual void drawEllipse(CoordinateType::Enum ctype, int x, int y, int xrad, int yrad, Color color, bool isSolid = false) override;
virtual void drawDot(CoordinateType::Enum ctype, int x, int y, Color color) override;
virtual void drawLine(CoordinateType::Enum ctype, int x1, int y1, int x2, int y2, Color color) override;
virtual int getLatencyFrames() const override;
virtual int getLatencyTime() const override;
virtual int getRemainingLatencyFrames() const override;
virtual int getRemainingLatencyTime() const override;
virtual int getRevision() const override;
virtual bool isDebug() const override;
virtual bool isLatComEnabled() const override;
virtual void setLatCom(bool isEnabled) override;
virtual bool isGUIEnabled() const override;
virtual void setGUI(bool enabled) override;
virtual int getInstanceNumber() const override;
virtual int getAPM(bool includeSelects = false) const override;
virtual bool setMap(const char *mapFileName) override;
virtual void setFrameSkip(int frameSkip) override;
virtual bool setAlliance(BWAPI::Player player, bool allied = true, bool alliedVictory = true) override;
virtual bool setVision(BWAPI::Player player, bool enabled = true) override;
virtual int elapsedTime() const override;
virtual void setCommandOptimizationLevel(int level) override;
virtual int countdownTimer() const override;
virtual const Regionset &getAllRegions() const override;
virtual BWAPI::Region getRegionAt(int x, int y) const override;
virtual int getLastEventTime() const override;
virtual bool setRevealAll(bool reveal = true) override;
};
}

View file

@ -1,30 +0,0 @@
#pragma once
namespace BWAPI
{
struct GameInstance
{
GameInstance()
: serverProcessID(0)
, isConnected(false)
, lastKeepAliveTime(0)
{};
GameInstance(unsigned int servID, bool connected, unsigned int lastAliveTime)
: serverProcessID(servID)
, isConnected(connected)
, lastKeepAliveTime(lastAliveTime)
{};
unsigned int serverProcessID;
bool isConnected;
//time_t lastKeepAliveTime;
unsigned int lastKeepAliveTime;
};
struct GameTable
{
GameTable()
{}
static const int MAX_GAME_INSTANCES = 8;
GameInstance gameInstances[MAX_GAME_INSTANCES];
};
}

View file

@ -1,59 +0,0 @@
#pragma once
#include <BWAPI/UnitType.h>
#include <BWAPI/UpgradeType.h>
#include <BWAPI/TechType.h>
namespace BWAPI
{
struct PlayerData
{
char name[25];
int race;
int type;
int force;
bool isAlly[12];
bool isEnemy[12];
bool isNeutral;
int startLocationX;
int startLocationY;
bool isVictorious;
bool isDefeated;
bool leftGame;
bool isParticipating;
int minerals;
int gas;
int gatheredMinerals;
int gatheredGas;
int repairedMinerals;
int repairedGas;
int refundedMinerals;
int refundedGas;
int supplyTotal[3];
int supplyUsed[3];
int allUnitCount[UnitTypes::Enum::MAX];
int visibleUnitCount[UnitTypes::Enum::MAX];
int completedUnitCount[UnitTypes::Enum::MAX];
int deadUnitCount[UnitTypes::Enum::MAX];
int killedUnitCount[UnitTypes::Enum::MAX];
int upgradeLevel[UpgradeTypes::Enum::MAX];
bool hasResearched[TechTypes::Enum::MAX];
bool isResearching[TechTypes::Enum::MAX];
bool isUpgrading[UpgradeTypes::Enum::MAX];
int color;
int totalUnitScore;
int totalKillScore;
int totalBuildingScore;
int totalRazingScore;
int customScore;
int maxUpgradeLevel[UpgradeTypes::Enum::MAX];
bool isResearchAvailable[TechTypes::Enum::MAX];
bool isUnitAvailable[UnitTypes::Enum::MAX];
};
}

View file

@ -1,75 +0,0 @@
#pragma once
#include <BWAPI.h>
#include "PlayerData.h"
#include <string>
#include <BWAPI/Unitset.h>
namespace BWAPI
{
class ForceInterface;
typedef ForceInterface *Force;
class PlayerImpl : public PlayerInterface
{
private:
int id;
public:
PlayerData* self;
Unitset units;
void clear();
PlayerImpl(int id);
virtual int getID() const override;
virtual std::string getName() const override;
virtual const Unitset &getUnits() const override;
virtual Race getRace() const override;
virtual PlayerType getType() const override;
virtual Force getForce() const override;
virtual bool isAlly(const Player player) const override;
virtual bool isEnemy(const Player player) const override;
virtual bool isNeutral() const override;
virtual TilePosition getStartLocation() const override;
virtual bool isVictorious() const override;
virtual bool isDefeated() const override;
virtual bool leftGame() const override;
virtual int minerals() const override;
virtual int gas() const override;
virtual int gatheredMinerals() const override;
virtual int gatheredGas() const override;
virtual int repairedMinerals() const override;
virtual int repairedGas() const override;
virtual int refundedMinerals() const override;
virtual int refundedGas() const override;
virtual int spentMinerals() const override;
virtual int spentGas() const override;
virtual int supplyTotal(Race race = Races::None) const override;
virtual int supplyUsed(Race race = Races::None) const override;
virtual int allUnitCount(UnitType unit) const override;
virtual int visibleUnitCount(UnitType unit) const override;
virtual int completedUnitCount(UnitType unit) const override;
virtual int deadUnitCount(UnitType unit) const override;
virtual int killedUnitCount(UnitType unit) const override;
virtual int getUpgradeLevel(UpgradeType upgrade) const override;
virtual bool hasResearched(TechType tech) const override;
virtual bool isResearching(TechType tech) const override;
virtual bool isUpgrading(UpgradeType upgrade) const override;
virtual BWAPI::Color getColor() const override;
virtual int getUnitScore() const override;
virtual int getKillScore() const override;
virtual int getBuildingScore() const override;
virtual int getRazingScore() const override;
virtual int getCustomScore() const override;
virtual bool isObserver() const override;
virtual int getMaxUpgradeLevel(UpgradeType upgrade) const override;
virtual bool isResearchAvailable(TechType tech) const override;
virtual bool isUnitAvailable(UnitType unit) const override;
};
};

View file

@ -1,25 +0,0 @@
#pragma once
namespace BWAPI
{
struct RegionData
{
int id;
int islandID;
int center_x;
int center_y;
int priority;
// region boundary
int leftMost;
int rightMost;
int topMost;
int bottomMost;
int neighborCount;
int neighbors[256];
bool isAccessible;
bool isHigherGround;
};
};

View file

@ -1,39 +0,0 @@
#pragma once
#include <BWAPI/Region.h>
#include <BWAPI/Position.h>
#include <BWAPI/Client/RegionData.h>
#include <BWAPI/Regionset.h>
namespace BWAPI
{
class RegionImpl : public RegionInterface
{
private:
RegionData* self;
Regionset neighbors;
BWAPI::Region closestAccessibleRgn = nullptr;
BWAPI::Region closestInaccessibleRgn = nullptr;
public:
RegionImpl(int index);
void setNeighbors();
virtual int getID() const override;
virtual int getRegionGroupID() const override;
virtual BWAPI::Position getCenter() const override;
virtual bool isHigherGround() const override;
virtual int getDefensePriority() const override;
virtual bool isAccessible() const override;
virtual const Regionset &getNeighbors() const override;
virtual int getBoundsLeft() const override;
virtual int getBoundsTop() const override;
virtual int getBoundsRight() const override;
virtual int getBoundsBottom() const override;
virtual BWAPI::Region getClosestAccessibleRegion() const override;
virtual BWAPI::Region getClosestInaccessibleRegion() const override;
};
};

View file

@ -1,48 +0,0 @@
#pragma once
#include "ShapeType.h"
#include <BWAPI/CoordinateType.h>
namespace BWAPIC
{
struct Shape
{
Shape()
:type(ShapeType::None)
,ctype(BWAPI::CoordinateType::None)
,x1(0)
,y1(0)
,x2(0)
,y2(0)
,extra1(0)
,extra2(0)
,color(0)
,isSolid(false)
{
}
Shape(ShapeType::Enum _shapeType, BWAPI::CoordinateType::Enum _ctype, int _x1, int _y1, int _x2, int _y2, int _extra1, int _extra2, int _color, bool _isSolid)
:type(_shapeType)
,ctype(_ctype)
,x1(_x1)
,y1(_y1)
,x2(_x2)
,y2(_y2)
,extra1(_extra1)
,extra2(_extra2)
,color(_color)
,isSolid(_isSolid)
{
}
ShapeType::Enum type;
BWAPI::CoordinateType::Enum ctype;
int x1;
int y1;
int x2;
int y2;
int extra1;
int extra2;
int color;
bool isSolid;
};
}

View file

@ -1,22 +0,0 @@
#pragma once
/**
* Used in UnitCommand
*/
namespace BWAPIC
{
namespace ShapeType
{
enum Enum
{
None,
Text,
Box,
Triangle,
Circle,
Ellipse,
Dot,
Line
};
}
}

View file

@ -1,20 +0,0 @@
#pragma once
#include <BWAPI.h>
/**
* UnitOrder contains a single whole order
*/
namespace BWAPIC
{
struct UnitCommand
{
BWAPI::UnitCommandType type;
int unitIndex;
int targetIndex;
int x;
int y;
int extra;
};
}

View file

@ -1,111 +0,0 @@
#pragma once
namespace BWAPI
{
struct UnitData
{
int clearanceLevel;
int id;
int player;
int type;
int positionX;
int positionY;
double angle;
double velocityX;
double velocityY;
int hitPoints;
int lastHitPoints;
int shields;
int energy;
int resources;
int resourceGroup;
int killCount;
int acidSporeCount;
int scarabCount;
int spiderMineCount;
int groundWeaponCooldown;
int airWeaponCooldown;
int spellCooldown;
int defenseMatrixPoints;
int defenseMatrixTimer;
int ensnareTimer;
int irradiateTimer;
int lockdownTimer;
int maelstromTimer;
int orderTimer;
int plagueTimer;
int removeTimer;
int stasisTimer;
int stimTimer;
int buildType;
int trainingQueueCount;
int trainingQueue[5];
int tech;
int upgrade;
int remainingBuildTime;
int remainingTrainTime;
int remainingResearchTime;
int remainingUpgradeTime;
int buildUnit;
int target;
int targetPositionX;
int targetPositionY;
int order;
int orderTarget;
int orderTargetPositionX;
int orderTargetPositionY;
int secondaryOrder;
int rallyPositionX;
int rallyPositionY;
int rallyUnit;
int addon;
int nydusExit;
int powerUp;
int transport;
int carrier;
int hatchery;
bool exists;
bool hasNuke;
bool isAccelerating;
bool isAttacking;
bool isAttackFrame;
bool isBeingGathered;
bool isBlind;
bool isBraking;
bool isBurrowed;
int carryResourceType;
bool isCloaked;
bool isCompleted;
bool isConstructing;
bool isDetected;
bool isGathering;
bool isHallucination;
bool isIdle;
bool isInterruptible;
bool isInvincible;
bool isLifted;
bool isMorphing;
bool isMoving;
bool isParasited;
bool isSelected;
bool isStartingAttack;
bool isStuck;
bool isTraining;
bool isUnderStorm;
bool isUnderDarkSwarm;
bool isUnderDWeb;
bool isPowered;
bool isVisible[9];
int buttonset;
int lastAttackerPlayer;
bool recentlyAttacked;
int replayID;
};
}

View file

@ -1,242 +0,0 @@
#pragma once
#include <BWAPI.h>
#include "UnitData.h"
#include <string>
namespace BWAPI
{
class PlayerInterface;
typedef PlayerInterface *Player;
class UnitImpl : public UnitInterface
{
private:
int id;
UnitType initialType;
int initialResources;
int initialHitPoints;
Position initialPosition;
int lastCommandFrame;
UnitCommand lastCommand;
public:
UnitData* self;
Unitset connectedUnits;
Unitset loadedUnits;
void clear();
void saveInitialState();
UnitImpl(int _id);
virtual int getID() const override;
virtual bool exists() const override;
virtual int getReplayID() const override;
virtual Player getPlayer() const override;
virtual UnitType getType() const override;
virtual Position getPosition() const override;
virtual double getAngle() const override;
virtual double getVelocityX() const override;
virtual double getVelocityY() const override;
virtual int getHitPoints() const override;
virtual int getShields() const override;
virtual int getEnergy() const override;
virtual int getResources() const override;
virtual int getResourceGroup() const override;
virtual int getLastCommandFrame() const override;
virtual UnitCommand getLastCommand() const override;
virtual BWAPI::Player getLastAttackingPlayer() const override;
virtual UnitType getInitialType() const override;
virtual Position getInitialPosition() const override;
virtual TilePosition getInitialTilePosition() const override;
virtual int getInitialHitPoints() const override;
virtual int getInitialResources() const override;
virtual int getKillCount() const override;
virtual int getAcidSporeCount() const override;
virtual int getInterceptorCount() const override;
virtual int getScarabCount() const override;
virtual int getSpiderMineCount() const override;
virtual int getGroundWeaponCooldown() const override;
virtual int getAirWeaponCooldown() const override;
virtual int getSpellCooldown() const override;
virtual int getDefenseMatrixPoints() const override;
virtual int getDefenseMatrixTimer() const override;
virtual int getEnsnareTimer() const override;
virtual int getIrradiateTimer() const override;
virtual int getLockdownTimer() const override;
virtual int getMaelstromTimer() const override;
virtual int getOrderTimer() const override;
virtual int getPlagueTimer() const override;
virtual int getRemoveTimer() const override;
virtual int getStasisTimer() const override;
virtual int getStimTimer() const override;
virtual UnitType getBuildType() const override;
virtual UnitType::list getTrainingQueue() const override;
virtual TechType getTech() const override;
virtual UpgradeType getUpgrade() const override;
virtual int getRemainingBuildTime() const override;
virtual int getRemainingTrainTime() const override;
virtual int getRemainingResearchTime() const override;
virtual int getRemainingUpgradeTime() const override;
virtual Unit getBuildUnit() const override;
virtual Unit getTarget() const override;
virtual Position getTargetPosition() const override;
virtual Order getOrder() const override;
virtual Unit getOrderTarget() const override;
virtual Position getOrderTargetPosition() const override;
virtual Order getSecondaryOrder() const override;
virtual Position getRallyPosition() const override;
virtual Unit getRallyUnit() const override;
virtual Unit getAddon() const override;
virtual Unit getNydusExit() const override;
virtual Unit getPowerUp() const override;
virtual Unit getTransport() const override;
virtual Unitset getLoadedUnits() const override;
virtual Unit getCarrier() const override;
virtual Unitset getInterceptors() const override;
virtual Unit getHatchery() const override;
virtual Unitset getLarva() const override;
virtual bool hasNuke() const override;
virtual bool isAccelerating() const override;
virtual bool isAttackFrame() const override;
virtual bool isAttacking() const override;
virtual bool isBeingGathered() const override;
virtual bool isBeingHealed() const override;
virtual bool isBlind() const override;
virtual bool isBraking() const override;
virtual bool isBurrowed() const override;
virtual bool isCarryingGas() const override;
virtual bool isCarryingMinerals() const override;
virtual bool isCloaked() const override;
virtual bool isCompleted() const override;
virtual bool isConstructing() const override;
virtual bool isDetected() const override;
virtual bool isGatheringGas() const override;
virtual bool isGatheringMinerals() const override;
virtual bool isHallucination() const override;
virtual bool isIdle() const override;
virtual bool isInterruptible() const override;
virtual bool isInvincible() const override;
virtual bool isLifted() const override;
virtual bool isMorphing() const override;
virtual bool isMoving() const override;
virtual bool isParasited() const override;
virtual bool isSelected() const override;
virtual bool isStartingAttack() const override;
virtual bool isStuck() const override;
virtual bool isTraining() const override;
virtual bool isUnderAttack() const override;
virtual bool isUnderDarkSwarm() const override;
virtual bool isUnderDisruptionWeb() const override;
virtual bool isUnderStorm() const override;
virtual bool isPowered() const override;
virtual bool isVisible(Player player = nullptr) const override;
virtual bool isTargetable() const override;
virtual bool canCommand() const override;
virtual bool canCommandGrouped(bool checkCommandibility = true) const override;
virtual bool canTargetUnit(Unit targetUnit, bool checkCommandibility = true) const override;
virtual bool canAttack(bool checkCommandibility = true) const override;
virtual bool canAttack(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canAttackGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
virtual bool canAttackGrouped(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
virtual bool canAttackMove(bool checkCommandibility = true) const override;
virtual bool canAttackMoveGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
virtual bool canAttackUnit(bool checkCommandibility = true) const override;
virtual bool canAttackUnit(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canAttackUnitGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
virtual bool canAttackUnitGrouped(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
virtual bool canBuild(bool checkCommandibility = true) const override;
virtual bool canBuild(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canBuild(UnitType uType, BWAPI::TilePosition tilePos, bool checkTargetUnitType = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canBuildAddon(bool checkCommandibility = true) const override;
virtual bool canBuildAddon(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canTrain(bool checkCommandibility = true) const override;
virtual bool canTrain(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canMorph(bool checkCommandibility = true) const override;
virtual bool canMorph(UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canResearch(bool checkCommandibility = true) const override;
virtual bool canResearch(TechType type, bool checkCanIssueCommandType = true) const override;
virtual bool canUpgrade(bool checkCommandibility = true) const override;
virtual bool canUpgrade(UpgradeType type, bool checkCanIssueCommandType = true) const override;
virtual bool canSetRallyPoint(bool checkCommandibility = true) const override;
virtual bool canSetRallyPoint(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canSetRallyPosition(bool checkCommandibility = true) const override;
virtual bool canSetRallyUnit(bool checkCommandibility = true) const override;
virtual bool canSetRallyUnit(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canMove(bool checkCommandibility = true) const override;
virtual bool canMoveGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
virtual bool canPatrol(bool checkCommandibility = true) const override;
virtual bool canPatrolGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
virtual bool canFollow(bool checkCommandibility = true) const override;
virtual bool canFollow(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canGather(bool checkCommandibility = true) const override;
virtual bool canGather(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canReturnCargo(bool checkCommandibility = true) const override;
virtual bool canHoldPosition(bool checkCommandibility = true) const override;
virtual bool canStop(bool checkCommandibility = true) const override;
virtual bool canRepair(bool checkCommandibility = true) const override;
virtual bool canRepair(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canBurrow(bool checkCommandibility = true) const override;
virtual bool canUnburrow(bool checkCommandibility = true) const override;
virtual bool canCloak(bool checkCommandibility = true) const override;
virtual bool canDecloak(bool checkCommandibility = true) const override;
virtual bool canSiege(bool checkCommandibility = true) const override;
virtual bool canUnsiege(bool checkCommandibility = true) const override;
virtual bool canLift(bool checkCommandibility = true) const override;
virtual bool canLand(bool checkCommandibility = true) const override;
virtual bool canLand(TilePosition target, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canLoad(bool checkCommandibility = true) const override;
virtual bool canLoad(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canUnloadWithOrWithoutTarget(bool checkCommandibility = true) const override;
virtual bool canUnloadAtPosition(Position targDropPos, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canUnload(bool checkCommandibility = true) const override;
virtual bool canUnload(Unit targetUnit, bool checkCanTargetUnit = true, bool checkPosition = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canUnloadAll(bool checkCommandibility = true) const override;
virtual bool canUnloadAllPosition(bool checkCommandibility = true) const override;
virtual bool canUnloadAllPosition(Position targDropPos, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canRightClick(bool checkCommandibility = true) const override;
virtual bool canRightClick(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canRightClickGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
virtual bool canRightClickGrouped(PositionOrUnit target, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
virtual bool canRightClickPosition(bool checkCommandibility = true) const override;
virtual bool canRightClickPositionGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
virtual bool canRightClickUnit(bool checkCommandibility = true) const override;
virtual bool canRightClickUnit(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canRightClickUnitGrouped(bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
virtual bool canRightClickUnitGrouped(Unit targetUnit, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
virtual bool canHaltConstruction(bool checkCommandibility = true) const override;
virtual bool canCancelConstruction(bool checkCommandibility = true) const override;
virtual bool canCancelAddon(bool checkCommandibility = true) const override;
virtual bool canCancelTrain(bool checkCommandibility = true) const override;
virtual bool canCancelTrainSlot(bool checkCommandibility = true) const override;
virtual bool canCancelTrainSlot(int slot, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canCancelMorph(bool checkCommandibility = true) const override;
virtual bool canCancelResearch(bool checkCommandibility = true) const override;
virtual bool canCancelUpgrade(bool checkCommandibility = true) const override;
virtual bool canUseTechWithOrWithoutTarget(bool checkCommandibility = true) const override;
virtual bool canUseTechWithOrWithoutTarget(BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canUseTech(BWAPI::TechType tech, PositionOrUnit target = nullptr, bool checkCanTargetUnit = true, bool checkTargetsType = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canUseTechWithoutTarget(BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canUseTechUnit(BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canUseTechUnit(BWAPI::TechType tech, Unit targetUnit, bool checkCanTargetUnit = true, bool checkTargetsUnits = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canUseTechPosition(BWAPI::TechType tech, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canUseTechPosition(BWAPI::TechType tech, Position target, bool checkTargetsPositions = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canPlaceCOP(bool checkCommandibility = true) const override;
virtual bool canPlaceCOP(TilePosition target, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canIssueCommandType(BWAPI::UnitCommandType ct, bool checkCommandibility = true) const override;
virtual bool canIssueCommandTypeGrouped(BWAPI::UnitCommandType ct, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
virtual bool canIssueCommand(UnitCommand command, bool checkCanUseTechPositionOnPositions = true, bool checkCanUseTechUnitOnUnits = true, bool checkCanBuildUnitType = true, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibility = true) const override;
virtual bool canIssueCommandGrouped(UnitCommand command, bool checkCanUseTechPositionOnPositions = true, bool checkCanUseTechUnitOnUnits = true, bool checkCanTargetUnit = true, bool checkCanIssueCommandType = true, bool checkCommandibilityGrouped = true, bool checkCommandibility = true) const override;
virtual bool issueCommand(UnitCommand command) override;
};
}

View file

@ -1,223 +0,0 @@
#pragma once
#include <BWAPI/Type.h>
namespace BWAPI
{
/// <summary>The Color object is used in drawing routines to specify the color to use.</summary>
///
/// @note Starcraft uses a 256 color palette for rendering. Thus, the colors available are
/// limited to this palette.
///
/// @see Colors
/// @ingroup TypeClasses
class Color : public Type<Color, 255>
{
public:
/// <summary>A constructor that uses the color at the specified palette index.</summary>
///
/// <param name="id">
/// The index of the color in the 256-color palette.
/// </param>
Color(int id = 0);
/// <summary>A constructor that uses the color index in the palette that is closest to the
/// given rgb values.</summary> On its first call, the colors in the palette will be sorted
/// for fast indexing.
///
/// @note This function computes the distance of the RGB values and may not be accurate.
///
/// <param name="red">
/// The amount of red.
/// </param>
/// <param name="green">
/// The amount of green.
/// </param>
/// <param name="blue">
/// The amount of blue.
/// </param>
Color(int red, int green, int blue);
/// <summary>Retrieves the red component of the color.</summary>
///
/// @returns integer containing the value of the red component.
int red() const;
/// <summary>Retrieves the green component of the color.</summary>
///
/// @returns integer containing the value of the green component.
int green() const;
/// <summary>Retrieves the blue component of the color.</summary>
///
/// @returns integer containing the value of the blue component.
int blue() const;
};
/// <summary>Namespace containing known colors.</summary>
/// @see Color
/// @ingroup Types
namespace Colors
{
/// <summary>The default color for Player 1.</summary>
extern const Color Red;
/// <summary>The default color for Player 2.</summary>
extern const Color Blue;
/// <summary>The default color for Player 3.</summary>
extern const Color Teal;
/// <summary>The default color for Player 4.</summary>
extern const Color Purple;
/// <summary>The default color for Player 5.</summary>
extern const Color Orange;
/// <summary>The default color for Player 6.</summary>
extern const Color Brown;
/// <summary>A bright white. Note that this is lighter than Player 7's white.</summary>
extern const Color White;
/// <summary>The default color for Player 8.</summary>
extern const Color Yellow;
/// <summary>The alternate color for Player 7 on Ice tilesets.</summary>
extern const Color Green;
/// <summary>The default color for Neutral (Player 12).</summary>
extern const Color Cyan;
/// <summary>The color black</summary>
extern const Color Black;
/// <summary>The color grey</summary>
extern const Color Grey;
}
/// <summary>Namespace containing text formatting codes.</summary> Such codes are used in calls
/// to Game::drawText, Game::printf, and Broodwar::operator<<
namespace Text
{
/// <summary>Enumeration of text formatting codes</summary>
enum Enum
{
/// <summary>Uses the previous color that was specified before the current one.</summary>
Previous = 1,
/// <summary>Uses the default blueish color. This color is used in standard game messages.</summary>
Default = 2,
/// <summary>A solid yellow. This yellow is used in notifications and is also the default
/// color when printing text to Broodwar.</summary>
Yellow = 3,
/// <summary>A bright white. This is used for timers.</summary>
White = 4,
/// <summary>A dark grey. This color code will override all color formatting that follows.</summary>
Grey = 5,
/// <summary>A deep red. This color code is used for error messages.</summary>
Red = 6,
/// <summary>A solid green. This color is used for sent messages and resource counters.</summary>
Green = 7,
/// <summary>A type of red. This color is used to color the name of the red player.</summary>
BrightRed = 8,
/// <summary>This code hides all text and formatting that follows.</summary>
Invisible = 11,
/// <summary>A deep blue. This color is used to color the name of the blue player.</summary>
Blue = 14,
/// <summary>A teal color. This color is used to color the name of the teal player.</summary>
Teal = 15,
/// <summary>A deep purple. This color is used to color the name of the purple player.</summary>
Purple = 16,
/// <summary>A solid orange. This color is used to color the name of the orange player.</summary>
Orange = 17,
/// <summary>An alignment directive that aligns the text to the right side of the screen.</summary>
Align_Right = 18,
/// <summary>An alignment directive that aligns the text to the center of the screen.</summary>
Align_Center = 19,
/// @copydoc Invisible
Invisible2 = 20,
/// <summary>A dark brown. This color is used to color the name of the brown player.</summary>
Brown = 21,
/// <summary>A dirty white. This color is used to color the name of the white player.</summary>
PlayerWhite = 22,
/// <summary>A deep yellow. This color is used to color the name of the yellow player.</summary>
PlayerYellow = 23,
/// <summary>A dark green. This color is used to color the name of the green player.</summary>
DarkGreen = 24,
/// <summary>A bright yellow.</summary>
LightYellow = 25,
/// <summary>A cyan color. Similar to Default.</summary>
Cyan = 26,
/// <summary>A tan color.</summary>
Tan = 27,
/// <summary>A dark blueish color.</summary>
GreyBlue = 28,
/// <summary>A type of Green.</summary>
GreyGreen = 29,
/// <summary>A different type of Cyan.</summary>
GreyCyan = 30,
/// <summary>A bright blue color.</summary>
Turquoise = 31
};
/// <summary>Namespace containing text sizes.</summary>
namespace Size
{
/// <summary>Enumeration of available text sizes</summary>
enum Enum
{
/// <summary>The smallest text size in the game.</summary>
Small,
/// <summary>The standard text size, used for most things in the game such as chat messages.</summary>
Default,
/// <summary>A larger text size. This size is used for the in-game countdown timer seen in @CTF and @UMS game types.</summary>
Large,
/// <summary>The largest text size in the game.</summary>
Huge
};
}
/// <summary>Standard output stream operator for text formatting codes.</summary> This is
/// used to correctly format the codes for output.
///
/// <param name="out">
/// Reference to destination output stream.
/// </param>
/// <param name="t">
/// Reference to the Text formatting code to insert into the output stream.
/// </param>
///
/// @returns Reference to the \p out parameter that was passed in.
std::ostream &operator << (std::ostream &out, const Text::Enum &t);
}
static_assert(sizeof(Color) == sizeof(int), "Expected type to resolve to primitive size.");
}

View file

@ -1,92 +0,0 @@
#pragma once
// Prevent warnings if someone includes windows.h
#ifdef max
#undef max
#endif
#include <functional>
#include <limits>
#include "UnaryFilter.h"
#define BWAPI_COMPARE_FILTER_OP(op) UnaryFilter<PType> operator op(const RType &cmp) const \
{ return [=](PType v)->bool{ return (*this)(v) op cmp; }; }
#define BWAPI_ARITHMATIC_FILTER_OP(op) template <typename T> \
CompareFilter<PType,RType,std::function<RType(PType)> > operator op(const T &other) const \
{ return [=](PType v)->int{ return (*this)(v) op other(v); }; } \
CompareFilter<PType,RType,std::function<RType(PType)> > operator op(RType other) const \
{ return [=](PType v)->int{ return (*this)(v) op other; }; }
namespace BWAPI
{
/// <summary>The CompareFilter is a container in which a stored function predicate returns a
/// value.</summary> Arithmetic and bitwise operators will return a new CompareFilter that
/// applies the operation to the result of the original functor. If any relational operators are
/// used, then it creates a UnaryFilter that returns the result of the operation.
///
/// @tparam PType
/// The parameter type, which is the type passed into the functor.
/// @tparam RType (optional)
/// The functor's return type. It is int by default.
/// @tparam Container (optional)
/// Storage container for the function predicate. It is std::function<RType(PType)> by default.
template < typename PType, typename RType=int, class Container = std::function<RType(PType)> >
class CompareFilter
{
private:
Container pred;
public:
// ctor
template <typename T>
CompareFilter(const T &predicate) : pred(predicate) {}
// Default copy/move ctor/assign and dtor
// Comparison operators
BWAPI_COMPARE_FILTER_OP(==);
BWAPI_COMPARE_FILTER_OP(!=);
BWAPI_COMPARE_FILTER_OP(<=);
BWAPI_COMPARE_FILTER_OP(>=);
BWAPI_COMPARE_FILTER_OP(<);
BWAPI_COMPARE_FILTER_OP(>);
// Arithmetic operators
BWAPI_ARITHMATIC_FILTER_OP(+);
BWAPI_ARITHMATIC_FILTER_OP(-);
BWAPI_ARITHMATIC_FILTER_OP(|);
BWAPI_ARITHMATIC_FILTER_OP(&);
BWAPI_ARITHMATIC_FILTER_OP(*);
BWAPI_ARITHMATIC_FILTER_OP(^);
// Division
template <typename T>
CompareFilter<PType,RType,std::function<RType(PType)> > operator /(const T &other) const
{
return [=](PType v)->int{ int rval = other(v);
return rval == 0 ? std::numeric_limits<int>::max() : (*this)(v) / rval;
};
};
// Modulus
template <typename T>
CompareFilter<PType,RType,std::function<RType(PType)> > operator %(const T &other) const
{
return [=](PType v)->int{ int rval = other(v);
return rval == 0 ? 0 : (*this)(v) % rval;
};
};
// call
inline RType operator()(PType u) const
{
return pred(u);
};
inline bool isValid() const
{
return (bool)pred;
};
};
}

View file

@ -1,6 +0,0 @@
#pragma once
namespace BWAPI
{
/** Used for converting between TilePosition coordinates and Position coordinates. */
#define TILE_SIZE 32
}

View file

@ -1,23 +0,0 @@
#pragma once
namespace BWAPI
{
/// <summary>Contains the coordinate type enumeration for relative drawing positions.</summary>
namespace CoordinateType
{
/// <summary>The coordinate type enumeration, used to indicate relative drawing positions.</summary>
enum Enum
{
/// <summary>A default value for uninitialized coordinate types.</summary>
None = 0,
/// <summary>Positions::Origin (0,0) corresponds to the top left corner of the <b>screen</b>.</summary>
Screen = 1,
/// <summary>Positions::Origin (0,0) corresponds to the top left corner of the <b>map</b>.</summary>
Map = 2,
/// <summary>Positions::Origin (0,0) corresponds to the location of the <b>mouse cursor</b>.</summary>
Mouse = 3,
};
}
}

View file

@ -1,70 +0,0 @@
#pragma once
#include <BWAPI/Type.h>
namespace BWAPI
{
/// <summary>Namespace containing damage types.</summary>
///
/// @see DamageType
///
/// [View on Liquipedia](http://wiki.teamliquid.net/starcraft/Damage_Type)<br>
/// [View on Starcraft Campendium (Official Website)](http://classic.battle.net/scc/gs/damage.shtml)<br>
/// [View on Starcraft Wikia](http://starcraft.wikia.com/wiki/Damage_types)<br>
namespace DamageTypes
{
/// <summary>Enumeration of damage types.</summary>
/// @see DamageType
namespace Enum
{
/// <summary>Enumeration of damage types.</summary>
/// @see DamageType
enum Enum
{
Independent,
Explosive,
Concussive,
Normal,
Ignore_Armor,
None,
Unknown,
MAX
};
}
}
/// <summary>Damage types are used in Broodwar to determine the amount of damage that will be
/// done to a unit.</summary> This corresponds with UnitSizeType to determine the damage done to
/// a unit.
///
/// @see WeaponType, DamageTypes, UnitSizeType
///
/// [View on Liquipedia](http://wiki.teamliquid.net/starcraft/Damage_Type)<br>
/// [View on Starcraft Campendium (Official Website)](http://classic.battle.net/scc/gs/damage.shtml)<br>
/// [View on Starcraft Wikia](http://starcraft.wikia.com/wiki/Damage_types)<br>
///
/// @ingroup TypeClasses
class DamageType : public Type<DamageType, DamageTypes::Enum::Unknown>
{
public:
/// @copydoc Type::Type(int)
DamageType(int id = DamageTypes::Enum::None);
};
/// @ingroup Types
namespace DamageTypes
{
/// <summary>Retrieves the set of all the DamageTypes.</summary>
///
/// @returns Set of DamageTypes.
const DamageType::set& allDamageTypes();
extern const DamageType Independent;
extern const DamageType Explosive;
extern const DamageType Concussive;
extern const DamageType Normal;
extern const DamageType Ignore_Armor;
extern const DamageType None;
extern const DamageType Unknown;
}
static_assert(sizeof(DamageType) == sizeof(int), "Expected type to resolve to primitive size.");
}

View file

@ -1,106 +0,0 @@
#pragma once
#include <BWAPI/Type.h>
#include <string>
namespace BWAPI
{
class UnitType;
/// <summary>Namespace containing error codes</summary>
/// @see Error
namespace Errors
{
/// <summary>Enumeration of Error types.</summary>
/// @see Error
namespace Enum
{
/// <summary>Enumeration of Error types.</summary>
/// @see Error
enum Enum
{
Unit_Does_Not_Exist,
Unit_Not_Visible,
Unit_Not_Owned,
Unit_Busy,
Incompatible_UnitType,
Incompatible_TechType,
Incompatible_State,
Already_Researched,
Fully_Upgraded,
Currently_Researching,
Currently_Upgrading,
Insufficient_Minerals,
Insufficient_Gas,
Insufficient_Supply,
Insufficient_Energy,
Insufficient_Tech,
Insufficient_Ammo,
Insufficient_Space,
Invalid_Tile_Position,
Unbuildable_Location,
Unreachable_Location,
Out_Of_Range,
Unable_To_Hit,
Access_Denied,
File_Not_Found,
Invalid_Parameter,
None,
Unknown,
MAX
};
};
};
/// <summary>The Error object is generally used to determine why certain functions in BWAPI
/// have failed.</summary>
///
/// For example, you may not have enough resources to construct a unit.
/// @see Game::getLastError, Game::setLastError, Errors
/// @ingroup TypeClasses
class Error : public Type<Error, Errors::Enum::Unknown>
{
public:
/// @copydoc Type::Type(int)
Error(int id = Errors::Enum::None);
};
/// @ingroup Types
namespace Errors
{
/// <summary>Retrieves the set of all the error codes.</summary>
///
/// @returns Set of error types.
const Error::set& allErrors();
extern const Error Unit_Does_Not_Exist;
extern const Error Unit_Not_Visible;
extern const Error Unit_Not_Owned;
extern const Error Unit_Busy;
extern const Error Incompatible_UnitType;
extern const Error Incompatible_TechType;
extern const Error Incompatible_State;
extern const Error Already_Researched;
extern const Error Fully_Upgraded;
extern const Error Currently_Researching;
extern const Error Currently_Upgrading;
extern const Error Insufficient_Minerals;
extern const Error Insufficient_Gas;
extern const Error Insufficient_Supply;
extern const Error Insufficient_Energy;
extern const Error Insufficient_Tech;
extern const Error Insufficient_Ammo;
extern const Error Insufficient_Space;
extern const Error Invalid_Tile_Position;
extern const Error Unbuildable_Location;
extern const Error Unreachable_Location;
extern const Error Out_Of_Range;
extern const Error Unable_To_Hit;
extern const Error Access_Denied;
extern const Error File_Not_Found;
extern const Error Invalid_Parameter;
extern const Error None;
extern const Error Unknown;
}
static_assert(sizeof(Error) == sizeof(int), "Expected type to resolve to primitive size.");
}

View file

@ -1,64 +0,0 @@
#pragma once
#include <BWAPI/Position.h>
#include <BWAPI/EventType.h>
#include <BWAPI/Unit.h>
#include <string>
namespace BWAPI
{
// Forward Declarations
class PlayerInterface;
typedef PlayerInterface* Player;
class Event
{
public:
Event() = default;
~Event();
Event(const Event& other);
Event(Event&& other);
Event& operator=(const Event& other);
Event& operator=(Event &&other);
bool operator==(const Event& other) const;
static Event MatchStart();
static Event MatchEnd(bool isWinner);
static Event MatchFrame();
static Event MenuFrame();
static Event SendText(const char* text = nullptr);
static Event ReceiveText(Player player, const char* text = nullptr);
static Event PlayerLeft(Player player);
static Event NukeDetect(Position target);
static Event UnitDiscover(Unit unit);
static Event UnitEvade(Unit unit);
static Event UnitShow(Unit unit);
static Event UnitHide(Unit unit);
static Event UnitCreate(Unit unit);
static Event UnitDestroy(Unit unit);
static Event UnitMorph(Unit unit);
static Event UnitRenegade(Unit unit);
static Event SaveGame(const char* gameName = nullptr);
static Event UnitComplete(Unit unit);
EventType::Enum getType() const;
Position getPosition() const;
const std::string& getText() const;
Unit getUnit() const;
Player getPlayer() const;
bool isWinner() const;
Event& setType(EventType::Enum type);
Event& setPosition(Position position);
Event& setText(const char* text);
Event& setUnit(Unit unit);
Event& setPlayer(Player player);
Event& setWinner(bool isWinner);
//static Event TriggerAction();
private:
Position position = Positions::None;
std::string* text = nullptr;
Unit unit = nullptr;
Player player = nullptr;
EventType::Enum type = EventType::None;
bool winner = false;
};
}

View file

@ -1,32 +0,0 @@
#pragma once
namespace BWAPI
{
/// <summary>Contains a list of event types supported by BWAPI.</summary>
namespace EventType
{
/// <summary>Enumeration of callback event types.</summary>
enum Enum
{
MatchStart,
MatchEnd,
MatchFrame,
MenuFrame,
SendText,
ReceiveText,
PlayerLeft,
NukeDetect,
UnitDiscover,
UnitEvade,
UnitShow,
UnitHide,
UnitCreate,
UnitDestroy,
UnitMorph,
UnitRenegade,
SaveGame,
UnitComplete,
//TriggerAction,
None
};
}
}

View file

@ -1,96 +0,0 @@
#pragma once
#include <BWAPI/Type.h>
namespace BWAPI
{
/// <summary>Namespace containing explosion types.</summary>
/// @see ExplosionType
namespace ExplosionTypes
{
/// <summary>Enumeration of explosion types.</summary>
/// @see ExplosionType
namespace Enum
{
/// <summary>Enumeration of explosion types.</summary>
/// @see ExplosionType
enum Enum
{
None = 0,
Normal,
Radial_Splash,
Enemy_Splash,
Lockdown,
Nuclear_Missile,
Parasite,
Broodlings,
EMP_Shockwave,
Irradiate,
Ensnare,
Plague,
Stasis_Field,
Dark_Swarm,
Consume,
Yamato_Gun,
Restoration,
Disruption_Web,
Corrosive_Acid,
Mind_Control,
Feedback,
Optical_Flare,
Maelstrom,
Unused,
Air_Splash,
Unknown,
MAX
};
};
};
/// <summary>A representation of a weapon's explosion type.</summary> This indicates how the
/// weapon behaves, such as if it deals splash damage or causes an effect to occur.
///
/// @see ExplosionTypes
/// @ingroup TypeClasses
class ExplosionType : public Type<ExplosionType, ExplosionTypes::Enum::Unknown>
{
public:
/// @copydoc Type::Type(int)
ExplosionType(int id = ExplosionTypes::Enum::None);
};
/// @ingroup Types
namespace ExplosionTypes
{
/// <summary>Retrieves the set of all valid ExplosionTypes.</summary>
///
/// @returns Set of ExplosionTypes.
const ExplosionType::set& allExplosionTypes();
extern const ExplosionType None;
extern const ExplosionType Normal;
extern const ExplosionType Radial_Splash;
extern const ExplosionType Enemy_Splash;
extern const ExplosionType Lockdown;
extern const ExplosionType Nuclear_Missile;
extern const ExplosionType Parasite;
extern const ExplosionType Broodlings;
extern const ExplosionType EMP_Shockwave;
extern const ExplosionType Irradiate;
extern const ExplosionType Ensnare;
extern const ExplosionType Plague;
extern const ExplosionType Stasis_Field;
extern const ExplosionType Dark_Swarm;
extern const ExplosionType Consume;
extern const ExplosionType Yamato_Gun;
extern const ExplosionType Restoration;
extern const ExplosionType Disruption_Web;
extern const ExplosionType Corrosive_Acid;
extern const ExplosionType Mind_Control;
extern const ExplosionType Feedback;
extern const ExplosionType Optical_Flare;
extern const ExplosionType Maelstrom;
extern const ExplosionType Air_Splash;
extern const ExplosionType Unknown;
}
static_assert(sizeof(ExplosionType) == sizeof(int), "Expected type to resolve to primitive size.");
}

View file

@ -1,476 +0,0 @@
#pragma once
#include <BWAPI/UnaryFilter.h>
#include <BWAPI/ComparisonFilter.h>
#include <BWAPI/BestFilter.h>
#include <BWAPI/UnitSizeType.h>
#include <BWAPI/UpgradeType.h>
#include <BWAPI/WeaponType.h>
#include <BWAPI/Order.h>
#include <BWAPI/Race.h>
namespace BWAPI
{
// forwards
class PlayerInterface;
typedef PlayerInterface *Player;
class UnitType;
class UnitInterface;
typedef UnitInterface *Unit;
// typedefs
typedef UnaryFilter<Unit > UnitFilter;
typedef UnaryFilter<Unit ,bool (*)(Unit )> PtrUnitFilter;
typedef BestFilter<Unit > BestUnitFilter;
typedef CompareFilter<Unit ,int,int(*)(Unit )> PtrIntCompareUnitFilter;
namespace Filter
{
/// <summary>A unary filter that checks if the unit type is a transport.</summary>
extern const PtrUnitFilter IsTransport;
/// @see BWAPI::UnitType::canProduce
extern const PtrUnitFilter CanProduce;
/// @see BWAPI::UnitType::canAttack
extern const PtrUnitFilter CanAttack;
/// @see BWAPI::UnitType::canMove
extern const PtrUnitFilter CanMove;
/// @see BWAPI::UnitType::isFlying
extern const PtrUnitFilter IsFlyer;
/// @see BWAPI::UnitInterface::IsFlying
extern const PtrUnitFilter IsFlying;
/// @see BWAPI::UnitType::regeneratesHP
extern const PtrUnitFilter RegeneratesHP;
/// @see BWAPI::UnitType::isSpellcaster
extern const PtrUnitFilter IsSpellcaster;
/// @see BWAPI::UnitType::hasPermanentCloak
extern const PtrUnitFilter HasPermanentCloak;
/// @see BWAPI::UnitType::isOrganic
extern const PtrUnitFilter IsOrganic;
/// @see BWAPI::UnitType::isMechanical
extern const PtrUnitFilter IsMechanical;
/// @see BWAPI::UnitType::isRobotic
extern const PtrUnitFilter IsRobotic;
/// @see BWAPI::UnitType::isDetector
extern const PtrUnitFilter IsDetector;
/// @see BWAPI::UnitType::isResourceContainer
extern const PtrUnitFilter IsResourceContainer;
/// @see BWAPI::UnitType::isResourceDepot
extern const PtrUnitFilter IsResourceDepot;
/// @see BWAPI::UnitType::isRefinery
extern const PtrUnitFilter IsRefinery;
/// @see BWAPI::UnitType::isWorker
extern const PtrUnitFilter IsWorker;
/// @see BWAPI::UnitType::requiresPsi
extern const PtrUnitFilter RequiresPsi;
/// @see BWAPI::UnitType::requiresCreep
extern const PtrUnitFilter RequiresCreep;
/// @see BWAPI::UnitType::isBurrowable
extern const PtrUnitFilter IsBurrowable;
/// @see BWAPI::UnitType::isCloakable
extern const PtrUnitFilter IsCloakable;
/// @see BWAPI::UnitType::isBuilding
extern const PtrUnitFilter IsBuilding;
/// @see BWAPI::UnitType::isAddon
extern const PtrUnitFilter IsAddon;
/// @see BWAPI::UnitType::isFlyingBuilding
extern const PtrUnitFilter IsFlyingBuilding;
/// @see BWAPI::UnitType::isNeutral
extern const PtrUnitFilter IsNeutral;
/// @see BWAPI::UnitType::isHero
extern const PtrUnitFilter IsHero;
/// @see BWAPI::UnitType::isPowerup
extern const PtrUnitFilter IsPowerup;
/// @see BWAPI::UnitType::isBeacon
extern const PtrUnitFilter IsBeacon;
/// @see BWAPI::UnitType::isFlagBeacon
extern const PtrUnitFilter IsFlagBeacon;
/// @see BWAPI::UnitType::isSpecialBuilding
extern const PtrUnitFilter IsSpecialBuilding;
/// @see BWAPI::UnitType::isSpell
extern const PtrUnitFilter IsSpell;
/// @see BWAPI::UnitType::producesLarva
extern const PtrUnitFilter ProducesLarva;
/// @see BWAPI::UnitType::isMineralField
extern const PtrUnitFilter IsMineralField;
/// @see BWAPI::UnitType::isCritter
extern const PtrUnitFilter IsCritter;
/// @see BWAPI::UnitType::canBuildAddon
extern const PtrUnitFilter CanBuildAddon;
/// @see BWAPI::UnitInterface::getHitPoints
extern const PtrIntCompareUnitFilter HP;
/// @see BWAPI::UnitType::maxHitPoints
extern const PtrIntCompareUnitFilter MaxHP;
/// <summary>A comparison filter that retrieves the unit's HP percentage.</summary> The formula
/// is HP*100/MaxHP.
extern const PtrIntCompareUnitFilter HP_Percent;
/// @see BWAPI::UnitInterface::getShields
extern const PtrIntCompareUnitFilter Shields;
/// @see BWAPI::UnitType::maxShields
extern const PtrIntCompareUnitFilter MaxShields;
/// <summary>A comparison filter that retrieves the unit's shields percentage.</summary> The
/// formula is Shields*100/MaxShields.
extern const PtrIntCompareUnitFilter Shields_Percent;
/// @see BWAPI::UnitInterface::getEnergy
extern const PtrIntCompareUnitFilter Energy;
/// @see BWAPI::PlayerInterface::maxEnergy
extern const PtrIntCompareUnitFilter MaxEnergy;
/// <summary>A comparison filter that retrieves the unit's energy percentage.</summary> The
/// formula is Energy*100/MaxEnergy.
extern const PtrIntCompareUnitFilter Energy_Percent;
/// @see BWAPI::PlayerInterface::armor
extern const PtrIntCompareUnitFilter Armor;
/// @see BWAPI::UnitType::armorUpgrade
extern const CompareFilter<Unit ,UpgradeType,UpgradeType (*)(Unit )> ArmorUpgrade;
/// @see BWAPI::UnitType::mineralPrice
extern const PtrIntCompareUnitFilter MineralPrice;
/// @see BWAPI::UnitType::gasPrice
extern const PtrIntCompareUnitFilter GasPrice;
/// @see BWAPI::UnitType::buildTime
extern const PtrIntCompareUnitFilter BuildTime;
/// @see BWAPI::UnitType::supplyRequired
extern const PtrIntCompareUnitFilter SupplyRequired;
/// @see BWAPI::UnitType::supplyProvided
extern const PtrIntCompareUnitFilter SupplyProvided;
/// @see BWAPI::UnitType::spaceRequired
extern const PtrIntCompareUnitFilter SpaceRequired;
/// @see BWAPI::UnitInterface::getSpaceRemaining
extern const PtrIntCompareUnitFilter SpaceRemaining;
/// @see BWAPI::UnitType::spaceProvided
extern const PtrIntCompareUnitFilter SpaceProvided;
/// @see BWAPI::UnitType::buildScore
extern const PtrIntCompareUnitFilter BuildScore;
/// @see BWAPI::UnitType::destroyScore
extern const PtrIntCompareUnitFilter DestroyScore;
/// @see BWAPI::PlayerInterface::topSpeed
extern const CompareFilter<Unit ,double,double (*)(Unit )> TopSpeed;
/// @see BWAPI::PlayerInterface::sightRange
extern const PtrIntCompareUnitFilter SightRange;
/// @see BWAPI::PlayerInterface::weaponDamageCooldown
extern const PtrIntCompareUnitFilter WeaponCooldown;
/// @see BWAPI::UnitType::size
extern const CompareFilter<Unit ,UnitSizeType,UnitSizeType (*)(Unit )> SizeType;
/// @see BWAPI::UnitType::groundWeapon
extern const CompareFilter<Unit ,WeaponType,WeaponType (*)(Unit )> GroundWeapon;
/// @see BWAPI::UnitType::airWeapon
extern const CompareFilter<Unit ,WeaponType,WeaponType (*)(Unit )> AirWeapon;
/// @see BWAPI::UnitInterface::getType
extern const CompareFilter<Unit ,UnitType,UnitType (*)(Unit )> GetType;
/// @see BWAPI::UnitType::getRace
extern const CompareFilter<Unit ,Race,Race (*)(Unit )> GetRace;
/// @see BWAPI::UnitInterface::getPlayer
extern const CompareFilter<Unit ,Player,Player (*)(Unit )> GetPlayer;
/// @see BWAPI::UnitInterface::getResources
extern const PtrIntCompareUnitFilter Resources;
/// @see BWAPI::UnitInterface::getResourceGroup
extern const PtrIntCompareUnitFilter ResourceGroup;
/// @see BWAPI::UnitInterface::getAcidSporeCount
extern const PtrIntCompareUnitFilter AcidSporeCount;
/// @see BWAPI::UnitInterface::getInterceptorCount
extern const PtrIntCompareUnitFilter InterceptorCount;
/// @see BWAPI::UnitInterface::getScarabCount
extern const PtrIntCompareUnitFilter ScarabCount;
/// @see BWAPI::UnitInterface::getSpiderMineCount
extern const PtrIntCompareUnitFilter SpiderMineCount;
/// @see BWAPI::UnitInterface::getGroundWeaponCooldown
extern const PtrIntCompareUnitFilter MaxWeaponCooldown;
/// @see BWAPI::UnitInterface::getSpellCooldown
extern const PtrIntCompareUnitFilter SpellCooldown;
/// @see BWAPI::UnitInterface::getDefenseMatrixPoints
extern const PtrIntCompareUnitFilter DefenseMatrixPoints;
/// @see BWAPI::UnitInterface::getDefenseMatrixTimer
extern const PtrIntCompareUnitFilter DefenseMatrixTime;
/// @see BWAPI::UnitInterface::getEnsnareTimer
extern const PtrIntCompareUnitFilter EnsnareTime;
/// @see BWAPI::UnitInterface::getIrradiateTimer
extern const PtrIntCompareUnitFilter IrradiateTime;
/// @see BWAPI::UnitInterface::getLockdownTimer
extern const PtrIntCompareUnitFilter LockdownTime;
/// @see BWAPI::UnitInterface::getMaelstromTimer
extern const PtrIntCompareUnitFilter MaelstromTime;
/// @see BWAPI::UnitInterface::getOrderTimer
extern const PtrIntCompareUnitFilter OrderTime;
/// @see BWAPI::UnitInterface::getPlagueTimer
extern const PtrIntCompareUnitFilter PlagueTimer;
/// @see BWAPI::UnitInterface::getRemoveTimer
extern const PtrIntCompareUnitFilter RemoveTime;
/// @see BWAPI::UnitInterface::getStasisTimer
extern const PtrIntCompareUnitFilter StasisTime;
/// @see BWAPI::UnitInterface::getStimTimer
extern const PtrIntCompareUnitFilter StimTime;
/// @see BWAPI::UnitInterface::getBuildType
extern const CompareFilter<Unit ,UnitType,UnitType (*)(Unit )> BuildType;
/// @see BWAPI::UnitInterface::getRemainingBuildTime
extern const PtrIntCompareUnitFilter RemainingBuildTime;
/// @see BWAPI::UnitInterface::getRemainingTrainTime
extern const PtrIntCompareUnitFilter RemainingTrainTime;
/// @see BWAPI::UnitInterface::getTarget
extern const CompareFilter<Unit ,Unit ,Unit (*)(Unit )> Target;
/// @see BWAPI::UnitInterface::getOrder
extern const CompareFilter<Unit ,Order,Order (*)(Unit )> CurrentOrder;
/// @see BWAPI::UnitInterface::getSecondaryOrder
extern const CompareFilter<Unit ,Order,Order (*)(Unit )> SecondaryOrder;
/// @see BWAPI::UnitInterface::getOrderTarget
extern const CompareFilter<Unit ,Unit ,Unit (*)(Unit )> OrderTarget;
/// @see BWAPI::UnitInterface::getLeft
extern const PtrIntCompareUnitFilter GetLeft;
/// @see BWAPI::UnitInterface::getTop
extern const PtrIntCompareUnitFilter GetTop;
/// @see BWAPI::UnitInterface::getRight
extern const PtrIntCompareUnitFilter GetRight;
/// @see BWAPI::UnitInterface::getBottom
extern const PtrIntCompareUnitFilter GetBottom;
/// @see BWAPI::UnitInterface::exists
extern const PtrUnitFilter Exists;
/// @see BWAPI::UnitInterface::isAttacking
extern const PtrUnitFilter IsAttacking;
/// @see BWAPI::UnitInterface::isBeingConstructed
extern const PtrUnitFilter IsBeingConstructed;
/// @see BWAPI::UnitInterface::isBeingGathered
extern const PtrUnitFilter IsBeingGathered;
/// @see BWAPI::UnitInterface::isBeingHealed
extern const PtrUnitFilter IsBeingHealed;
/// @see BWAPI::UnitInterface::isBlind
extern const PtrUnitFilter IsBlind;
/// @see BWAPI::UnitInterface::isBraking
extern const PtrUnitFilter IsBraking;
/// @see BWAPI::UnitInterface::isBurrowed
extern const PtrUnitFilter IsBurrowed;
/// @see BWAPI::UnitInterface::isCarryingGas
extern const PtrUnitFilter IsCarryingGas;
/// @see BWAPI::UnitInterface::isCarryingMinerals
extern const PtrUnitFilter IsCarryingMinerals;
/// <summary>A unary filter that checks if IsCarryingGas or IsCarryingMinerals return true.</summary>
extern const PtrUnitFilter IsCarryingSomething;
/// @see BWAPI::UnitInterface::isCloaked
extern const PtrUnitFilter IsCloaked;
/// @see BWAPI::UnitInterface::isCompleted
extern const PtrUnitFilter IsCompleted;
/// @see BWAPI::UnitInterface::isConstructing
extern const PtrUnitFilter IsConstructing;
/// @see BWAPI::UnitInterface::isDefenseMatrixed
extern const PtrUnitFilter IsDefenseMatrixed;
/// @see BWAPI::UnitInterface::isDetected
extern const PtrUnitFilter IsDetected;
/// @see BWAPI::UnitInterface::isEnsnared
extern const PtrUnitFilter IsEnsnared;
/// @see BWAPI::UnitInterface::isFollowing
extern const PtrUnitFilter IsFollowing;
/// @see BWAPI::UnitInterface::isGatheringGas
extern const PtrUnitFilter IsGatheringGas;
/// @see BWAPI::UnitInterface::isGatheringMinerals
extern const PtrUnitFilter IsGatheringMinerals;
/// @see BWAPI::UnitInterface::isHallucination
extern const PtrUnitFilter IsHallucination;
/// @see BWAPI::UnitInterface::isHoldingPosition
extern const PtrUnitFilter IsHoldingPosition;
/// @see BWAPI::UnitInterface::isIdle
extern const PtrUnitFilter IsIdle;
/// @see BWAPI::UnitInterface::isInterruptible
extern const PtrUnitFilter IsInterruptible;
/// @see BWAPI::UnitInterface::isInvincible
extern const PtrUnitFilter IsInvincible;
/// @see BWAPI::UnitInterface::isIrradiated
extern const PtrUnitFilter IsIrradiated;
/// @see BWAPI::UnitInterface::isLifted
extern const PtrUnitFilter IsLifted;
/// @see BWAPI::UnitInterface::isLoaded
extern const PtrUnitFilter IsLoaded;
/// @see BWAPI::UnitInterface::isLockedDown
extern const PtrUnitFilter IsLockedDown;
/// @see BWAPI::UnitInterface::isMaelstrommed
extern const PtrUnitFilter IsMaelstrommed;
/// @see BWAPI::UnitInterface::isMorphing
extern const PtrUnitFilter IsMorphing;
/// @see BWAPI::UnitInterface::isMoving
extern const PtrUnitFilter IsMoving;
/// @see BWAPI::UnitInterface::isParasited
extern const PtrUnitFilter IsParasited;
/// @see BWAPI::UnitInterface::isPatrolling
extern const PtrUnitFilter IsPatrolling;
/// @see BWAPI::UnitInterface::isPlagued
extern const PtrUnitFilter IsPlagued;
/// @see BWAPI::UnitInterface::isRepairing
extern const PtrUnitFilter IsRepairing;
/// @see BWAPI::UnitInterface::isResearching
extern const PtrUnitFilter IsResearching;
/// @see BWAPI::UnitInterface::isSieged
extern const PtrUnitFilter IsSieged;
/// @see BWAPI::UnitInterface::isStartingAttack
extern const PtrUnitFilter IsStartingAttack;
/// @see BWAPI::UnitInterface::isStasised
extern const PtrUnitFilter IsStasised;
/// @see BWAPI::UnitInterface::isStimmed
extern const PtrUnitFilter IsStimmed;
/// @see BWAPI::UnitInterface::isStuck
extern const PtrUnitFilter IsStuck;
/// @see BWAPI::UnitInterface::isTraining
extern const PtrUnitFilter IsTraining;
/// @see BWAPI::UnitInterface::isUnderAttack
extern const PtrUnitFilter IsUnderAttack;
/// @see BWAPI::UnitInterface::isUnderDarkSwarm
extern const PtrUnitFilter IsUnderDarkSwarm;
/// @see BWAPI::UnitInterface::isUnderDisruptionWeb
extern const PtrUnitFilter IsUnderDisruptionWeb;
/// @see BWAPI::UnitInterface::isUnderStorm
extern const PtrUnitFilter IsUnderStorm;
/// @see BWAPI::UnitInterface::isPowered
extern const PtrUnitFilter IsPowered;
/// @see BWAPI::UnitInterface::isVisible
extern const PtrUnitFilter IsVisible;
/// <summary>A unary filter that checks if the current unit is an enemy of the BWAPI player.</summary>
/// @note This will always be false when the BWAPI Player is unspecified, such as in a replay.
extern const PtrUnitFilter IsEnemy;
/// <summary>A unary filter that checks if the current unit is an ally of the BWAPI player.</summary>
/// @note This will always be false when the BWAPI Player is unspecified, such as in a replay.
extern const PtrUnitFilter IsAlly;
/// <summary>A unary filter that checks if the current unit is owned by the BWAPI player.</summary>
/// @note This will always be false when the BWAPI Player is unspecified, such as in a replay.
extern const PtrUnitFilter IsOwned;
}
}

View file

@ -1,23 +0,0 @@
#pragma once
namespace BWAPI
{
/// <summary>Contains flag enumerations for BWAPI.</summary>
/// @see Game::enableFlag, Game::isFlagEnabled
namespace Flag
{
/// <summary>Contains flag enumerations for BWAPI.</summary>
/// @see Game::enableFlag, Game::isFlagEnabled
enum Enum
{
/// <summary>Enable to get information about all units on the map, not just the visible units.</summary>
CompleteMapInformation = 0,
/// <summary>Enable to get information from the user (what units are selected, chat messages
/// the user enters, etc)</summary>
UserInput = 1,
/// <summary>The maximum number of different flags available.</summary>
Max
};
}
}

View file

@ -1,65 +0,0 @@
#pragma once
#include <string>
#include <BWAPI/Interface.h>
namespace BWAPI
{
// Forward Declarations
class Playerset;
class ForceInterface;
typedef ForceInterface *Force;
/// <summary>The Force class is used to get information about each force in a match.</summary>
/// 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.
///
/// @ingroup Interface
class ForceInterface : public Interface<ForceInterface>
{
protected:
virtual ~ForceInterface() {};
public :
/// <summary>Retrieves the unique ID that represents this Force.</summary>
///
/// @returns
/// An integer containing the ID for the Force.
virtual int getID() const = 0;
/// <summary>Retrieves the name of the Force.</summary>
///
/// @returns
/// A std::string object containing the name of the force.
///
/// Example usage:
/// @code
/// BWAPI::Force myForce = BWAPI::Broodwar->self()->getForce();
/// if ( myForce->getName() == "Observers" )
/// BWAPI::Broodwar << "Looks like we're observing a match." << std::endl;
/// @endcode
///
/// @note Don't forget to use std::string::c_str() when passing this parameter to
/// Game::sendText and other variadic functions.
virtual std::string getName() const = 0;
/// <summary>Retrieves the set of players that belong to this Force.</summary>
///
/// @returns
/// A Playerset object containing the players that are part of this Force.
///
/// Example usage:
/// @code
/// // 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;
/// }
/// @endcode
virtual Playerset getPlayers() const = 0;
};
}

View file

@ -1,22 +0,0 @@
#pragma once
#include "SetContainer.h"
namespace BWAPI
{
// Forward Declarations
class ForceInterface;
typedef ForceInterface *Force;
class Playerset;
/// <summary>A container that holds a group of Forces.</summary>
///
/// @see BWAPI::Force
class Forceset : public SetContainer<BWAPI::Force, std::hash<void*>>
{
public:
/// @copydoc ForceInterface::getPlayers
Playerset getPlayers() const;
};
}

File diff suppressed because it is too large Load diff

View file

@ -1,80 +0,0 @@
#pragma once
#include <BWAPI/Type.h>
namespace BWAPI
{
/// <summary>Namespace containing game types.</summary>
/// @see GameType
namespace GameTypes
{
/// <summary>Enumeration of game types.</summary>
/// @see GameType
namespace Enum
{
/// <summary>Enumeration of game types.</summary>
/// @see GameType
enum Enum
{
None = 0,
Custom, // Warcraft III
Melee,
Free_For_All,
One_on_One,
Capture_The_Flag,
Greed,
Slaughter,
Sudden_Death,
Ladder,
Use_Map_Settings,
Team_Melee,
Team_Free_For_All,
Team_Capture_The_Flag,
Unknown_0x0E,
Top_vs_Bottom,
Iron_Man_Ladder, // Warcraft II
Pro_Gamer_League = 32, // Not valid
Unknown,
MAX
};
};
};
/// <summary>A class that represents game types in Broodwar.</summary> A game type is selected
/// when creating a game.
///
/// @see GameTypes
/// @ingroup TypeClasses
class GameType : public Type<GameType, GameTypes::Enum::Unknown>
{
public:
/// @copydoc Type::Type(int)
GameType(int id = GameTypes::Enum::None);
};
/// @ingroup Types
namespace GameTypes
{
/// <summary>Retrieves the set of all the valid GameTypes.</summary>
///
/// @returns Set of available GameTypes.
const GameType::set& allGameTypes();
extern const GameType Melee;
extern const GameType Free_For_All;
extern const GameType One_on_One;
extern const GameType Capture_The_Flag;
extern const GameType Greed;
extern const GameType Slaughter;
extern const GameType Sudden_Death;
extern const GameType Ladder;
extern const GameType Use_Map_Settings;
extern const GameType Team_Melee;
extern const GameType Team_Free_For_All;
extern const GameType Team_Capture_The_Flag;
extern const GameType Top_vs_Bottom;
extern const GameType None;
extern const GameType Unknown;
}
static_assert(sizeof(GameType) == sizeof(int), "Expected type to resolve to primitive size.");
}

View file

@ -1,251 +0,0 @@
#pragma once
namespace BWAPI
{
/// <summary>An enumeration of mouse button inputs.</summary>
/// @see Game::getMouseState
enum MouseButton
{
M_LEFT = 0,
M_RIGHT,
M_MIDDLE,
M_MAX,
};
/// <summary>An enumeration of keyboard input values.</summary>
/// @see Game::getKeyState
enum Key
{
K_LBUTTON = 0x01,
K_RBUTTON,
K_CANCEL,
K_MBUTTON,
K_XBUTTON1,
K_XBUTTON2,
__UNDEFINED_7,
K_BACK,
K_TAB,
__RESERVED_A,
__RESERVED_B,
K_CLEAR,
K_RETURN,
__UNDEFINED_E,
__UNDEFINED_F,
K_SHIFT,
K_CONTROL,
K_MENU,
K_PAUSE,
K_CAPITAL,
K_KANA,
K_UNDEFINED_16,
K_JUNJA,
K_FINAL,
K_KANJI,
__UNDEFINED_1A,
K_ESCAPE,
K_CONVERT,
K_NONCONVERT,
K_ACCEPT,
K_MODECHANGE,
K_SPACE,
K_PRIOR,
K_NEXT,
K_END,
K_HOME,
K_LEFT,
K_UP,
K_RIGHT,
K_DOWN,
K_SELECT,
K_PRINT,
K_EXECUTE,
K_SNAPSHOT,
K_INSERT,
K_DELETE,
K_HELP,
K_0,
K_1,
K_2,
K_3,
K_4,
K_5,
K_6,
K_7,
K_8,
K_9,
__UNDEFINED_3A,
__UNDEFINED_3B,
__UNDEFINED_3C,
__UNDEFINED_3D,
__UNDEFINED_3E,
__UNDEFINED_3F,
__UNDEFINED_40,
K_A,
K_B,
K_C,
K_D,
K_E,
K_F,
K_G,
K_H,
K_I,
K_J,
K_K,
K_L,
K_M,
K_N,
K_O,
K_P,
K_Q,
K_R,
K_S,
K_T,
K_U,
K_V,
K_W,
K_X,
K_Y,
K_Z,
K_LWIN,
K_RWIN,
K_APPS,
__RESERVED_5E,
K_SLEEP,
K_NUMPAD0,
K_NUMPAD1,
K_NUMPAD2,
K_NUMPAD3,
K_NUMPAD4,
K_NUMPAD5,
K_NUMPAD6,
K_NUMPAD7,
K_NUMPAD8,
K_NUMPAD9,
K_MULTIPLY,
K_ADD,
K_SEPARATOR,
K_SUBTRACT,
K_DECIMAL,
K_DIVIDE,
K_F1,
K_F2,
K_F3,
K_F4,
K_F5,
K_F6,
K_F7,
K_F8,
K_F9,
K_F10,
K_F11,
K_F12,
K_F13,
K_F14,
K_F15,
K_F16,
K_F17,
K_F18,
K_F19,
K_F20,
K_F21,
K_F22,
K_F23,
K_F24,
__UNASSIGNED_88,
__UNASSIGNED_89,
__UNASSIGNED_8A,
__UNASSIGNED_8B,
__UNASSIGNED_8C,
__UNASSIGNED_8D,
__UNASSIGNED_8E,
__UNASSIGNED_8F,
K_NUMLOCK,
K_SCROLL,
K_OEM_NEC_EQUAL,
K_OEM_FJ_JISHO,
K_OEM_FJ_MASSHOU,
K_OEM_FJ_TOUROKU,
K_OEM_FJ_LOYA,
__UNASSIGNED_97,
__UNASSIGNED_98,
__UNASSIGNED_99,
__UNASSIGNED_9A,
__UNASSIGNED_9B,
__UNASSIGNED_9C,
__UNASSIGNED_9D,
__UNASSIGNED_9E,
__UNASSIGNED_9F,
K_LSHIFT,
K_RSHIFT,
K_LCONTROL,
K_RCONTROL,
K_LMENU,
K_RMENU,
K_BROWSER_BACK,
K_BROWSER_FORWARD,
K_BROWSER_REFRESH,
K_BROWSER_STOP,
K_BROWSER_SEARCH,
K_BROWSER_FAVORITES,
K_BROWSER_HOME,
K_VOLUME_MUTE,
K_VOLUME_DOWN,
K_VOLUME_UP,
K_MEDIA_NEXT_TRACK,
K_MEDIA_PREV_TRACK,
K_MEDIA_STOP,
K_MEDIA_PLAY_PAUSE,
K_LAUNCH_MAIL,
K_LAUNCH_MEDIA_SELECT,
K_LAUNCH_APP1,
K_LAUNCH_APP2,
__RESERVED_B8,
__RESERVED_B9,
K_OEM_1,
K_OEM_PLUS,
K_OEM_COMMA,
K_OEM_MINUS,
K_OEM_PERIOD,
K_OEM_2,
K_OEM_3,
K_OEM_4 = 0xDB,
K_OEM_5,
K_OEM_6,
K_OEM_7,
K_OEM_8,
__RESERVED_E0,
K_OEM_AX,
K_OEM_102,
K_ICO_HELP,
K_ICO_00,
K_PROCESSKEY,
K_ICO_CLEAR,
K_PACKET,
__UNASSIGNED_E8,
K_OEM_RESET,
K_OEM_JUMP,
K_OEM_PA1,
K_OEM_PA2,
K_OEM_PA3,
K_OEM_WSCTRL,
K_OEM_CUSEL,
K_OEM_ATTN,
K_OEM_FINISH,
K_OEM_COPY,
K_OEM_AUTO,
K_OEM_ENLW,
K_OEM_BACKTAB,
K_ATTN,
K_CRSEL,
K_EXSEL,
K_EREOF,
K_PLAY,
K_ZOOM,
K_NONAME,
K_PA1,
K_OEM_CLEAR,
K_MAX
};
}

View file

@ -1,129 +0,0 @@
#pragma once
#include <map>
#include <list>
#include <BWAPI/InterfaceEvent.h>
namespace BWAPI
{
/// <summary>This generalized class allows the application of features that are common to all interface
/// classes.</summary>
///
/// @tparam T
/// The class that inherits this interface.
template < typename T >
class Interface
{
protected:
/// @cond HIDDEN
Interface() = default;
virtual ~Interface() {};
std::map<int,void*> clientInfo;
std::list< InterfaceEvent<T> > interfaceEvents;
friend class GameImpl;
// Function manages events and updates it for the given frame
void updateEvents()
{
auto e = interfaceEvents.begin();
while ( e != interfaceEvents.end() )
{
if ( e->isFinished() )
{
e = interfaceEvents.erase(e);
}
else
{
e->execute(static_cast<T*>(this));
++e;
}
}
};
/// @endcond
public:
/// <summary>Retrieves a pointer or value at an index that was stored for this interface using
/// setClientInfo.</summary>
///
/// <param name="key">
/// The key containing the value to retrieve. Default is 0.
/// </param>
///
/// @retval nullptr if index is out of bounds.
/// @returns The client info at the given index.
/// @see setClientInfo
void *getClientInfo(int key = 0) const
{
// Retrieve iterator to element at index
auto result = this->clientInfo.find(key);
// Return a default value if not found
if ( result == this->clientInfo.end() )
return nullptr;
// return the desired value
return result->second;
};
template <typename CT>
CT getClientInfo(int key = 0) const
{
return (CT)(int)this->getClientInfo(key);
};
/// <summary>Associates one or more pointers or values with any BWAPI interface.</summary>
///
/// This client information is managed entirely by the AI module. It is not modified by BWAPI.
/// @warning If a pointer to allocated memory is used, then the AI module is responsible for
/// deallocating the memory when the game ends.
///
/// If client info at the given index has already been set, then it will be overwritten.
///
/// <param name="clientInfo">
/// The data to associate with this interface.
/// </param>
/// <param name="key">
/// The key to use for this data. Default is 0.
/// </param>
///
/// @see getClientInfo
template < typename V >
void setClientInfo(const V &clientInfo, int key = 0)
{
this->clientInfo[key] = (void*)clientInfo;
};
/// <summary>Registers an event and associates it with the current Interface object.</summary>
/// Events can be used to automate tasks (like train X @Marines until Y of them have been
/// created by the given @Barracks) or to create user-defined callbacks.
///
/// <param name="action">
/// The action callback to be executed when the event conditions are true. It is of type
/// void fn(T *inst) where fn is the function name and inst is a pointer to the instance of
/// the object performing the action.
/// </param>
/// <param name="condition"> (optional)
/// The condition callback which will return true if the action is intended to be executed.
/// It is of type bool fn(T *inst) where fn is the function name and inst is a pointer to the
/// instance of the object performing the check. The condition will always be true if omitted.
/// </param>
/// <param name="timesToRun"> (optional)
/// The number of times to execute the action before the event is removed. If the value is
/// negative, then the event will never be removed. The value will be -1 if omitted, causing
/// the event to execute until the game ends.
/// </param>
/// <param name="framesToCheck"> (optional)
/// The number of frames to skip between checks. If this value is 0, then a condition check is
/// made once per frame. If this value is 1, then the condition for this event is only checked
/// every other frame. This value is 0 by default, meaning the event's condition is checked
/// every frame.
/// </param>
void registerEvent(const std::function<void(T*)> &action, const std::function<bool(T*)> &condition = nullptr, int timesToRun = -1, int framesToCheck = 0)
{
interfaceEvents.push_back( InterfaceEvent<T>(action,condition,timesToRun,framesToCheck) );
};
};
}

View file

@ -1,112 +0,0 @@
#pragma once
#include <functional>
namespace BWAPI
{
/// <summary>The interface event is an attachment to BWAPI interfaces which allows the user to
/// register powerful conditional callbacks that can be executed a user-specified number of
/// times.</summary>
///
/// @tparam T
/// The interface that this class is being used for.
///
/// @see Interface::registerEvent
template < typename T >
class InterfaceEvent
{
public:
InterfaceEvent() = default;
/// <summary>This is the expected constructor for an interface event.</summary>
///
/// <param name="action">
/// An function callback that is run when all other conditions for this event are met.
/// </param>
/// <param name="condition"> (optioinal)
/// A function predicate that returns true if this event should be triggered.
/// </param>
/// <param name="timesToRun"> (optional)
/// The number of times that the action is called before this event is discarded. A value
/// of -1 means the event will never be discarded until the game has ended.
/// </param>
/// <param name="framesToCheck"> (optional)
/// The frequency that the event will check its condition at. A lower value indicates a
/// higher frequency. A value of 0 means that the condition is checked every frame.
/// A value of 10 means that the condition is checked once every 10 frames.
/// </param>
InterfaceEvent(const std::function<void(T*)> &action, const std::function<bool(T*)> &condition = nullptr, int timesToRun = -1, int framesToCheck = 0)
: condProc( condition )
, execProc( action )
, runFreq( framesToCheck )
, runCount( timesToRun )
, step( framesToCheck )
{};
/// <summary>Checks if the event has finished its execution and is marked for removal.</summary>
///
/// @returns true if the event has completed all runs and/or is marked for removal, otherwise
/// it returns false if the event should continue execution.
bool isFinished() const
{
return this->runCount == 0;
};
/// <summary>Marks the event for removal.</summary>
void removeEvent()
{
this->runCount = 0;
};
protected:
template < typename U >
friend class Interface;
// Function that runs the event, checkings its conditions and running its action, then
// decrementing the run count.
bool execute(T *instance)
{
// condition check
if ( !this->isConditionMet(instance) )
return false;
// There must be an exec proc!
if ( !this->execProc )
return false;
// execute
this->execProc(instance);
// Decrement run count (-1 being infinite)
if ( this->runCount > 0 )
--this->runCount;
return true;
};
// Function to check if the condition associated with the event is true. Includes frame and
// run count checking.
bool isConditionMet(T *instance)
{
// Validity check
if ( this->isFinished() )
return false;
// Frame check
--step;
if ( step > 0 )
return false;
this->step = this->runFreq;
// Conditional check
if ( this->condProc )
return this->condProc(instance);
return true; // always run if there is no conditional function
};
private:
// Data members
std::function<bool(T*)> condProc = nullptr;
std::function<void(T*)> execProc = nullptr;
int runFreq = 0; // Frequency of runs, in frames (0 means every frame, 1 means every other frame)
int runCount = 0; // Number of times that the action can occur (-1 being infinite)
int step = 0; // Current step. Executes when reaches 0, then reset to runFreq.
};
}

View file

@ -1,21 +0,0 @@
#pragma once
namespace BWAPI
{
/// <summary>Contains enumeration of known latency values.</summary>
/// @see Game::getLatency
namespace Latency
{
/// <summary>Contains enumeration of known latency values.</summary>
/// @see Game::getLatency
enum Enum
{
SinglePlayer = 2,
LanLow = 5,
LanMedium = 7,
LanHigh = 9,
BattlenetLow = 14,
BattlenetMedium = 19,
BattlenetHigh = 24
};
}
}

View file

@ -1,394 +0,0 @@
#pragma once
#include <BWAPI/Type.h>
namespace BWAPI
{
/// <summary>Namespace containing unit orders.</summary>
/// @see Order
namespace Orders
{
/// <summary>Enumeration of unit orders.</summary>
/// @see Order
namespace Enum
{
/// <summary>Enumeration of unit orders.</summary>
/// @see Order
enum Enum
{
Die,
Stop,
Guard,
PlayerGuard,
TurretGuard,
BunkerGuard,
Move,
ReaverStop,
Attack1,
Attack2,
AttackUnit,
AttackFixedRange,
AttackTile,
Hover,
AttackMove,
InfestedCommandCenter,
UnusedNothing,
UnusedPowerup,
TowerGuard,
TowerAttack,
VultureMine,
StayInRange,
TurretAttack,
Nothing,
Unused_24,
DroneStartBuild,
DroneBuild,
CastInfestation,
MoveToInfest,
InfestingCommandCenter,
PlaceBuilding,
PlaceProtossBuilding,
CreateProtossBuilding,
ConstructingBuilding,
Repair,
MoveToRepair,
PlaceAddon,
BuildAddon,
Train,
RallyPointUnit,
RallyPointTile,
ZergBirth,
ZergUnitMorph,
ZergBuildingMorph,
IncompleteBuilding,
IncompleteMorphing,
BuildNydusExit,
EnterNydusCanal,
IncompleteWarping,
Follow,
Carrier,
ReaverCarrierMove,
CarrierStop,
CarrierAttack,
CarrierMoveToAttack,
CarrierIgnore2,
CarrierFight,
CarrierHoldPosition,
Reaver,
ReaverAttack,
ReaverMoveToAttack,
ReaverFight,
ReaverHoldPosition,
TrainFighter,
InterceptorAttack,
ScarabAttack,
RechargeShieldsUnit,
RechargeShieldsBattery,
ShieldBattery,
InterceptorReturn,
DroneLand,
BuildingLand,
BuildingLiftOff,
DroneLiftOff,
LiftingOff,
ResearchTech,
Upgrade,
Larva,
SpawningLarva,
Harvest1,
Harvest2,
MoveToGas,
WaitForGas,
HarvestGas,
ReturnGas,
MoveToMinerals,
WaitForMinerals,
MiningMinerals,
Harvest3,
Harvest4,
ReturnMinerals,
Interrupted,
EnterTransport,
PickupIdle,
PickupTransport,
PickupBunker,
Pickup4,
PowerupIdle,
Sieging,
Unsieging,
WatchTarget,
InitCreepGrowth,
SpreadCreep,
StoppingCreepGrowth,
GuardianAspect,
ArchonWarp,
CompletingArchonSummon,
HoldPosition,
QueenHoldPosition,
Cloak,
Decloak,
Unload,
MoveUnload,
FireYamatoGun,
MoveToFireYamatoGun,
CastLockdown,
Burrowing,
Burrowed,
Unburrowing,
CastDarkSwarm,
CastParasite,
CastSpawnBroodlings,
CastEMPShockwave,
NukeWait,
NukeTrain,
NukeLaunch,
NukePaint,
NukeUnit,
CastNuclearStrike,
NukeTrack,
InitializeArbiter,
CloakNearbyUnits,
PlaceMine,
RightClickAction,
SuicideUnit,
SuicideLocation,
SuicideHoldPosition,
CastRecall,
Teleport,
CastScannerSweep,
Scanner,
CastDefensiveMatrix,
CastPsionicStorm,
CastIrradiate,
CastPlague,
CastConsume,
CastEnsnare,
CastStasisField,
CastHallucination,
Hallucination2,
ResetCollision,
ResetHarvestCollision,
Patrol,
CTFCOPInit,
CTFCOPStarted,
CTFCOP2,
ComputerAI,
AtkMoveEP,
HarassMove,
AIPatrol,
GuardPost,
RescuePassive,
Neutral,
ComputerReturn,
InitializePsiProvider,
SelfDestructing,
Critter,
HiddenGun,
OpenDoor,
CloseDoor,
HideTrap,
RevealTrap,
EnableDoodad,
DisableDoodad,
WarpIn,
Medic,
MedicHeal,
HealMove,
MedicHoldPosition,
MedicHealToIdle,
CastRestoration,
CastDisruptionWeb,
CastMindControl,
DarkArchonMeld,
CastFeedback,
CastOpticalFlare,
CastMaelstrom,
JunkYardDog,
Fatal,
None,
Unknown,
MAX
};
}
}
/// <summary>An Order (Order type) represents a Unit's current action and can be retrieved with
/// UnitInterface::getOrder.</summary> It can also be used to identify the current state of the
/// unit during command execution (gathering minerals can consist of Orders::MoveToMinerals,
/// Orders::WaitForMinerals, Orders::MiningMinerals, etc.).
///
/// @see UnitInterface::getOrder, Orders
/// @ingroup TypeClasses
class Order : public Type<Order, Orders::Enum::Unknown>
{
public:
/// @copydoc Type::Type(int)
Order(int id = Orders::Enum::None);
};
/// @ingroup Types
namespace Orders
{
/// <summary>Retrieves the set of all defined game orders.</summary>
///
/// @returns Set of all Order types.
const Order::set& allOrders();
extern const Order Die;
extern const Order Stop;
extern const Order Guard;
extern const Order PlayerGuard;
extern const Order TurretGuard;
extern const Order BunkerGuard;
extern const Order Move;
extern const Order AttackUnit;
extern const Order AttackTile;
extern const Order Hover;
extern const Order AttackMove;
extern const Order InfestedCommandCenter;
extern const Order UnusedNothing;
extern const Order UnusedPowerup;
extern const Order TowerGuard;
extern const Order VultureMine;
extern const Order Nothing;
extern const Order CastInfestation;
extern const Order InfestingCommandCenter;
extern const Order PlaceBuilding;
extern const Order CreateProtossBuilding;
extern const Order ConstructingBuilding;
extern const Order Repair;
extern const Order PlaceAddon;
extern const Order BuildAddon;
extern const Order Train;
extern const Order RallyPointUnit;
extern const Order RallyPointTile;
extern const Order ZergBirth;
extern const Order ZergUnitMorph;
extern const Order ZergBuildingMorph;
extern const Order IncompleteBuilding;
extern const Order BuildNydusExit;
extern const Order EnterNydusCanal;
extern const Order Follow;
extern const Order Carrier;
extern const Order ReaverCarrierMove;
extern const Order CarrierIgnore2;
extern const Order Reaver;
extern const Order TrainFighter;
extern const Order InterceptorAttack;
extern const Order ScarabAttack;
extern const Order RechargeShieldsUnit;
extern const Order RechargeShieldsBattery;
extern const Order ShieldBattery;
extern const Order InterceptorReturn;
extern const Order BuildingLand;
extern const Order BuildingLiftOff;
extern const Order DroneLiftOff;
extern const Order LiftingOff;
extern const Order ResearchTech;
extern const Order Upgrade;
extern const Order Larva;
extern const Order SpawningLarva;
extern const Order Harvest1;
extern const Order Harvest2;
extern const Order MoveToGas;
extern const Order WaitForGas;
extern const Order HarvestGas;
extern const Order ReturnGas;
extern const Order MoveToMinerals;
extern const Order WaitForMinerals;
extern const Order MiningMinerals;
extern const Order Harvest3;
extern const Order Harvest4;
extern const Order ReturnMinerals;
extern const Order Interrupted;
extern const Order EnterTransport;
extern const Order PickupIdle;
extern const Order PickupTransport;
extern const Order PickupBunker;
extern const Order Pickup4;
extern const Order PowerupIdle;
extern const Order Sieging;
extern const Order Unsieging;
extern const Order InitCreepGrowth;
extern const Order SpreadCreep;
extern const Order StoppingCreepGrowth;
extern const Order GuardianAspect;
extern const Order ArchonWarp;
extern const Order CompletingArchonSummon;
extern const Order HoldPosition;
extern const Order Cloak;
extern const Order Decloak;
extern const Order Unload;
extern const Order MoveUnload;
extern const Order FireYamatoGun;
extern const Order CastLockdown;
extern const Order Burrowing;
extern const Order Burrowed;
extern const Order Unburrowing;
extern const Order CastDarkSwarm;
extern const Order CastParasite;
extern const Order CastSpawnBroodlings;
extern const Order CastEMPShockwave;
extern const Order NukeWait;
extern const Order NukeTrain;
extern const Order NukeLaunch;
extern const Order NukePaint;
extern const Order NukeUnit;
extern const Order CastNuclearStrike;
extern const Order NukeTrack;
extern const Order CloakNearbyUnits;
extern const Order PlaceMine;
extern const Order RightClickAction;
extern const Order CastRecall;
extern const Order Teleport;
extern const Order CastScannerSweep;
extern const Order Scanner;
extern const Order CastDefensiveMatrix;
extern const Order CastPsionicStorm;
extern const Order CastIrradiate;
extern const Order CastPlague;
extern const Order CastConsume;
extern const Order CastEnsnare;
extern const Order CastStasisField;
extern const Order CastHallucination;
extern const Order Hallucination2;
extern const Order ResetCollision;
extern const Order Patrol;
extern const Order CTFCOPInit;
extern const Order CTFCOPStarted;
extern const Order CTFCOP2;
extern const Order ComputerAI;
extern const Order AtkMoveEP;
extern const Order HarassMove;
extern const Order AIPatrol;
extern const Order GuardPost;
extern const Order RescuePassive;
extern const Order Neutral;
extern const Order ComputerReturn;
extern const Order SelfDestructing;
extern const Order Critter;
extern const Order HiddenGun;
extern const Order OpenDoor;
extern const Order CloseDoor;
extern const Order HideTrap;
extern const Order RevealTrap;
extern const Order EnableDoodad;
extern const Order DisableDoodad;
extern const Order WarpIn;
extern const Order Medic;
extern const Order MedicHeal;
extern const Order HealMove;
extern const Order MedicHealToIdle;
extern const Order CastRestoration;
extern const Order CastDisruptionWeb;
extern const Order CastMindControl;
extern const Order DarkArchonMeld;
extern const Order CastFeedback;
extern const Order CastOpticalFlare;
extern const Order CastMaelstrom;
extern const Order JunkYardDog;
extern const Order Fatal;
extern const Order None;
extern const Order Unknown;
};
static_assert(sizeof(Order) == sizeof(int), "Expected type to resolve to primitive size.");
}

View file

@ -1,643 +0,0 @@
#pragma once
#include <string>
#include <BWAPI/Position.h>
#include <BWAPI/Race.h>
#include <BWAPI/Filters.h>
#include <BWAPI/Interface.h>
#include <BWAPI/UnitType.h>
namespace BWAPI
{
// Forwards
class Color;
class ForceInterface;
typedef ForceInterface *Force;
class PlayerType;
class TechType;
class Unitset;
class UpgradeType;
class WeaponType;
struct PlayerData;
class PlayerInterface;
typedef PlayerInterface *Player;
/// <summary>The Player represents a unique controller in the game.</summary> Each player in
/// a match will have his or her own player instance. There is also a neutral player which owns
/// all the neutral units (such as mineral patches and vespene geysers).
///
/// @see Playerset, PlayerType, Race
/// @ingroup Interface
class PlayerInterface : public Interface<PlayerInterface>
{
protected:
virtual ~PlayerInterface() {};
public :
/// <summary>Retrieves a unique ID that represents the player.</summary>
///
/// @returns
/// An integer representing the ID of the player.
virtual int getID() const = 0;
/// <summary>Retrieves the name of the player.</summary>
///
/// @returns
/// A std::string object containing the player's name.
///
/// @note Don't forget to use std::string::c_str() when passing this parameter to
/// Game::sendText and other variadic functions.
///
/// Example usage:
/// @code
/// BWAPI::Player myEnemy = BWAPI::Broodwar->enemy();
/// if ( myEnemy != nullptr ) // Make sure there is an enemy!
/// BWAPI::Broodwar->sendText("Prepare to be crushed, %s!", myEnemy->getName().c_str());
/// @endcode
virtual std::string getName() const = 0;
/// <summary>Retrieves the set of all units that the player owns.</summary> This also includes
/// incomplete units.
///
/// @returns Reference to a Unitset containing the units.
///
/// @note This does not include units that are loaded into transports, @Bunkers, @Refineries,
/// @Assimilators, or @Extractors.
///
/// Example usage:
/// @code
/// Unitset myUnits = BWAPI::Broodwar->self()->getUnits();
/// for ( auto u = myUnits.begin(); u != myUnits.end(); ++u )
/// {
/// // Do something with your units
/// }
/// @endcode
virtual const Unitset &getUnits() const = 0;
/// <summary>Retrieves the race of the player.</summary> This allows you to change strategies
/// against different races, or generalize some commands for yourself.
///
/// @retval Races::Unknown If the player chose Races::Random when the game started and they
/// have not been seen.
///
/// @returns
/// The Race that the player is using.
///
/// Example usage:
/// @code
/// if ( BWAPI::Broodwar->enemy() )
/// {
/// BWAPI::Race enemyRace = BWAPI::Broodwar->enemy()->getRace();
/// if ( enemyRace == Races::Zerg )
/// BWAPI::Broodwar->sendText("Do you really think you can beat me with a zergling rush?");
/// }
/// @endcode
virtual Race getRace() const = 0;
/// <summary>Retrieves the player's controller type.</summary> This allows you to distinguish
/// betweeen computer and human players.
///
/// @returns
/// The PlayerType that identifies who is controlling a player.
///
/// @note Other players using BWAPI will be treated as a human player and return
/// PlayerTypes::Player.
///
/// @code
/// if ( BWAPI::Broodwar->enemy() )
/// {
/// if ( BWAPI::Broodwar->enemy()->getType() == PlayerTypes::Computer )
/// BWAPI::Broodwar << "Looks like something I can abuse!" << std::endl;
/// }
/// @endcode
virtual PlayerType getType() const = 0;
/// <summary>Retrieves the player's force.</summary> A force is the team that the player is
/// playing on.
///
/// @returns
/// The Force object that the player is part of.
virtual Force getForce() const = 0;
/// <summary>Checks if this player is allied to the specified player.</summary>
///
/// <param name="player">
/// The player to check alliance with.
/// </param>
///
/// @retval true if this player is allied with \p player .
/// @retval false if this player is not allied with \p player.
///
/// @note This function will also return false if this player is neutral or an observer, or
/// if \p player is neutral or an observer.
///
/// @see isEnemy
virtual bool isAlly(const Player player) const = 0;
/// <summary>Checks if this player is unallied to the specified player.</summary>
///
/// <param name="player">
/// The player to check alliance with.
/// </param>
///
/// @retval true if this player is allied with \p player .
/// @retval false if this player is not allied with \p player .
///
/// @note This function will also return false if this player is neutral or an observer, or if
/// \p player is neutral or an observer.
///
/// @see isAlly
virtual bool isEnemy(const Player player) const = 0;
/// <summary>Checks if this player is the neutral player.</summary>
///
/// @retval true if this player is the neutral player.
/// @retval false if this player is any other player.
virtual bool isNeutral() const = 0;
/// <summary>Retrieve's the player's starting location.</summary>
///
/// @returns
/// A TilePosition containing the position of the start location.
///
/// @retval TilePositions::None if the player does not have a start location.
/// @retval TilePositions::Unknown if an error occured while trying to retrieve the start
/// location.
///
/// @see Game::getStartLocations, Game::getLastError
virtual TilePosition getStartLocation() const = 0;
/// <summary>Checks if the player has achieved victory.</summary>
///
/// @returns true if this player has achieved victory, otherwise false
virtual bool isVictorious() const = 0;
/// <summary>Checks if the player has been defeated.</summary>
///
/// @returns true if the player is defeated, otherwise false
virtual bool isDefeated() const = 0;
/// <summary>Checks if the player has left the game.</summary>
///
/// @returns true if the player has left the game, otherwise false
virtual bool leftGame() const = 0;
/// <summary>Retrieves the current amount of minerals/ore that this player has.</summary>
///
/// @note This function will return 0 if the player is inaccessible.
///
/// @returns Amount of minerals that the player currently has for spending.
virtual int minerals() const = 0;
/// <summary>Retrieves the current amount of vespene gas that this player has.</summary>
///
/// @note This function will return 0 if the player is inaccessible.
///
/// @returns Amount of gas that the player currently has for spending.
virtual int gas() const = 0;
/// <summary>Retrieves the cumulative amount of minerals/ore that this player has gathered
/// since the beginning of the game, including the amount that the player starts the game
/// with (if any).</summary>
///
/// @note This function will return 0 if the player is inaccessible.
///
/// @returns Cumulative amount of minerals that the player has gathered.
virtual int gatheredMinerals() const = 0;
/// <summary>Retrieves the cumulative amount of vespene gas that this player has gathered since
/// the beginning of the game, including the amount that the player starts the game with (if
/// any).</summary>
///
/// @note This function will return 0 if the player is inaccessible.
///
/// @returns Cumulative amount of gas that the player has gathered.
virtual int gatheredGas() const = 0;
/// <summary>Retrieves the cumulative amount of minerals/ore that this player has spent on
/// repairing units since the beginning of the game.</summary> This function only applies to
/// @Terran players.
///
/// @note This function will return 0 if the player is inaccessible.
///
/// @returns Cumulative amount of minerals that the player has spent repairing.
virtual int repairedMinerals() const = 0;
/// <summary>Retrieves the cumulative amount of vespene gas that this player has spent on
/// repairing units since the beginning of the game.</summary> This function only applies to
/// @Terran players.
///
/// @note This function will return 0 if the player is inaccessible.
///
/// @returns Cumulative amount of gas that the player has spent repairing.
virtual int repairedGas() const = 0;
/// <summary>Retrieves the cumulative amount of minerals/ore that this player has gained from
/// refunding (cancelling) units and structures.</summary>
///
/// @note This function will return 0 if the player is inaccessible.
///
/// @returns Cumulative amount of minerals that the player has received from refunds.
virtual int refundedMinerals() const = 0;
/// <summary>Retrieves the cumulative amount of vespene gas that this player has gained from
/// refunding (cancelling) units and structures.</summary>
///
/// @note This function will return 0 if the player is inaccessible.
///
/// @returns Cumulative amount of gas that the player has received from refunds.
virtual int refundedGas() const = 0;
/// <summary>Retrieves the cumulative amount of minerals/ore that this player has spent,
/// excluding repairs.</summary>
///
/// @note This function will return 0 if the player is inaccessible.
///
/// @returns Cumulative amount of minerals that the player has spent.
virtual int spentMinerals() const = 0;
/// <summary>Retrieves the cumulative amount of vespene gas that this player has spent,
/// excluding repairs.</summary>
///
/// @note This function will return 0 if the player is inaccessible.
///
/// @returns Cumulative amount of gas that the player has spent.
virtual int spentGas() const = 0;
/// <summary>Retrieves the total amount of supply the player has available for unit control.</summary>
///
/// @note In Starcraft programming, the managed supply values are double than what they appear
/// in the game. The reason for this is because @Zerglings use 0.5 visible supply.
///
/// @note In Starcraft, the supply for each race is separate. Having a @Pylon and an @Overlord
/// will not give you 32 supply. It will instead give you 16 @Protoss supply and 16 @Zerg
/// supply.
///
/// <param name="race"> (optional)
/// The race to query the total supply for. If this is omitted, then the player's current
/// race will be used.
/// </param>
///
/// @returns The total supply available for this player and the given \p race.
///
/// Example usage:
/// @code
/// if ( BWAPI::Broodwar->self()->supplyUsed() + 8 >= BWAPI::Broodwar->self()->supplyTotal() )
/// {
/// // Construct pylons, supply depots, or overlords
/// }
/// @endcode
/// @see supplyUsed
virtual int supplyTotal(Race race = Races::None) const = 0;
/// <summary>Retrieves the current amount of supply that the player is using for unit control.</summary>
///
/// <param name="race"> (optional)
/// The race to query the used supply for. If this is omitted, then the player's current
/// race will be used.
/// </param>
///
/// @returns The supply that is in use for this player and the given \p race.
/// @see supplyTotal
virtual int supplyUsed(Race race = Races::None) const = 0;
/// <summary>Retrieves the total number of units that the player has.</summary> If the
/// information about the player is limited, then this function will only return the number
/// of visible units.
///
/// <param name="unit"> (optional)
/// The unit type to query. UnitType macros are accepted. If this parameter is omitted,
/// then it will use UnitTypes::AllUnits by default.
/// </param>
///
/// @returns The total number of units of the given type that the player owns.
/// @see visibleUnitCount, completedUnitCount, incompleteUnitCount
virtual int allUnitCount(UnitType unit = UnitTypes::AllUnits) const = 0;
/// <summary>Retrieves the total number of strictly visible units that the player has, even if
/// information on the player is unrestricted.</summary>
///
/// <param name="unit"> (optional)
/// The unit type to query. UnitType macros are accepted. If this parameter is omitted,
/// then it will use UnitTypes::AllUnits by default.
/// </param>
///
/// @returns The total number of units of the given type that the player owns, and is visible
/// to the BWAPI player.
/// @see allUnitCount, completedUnitCount, incompleteUnitCount
virtual int visibleUnitCount(UnitType unit = UnitTypes::AllUnits) const = 0;
/// <summary>Retrieves the number of completed units that the player has.</summary> If the
/// information about the player is limited, then this function will only return the number of
/// visible completed units.
///
/// <param name="unit"> (optional)
/// The unit type to query. UnitType macros are accepted. If this parameter is omitted,
/// then it will use UnitTypes::AllUnits by default.
/// </param>
///
/// @returns The number of completed units of the given type that the player owns.
///
/// Example usage:
/// @code
/// bool obtainNextUpgrade(BWAPI::UpgradeType upgType)
/// {
/// BWAPI::Player self = BWAPI::Broodwar->self();
/// int maxLvl = self->getMaxUpgradeLevel(upgType);
/// int currentLvl = self->getUpgradeLevel(upgType);
/// if ( !self->isUpgrading(upgType) && currentLvl < maxLvl &&
/// self->completedUnitCount(upgType.whatsRequired(currentLvl+1)) > 0 &&
/// self->completedUnitCount(upgType.whatUpgrades()) > 0 )
/// return self->getUnits().upgrade(upgType);
/// return false;
/// }
/// @endcode
///
/// @see allUnitCount, visibleUnitCount, incompleteUnitCount
virtual int completedUnitCount(UnitType unit = UnitTypes::AllUnits) const = 0;
/// <summary>Retrieves the number of incomplete units that the player has.</summary> If the
/// information about the player is limited, then this function will only return the number of
/// visible incomplete units.
///
/// @note This function is a macro for allUnitCount() - completedUnitCount().
///
/// <param name="unit"> (optional)
/// The unit type to query. UnitType macros are accepted. If this parameter is omitted,
/// then it will use UnitTypes::AllUnits by default.
/// </param>
///
/// @returns The number of incomplete units of the given type that the player owns.
/// @see allUnitCount, visibleUnitCount, completedUnitCount
int incompleteUnitCount(UnitType unit = UnitTypes::AllUnits) const;
/// <summary>Retrieves the number units that have died for this player.</summary>
///
/// <param name="unit"> (optional)
/// The unit type to query. UnitType macros are accepted. If this parameter is omitted,
/// then it will use UnitTypes::AllUnits by default.
/// </param>
///
/// @returns The total number of units that have died throughout the game.
virtual int deadUnitCount(UnitType unit = UnitTypes::AllUnits) const = 0;
/// <summary>Retrieves the number units that the player has killed.</summary>
///
/// <param name="unit"> (optional)
/// The unit type to query. UnitType macros are accepted. If this parameter is omitted,
/// then it will use UnitTypes::AllUnits by default.
/// </param>
///
/// @returns The total number of units that the player has killed throughout the game.
virtual int killedUnitCount(UnitType unit = UnitTypes::AllUnits) const = 0;
/// <summary>Retrieves the current upgrade level that the player has attained for a given
/// upgrade type.</summary>
///
/// <param name="upgrade">
/// The UpgradeType to query.
/// </param>
///
/// @returns The number of levels that the \p upgrade has been upgraded for this player.
///
/// Example usage:
/// @code
/// bool obtainNextUpgrade(BWAPI::UpgradeType upgType)
/// {
/// BWAPI::Player self = BWAPI::Broodwar->self();
/// int maxLvl = self->getMaxUpgradeLevel(upgType);
/// int currentLvl = self->getUpgradeLevel(upgType);
/// if ( !self->isUpgrading(upgType) && currentLvl < maxLvl &&
/// self->completedUnitCount(upgType.whatsRequired(currentLvl+1)) > 0 &&
/// self->completedUnitCount(upgType.whatUpgrades()) > 0 )
/// return self->getUnits().upgrade(upgType);
/// return false;
/// }
/// @endcode
///
/// @see UnitInterface::upgrade, getMaxUpgradeLevel
virtual int getUpgradeLevel(UpgradeType upgrade) const = 0;
/// <summary>Checks if the player has already researched a given technology.</summary>
///
/// <param name="tech">
/// The TechType to query.
/// </param>
///
/// @returns true if the player has obtained the given \p tech, or false if they have not
/// @see isResearching, UnitInterface::research, isResearchAvailable
virtual bool hasResearched(TechType tech) const = 0;
/// <summary>Checks if the player is researching a given technology type.</summary>
///
/// <param name="tech">
/// The TechType to query.
/// </param>
///
/// @returns true if the player is currently researching the \p tech, or false otherwise
/// @see UnitInterface::research, hasResearched
virtual bool isResearching(TechType tech) const = 0;
/// <summary>Checks if the player is upgrading a given upgrade type.</summary>
///
/// <param name="upgrade">
/// The upgrade type to query.
/// </param>
///
/// @returns true if the player is currently upgrading the given \p upgrade, false otherwise
///
/// Example usage:
/// @code
/// bool obtainNextUpgrade(BWAPI::UpgradeType upgType)
/// {
/// BWAPI::Player self = BWAPI::Broodwar->self();
/// int maxLvl = self->getMaxUpgradeLevel(upgType);
/// int currentLvl = self->getUpgradeLevel(upgType);
/// if ( !self->isUpgrading(upgType) && currentLvl < maxLvl &&
/// self->completedUnitCount(upgType.whatsRequired(currentLvl+1)) > 0 &&
/// self->completedUnitCount(upgType.whatUpgrades()) > 0 )
/// return self->getUnits().upgrade(upgType);
/// return false;
/// }
/// @endcode
///
/// @see UnitInterface::upgrade
virtual bool isUpgrading(UpgradeType upgrade) const = 0;
/// <summary>Retrieves the color value of the current player.</summary>
///
/// @returns Color object that represents the color of the current player.
virtual BWAPI::Color getColor() const = 0;
/// <summary>Retrieves the control code character that changes the color of text messages to
/// represent this player.</summary>
///
/// @returns character code to use for text in Broodwar.
char getTextColor() const;
/// <summary>Retrieves the maximum amount of energy that a unit type will have, taking the
/// player's energy upgrades into consideration.</summary>
///
/// <param name="unit">
/// The UnitType to retrieve the maximum energy for.
/// </param>
///
/// @returns Maximum amount of energy that the given unit type can have.
int maxEnergy(UnitType unit) const;
/// <summary>Retrieves the top speed of a unit type, taking the player's speed upgrades into
/// consideration.</summary>
///
/// <param name="unit">
/// The UnitType to retrieve the top speed for.
/// </param>
///
/// @returns Top speed of the provided unit type for this player.
double topSpeed(UnitType unit) const;
/// <summary>Retrieves the maximum weapon range of a weapon type, taking the player's weapon
/// upgrades into consideration.</summary>
///
/// <param name="weapon">
/// The WeaponType to retrieve the maximum range for.
/// </param>
///
/// @returns Maximum range of the given weapon type for units owned by this player.
int weaponMaxRange(WeaponType weapon) const;
/// <summary>Retrieves the sight range of a unit type, taking the player's sight range
/// upgrades into consideration.</summary>
///
/// <param name="unit">
/// The UnitType to retrieve the sight range for.
/// </param>
///
/// @returns Sight range of the provided unit type for this player.
int sightRange(UnitType unit) const;
/// <summary>Retrieves the weapon cooldown of a unit type, taking the player's attack speed
/// upgrades into consideration.</summary>
///
/// <param name="unit">
/// The UnitType to retrieve the damage cooldown for.
/// </param>
///
/// @returns Weapon cooldown of the provided unit type for this player.
int weaponDamageCooldown(UnitType unit) const;
/// <summary>Calculates the armor that a given unit type will have, including upgrades.</summary>
///
/// <param name="unit">
/// The unit type to calculate armor for, using the current player's upgrades.
/// </param>
///
/// @returns The amount of armor that the unit will have with the player's upgrades.
int armor(UnitType unit) const;
/// <summary>Calculates the damage that a given weapon type can deal, including upgrades.</summary>
///
/// <param name="wpn">
/// The weapon type to calculate for.
/// </param>
///
/// @returns The amount of damage that the weapon deals with this player's upgrades.
int damage(WeaponType wpn) const;
/// <summary>Retrieves the total unit score, as seen in the end-game score screen.</summary>
///
/// @returns The player's unit score.
virtual int getUnitScore() const = 0;
/// <summary>Retrieves the total kill score, as seen in the end-game score screen.</summary>
///
/// @returns The player's kill score.
virtual int getKillScore() const = 0;
/// <summary>Retrieves the total building score, as seen in the end-game score screen.</summary>
///
/// @returns The player's building score.
virtual int getBuildingScore() const = 0;
/// <summary>Retrieves the total razing score, as seen in the end-game score screen.</summary>
///
/// @returns The player's razing score.
virtual int getRazingScore() const = 0;
/// <summary>Retrieves the player's custom score.</summary> This score is used in @UMS game
/// types.
///
/// @returns The player's custom score.
virtual int getCustomScore() const = 0;
/// <summary>Checks if the player is an observer player, typically in a @UMS observer
/// game.</summary> An observer player does not participate in the game.
///
/// @returns true if the player is observing, or false if the player is capable of playing in
/// the game.
virtual bool isObserver() const = 0;
/// <summary>Retrieves the maximum upgrades available specific to the player.</summary> This
/// value is only different from UpgradeType::maxRepeats in @UMS games.
///
/// <param name="upgrade">
/// The UpgradeType to retrieve the maximum upgrade level for.
/// </param>
///
/// @returns Maximum upgrade level of the given \p upgrade type.
///
/// Example usage:
/// @code
/// bool obtainNextUpgrade(BWAPI::UpgradeType upgType)
/// {
/// BWAPI::Player self = BWAPI::Broodwar->self();
/// int maxLvl = self->getMaxUpgradeLevel(upgType);
/// int currentLvl = self->getUpgradeLevel(upgType);
/// if ( !self->isUpgrading(upgType) && currentLvl < maxLvl &&
/// self->completedUnitCount(upgType.whatsRequired(currentLvl+1)) > 0 &&
/// self->completedUnitCount(upgType.whatUpgrades()) > 0 )
/// return self->getUnits().upgrade(upgType);
/// return false;
/// }
/// @endcode
virtual int getMaxUpgradeLevel(UpgradeType upgrade) const = 0;
/// <summary>Checks if a technology can be researched by the player.</summary> Certain
/// technologies may be disabled in @UMS game types.
///
/// <param name="tech">
/// The TechType to query.
/// </param>
///
/// @returns true if the \p tech type is available to the player for research.
virtual bool isResearchAvailable(TechType tech) const = 0;
/// <summary>Checks if a unit type can be created by the player.</summary> Certain unit types
/// may be disabled in @UMS game types.
///
/// <param name="unit">
/// The UnitType to check.
/// </param>
///
/// @returns true if the \p unit type is available to the player.
virtual bool isUnitAvailable(UnitType unit) const = 0;
/// <summary>Verifies that this player satisfies a unit type requirement.</summary>
/// This verifies complex type requirements involving morphable @Zerg structures. For example,
/// if something requires a @Spire, but the player has (or is in the process of morphing) a
/// @Greater_Spire, this function will identify the requirement. It is simply a convenience function
/// that performs all of the requirement checks.
///
/// <param name="unit">
/// The UnitType to check.
/// </param>
/// <param name="amount"> (optional)
/// The amount of units that are required.
/// </param>
///
/// @returns true if the unit type requirements are met, and false otherwise.
///
/// @since 4.1.2
bool hasUnitTypeRequirement(UnitType unit, int amount = 1) const;
};
};

View file

@ -1,82 +0,0 @@
#pragma once
#include <BWAPI/Type.h>
namespace BWAPI
{
/// <summary>Namespace containing player types (player controllers).</summary>
/// @see PlayerType
namespace PlayerTypes
{
/// <summary>Enumeration of player types (player controllers).</summary>
/// @see PlayerType
namespace Enum
{
/// <summary>Enumeration of player types (player controllers).</summary>
/// @see PlayerType
enum Enum
{
None = 0,
Computer,
Player,
RescuePassive,
RescueActive,
EitherPreferComputer,
EitherPreferHuman,
Neutral,
Closed,
Observer,
PlayerLeft,
ComputerLeft,
Unknown,
MAX
};
};
};
/// <summary>Represents the type of controller for the player slot (i.e. human, computer).</summary>
///
/// @see PlayerTypes
/// @ingroup TypeClasses
class PlayerType : public Type<PlayerType, PlayerTypes::Enum::Unknown>
{
public:
/// @copydoc Type::Type(int)
PlayerType(int id = PlayerTypes::Enum::None);
/// <summary>Identifies whether or not this type is used for the pre-game lobby.</summary>
/// A type such as PlayerTypes::ComputerLeft would only appear in-game when a computer
/// player is defeated.
///
/// @returns true if this type can appear in the pre-game lobby, false otherwise.
bool isLobbyType() const;
/// <summary>Identifies whether or not this type is used in-game.</summary> A type such as
/// PlayerTypes::Closed would not be a valid in-game type.
///
/// @returns true if the type can appear in-game, false otherwise.
/// @see isLobbyType
bool isGameType() const;
};
/// @ingroup Types
namespace PlayerTypes
{
/// <summary>Retrieves the set of all the PlayerTypes.</summary>
///
/// @returns Set consisting of all valid PlayerTypes.
const PlayerType::set& allPlayerTypes();
extern const PlayerType None;
extern const PlayerType Computer;
extern const PlayerType Player;
extern const PlayerType RescuePassive;
extern const PlayerType EitherPreferComputer;
extern const PlayerType EitherPreferHuman;
extern const PlayerType Neutral;
extern const PlayerType Closed;
extern const PlayerType PlayerLeft;
extern const PlayerType ComputerLeft;
extern const PlayerType Unknown;
}
static_assert(sizeof(PlayerType) == sizeof(int), "Expected type to resolve to primitive size.");
}

View file

@ -1,45 +0,0 @@
#pragma once
#include "SetContainer.h"
#include <BWAPI/Race.h>
#include <BWAPI/Filters.h>
namespace BWAPI
{
// Forward Declarations
class PlayerInterface;
typedef PlayerInterface *Player;
class Unitset;
/// <summary>A set containing Player objects.</summary>
class Playerset : public SetContainer<BWAPI::Player, std::hash<void*>>
{
public:
/// <summary>Returns the set of all units that every player in this set owns.</summary>
///
/// @returns Unitset containing Playerset's units
/// @see PlayerInterface::getUnits
Unitset getUnits() const;
/// <summary>Returns the list of races that each player in the set is.</summary>
///
/// @returns Race::set containing Playerset's races
/// @see PlayerInterface::getRace
Race::set getRaces() const;
/// <summary>Sets the alliance status with all players contained in the Playerset.</summary>
///
/// <param name="allies">
/// Set to true to set the player to allied, or false for enemy.
/// </param>
/// <param name="alliedVictory">
/// Set to true to turn on allied victory, or false to disable it.
/// </param>
///
/// @see Game::setAlliance
void setAlliance(bool allies = true, bool alliedVictory = true);
};
}

View file

@ -1,435 +0,0 @@
#pragma once
#include <cmath>
#include <algorithm>
#include <tuple>
#include <deque>
#include <iostream>
namespace BWAPI
{
// Declaration
template<typename T, int Scale = 1>
class Point;
// Restrictions (no division by 0 or types too small to contain map positions)
template<typename T> class Point<T, 0> {};
template<int Scale> class Point<char, Scale> {};
template<int Scale> class Point<unsigned char, Scale> {};
template<int Scale> class Point<bool, Scale> {};
/// <summary>The Point class is a base class that implements convenience members and performs
/// conversions for several different position scales.</summary> It is intended to be inherited
/// or typedef'd for use with BWAPI. Users can extend the Point class, and implement their own
/// members, and it will remain compatible with BWAPI.
///
/// @tparam T
/// The underlying type of the x and y values. BWAPI uses int.
/// @tparam Scale
/// The underlying scale that this is intended to be used for. The smaller this value, the
/// higher the precision. A value of 1 indicates the pixel level.
///
/// Consider the following:
/// @code
/// class VectorPos : public BWAPI::Point<double, 1> // Same as BWAPI::Position with underlying type double
/// {
/// public:
/// VectorPos(double x_, double y_) : BWAPI::Point<double,1>(x_, y_) {}
/// // ... whatever members that operate with the underling type double
/// };
/// @endcode
///
/// It then follows that this code will work without incident:
/// @code
/// BWAPI::Unit myUnit; // assume that the unit is valid and assigned elsewhere
/// VectorPos myPos{5.7, 8.2};
/// myUnit->move(myPos); // Automatic type conversion, unit is moved to (5,8)
/// @endcode
///
/// @note For full compatibility with BWAPI, \p T must have a precision of at least 16 bits and
/// \p Scale must be a factor of 32.
template<typename T, int Scale>
class Point
{
public:
typedef std::deque< Point<T,Scale> > list;
Point() = default;
Point(T _x, T _y) : x(_x), y(_y) {}
/// <summary>A copy constructor for positions with different underlying types.</summary>
///
/// <param name="pt">
/// The Point to receive data from.
/// </param>
///
/// @tparam FromT
/// The type being converted to type T.
template<typename FromT> Point(const Point<FromT, Scale> &pt) : x( static_cast<T>(pt.x) ), y( static_cast<T>(pt.y) ) {}
#pragma warning( push )
#pragma warning( disable: 4723 )
/// <summary>A conversion copy constructor to convert positions of different scales to one
/// another.</summary>
///
/// @tparam FromT
/// The type that it is converting from.
/// @tparam FromScale
/// The scale that it is converting from.
template<typename FromT, int FromScale> explicit Point(const Point<FromT, FromScale> &pt)
: x(static_cast<T>(FromScale > Scale ? pt.x*(FromScale / Scale) : pt.x / (Scale / FromScale)))
, y(static_cast<T>(FromScale > Scale ? pt.y*(FromScale / Scale) : pt.y / (Scale / FromScale))) { }
#pragma warning( pop )
// Operators
/// <summary>A convenience for use with if statements to identify if a position is valid.</summary>
/// @see isValid
explicit operator bool() const { return this->isValid(); };
bool operator == (const Point<T,Scale> &pos) const
{
return std::tie(this->x, this->y) == std::tie(pos.x, pos.y);
};
bool operator != (const Point<T,Scale> &pos) const
{
return !(*this == pos);
};
/// <summary>A less than operator that enables positions to be used by additional STL containers.</summary>
/// Compares lexicographically the x position, followed by the y position.
bool operator < (const Point<T,Scale> &position) const
{
return std::tie(this->x, this->y) < std::tie(position.x, position.y);
};
inline Point<T, Scale> &operator += (const Point<T, Scale> &p)
{
x += p.x;
y += p.y;
return *this;
};
inline Point<T, Scale> operator + (const Point<T, Scale> &p) const
{
Point<T, Scale> r(*this);
return r += p;
};
inline Point<T, Scale> &operator -= (const Point<T, Scale> &p)
{
x -= p.x;
y -= p.y;
return *this;
};
inline Point<T, Scale> operator - (const Point<T, Scale> &p) const
{
Point<T, Scale> r(*this);
return r -= p;
};
inline Point<T, Scale> &operator *= (const T &v)
{
x *= v;
y *= v;
return *this;
};
inline Point<T, Scale> operator *(const T &v) const
{
Point<T, Scale> r(*this);
return r *= v;
};
inline Point<T, Scale> &operator |= (const T &v)
{
x |= v;
y |= v;
return *this;
};
inline Point<T, Scale> operator |(const T &v) const
{
Point<T, Scale> r(*this);
return r |= v;
};
inline Point<T, Scale> &operator &= (const T &v)
{
x &= v;
y &= v;
return *this;
};
inline Point<T, Scale> operator &(const T &v) const
{
Point<T, Scale> r(*this);
return r &= v;
};
inline Point<T, Scale> &operator ^= (const T &v)
{
x ^= v;
y ^= v;
return *this;
};
inline Point<T, Scale> operator ^(const T &v) const
{
Point<T, Scale> r(*this);
return r ^= v;
};
Point<T, Scale> operator / (const T &v) const
{
Point<T, Scale> result(*this);
return result /= v;
};
Point<T, Scale> &operator /= (const T &val)
{
if (val == 0) { x = 32000 / Scale; y = 32000 / Scale; }
else { x /= val; y /= val; }
return *this;
};
Point<T, Scale> operator %(const T &v) const
{
Point<T, Scale> result(*this);
return result %= v;
};
Point<T, Scale> &operator %= (const T &val)
{
if (val == 0) { x = 32000 / Scale; y = 32000 / Scale; }
else { x %= val; y %= val; }
return *this;
};
/// <summary>Ouput stream operator overload. Outputs the Point in the format "(x,y)" without
/// quotations.</summary>
///
/// <param name="out">
/// Output stream.
/// </param>
/// <param name="pt">
/// Point to output.
/// </param>
/// @returns Output stream \p out.
friend std::ostream &operator << (std::ostream &out, const Point<T, Scale> &pt)
{
return out << '(' << pt.x << ',' << pt.y << ')';
};
/// @overload
friend std::wostream &operator << (std::wostream &out, const Point<T, Scale> &pt)
{
return out << L'(' << pt.x << L',' << pt.y << L')';
};
/// <summary>Input stream operator overload. Reads the input in the form "x y" without
/// quotations.</summary> The x and y values are read as type T(typically int or float) and
/// stored into pt.
///
/// <param name="in">
/// The input stream.
/// </param>
/// <param name="pt">
/// The receiving variable.
/// </param>
/// @returns Input stream \p in.
friend std::istream &operator >> (std::istream &in, Point<T, Scale> &pt)
{
return in >> pt.x >> pt.y;
};
/// @overload
friend std::wistream &operator >> (std::wistream &in, Point<T, Scale> &pt)
{
return in >> pt.x >> pt.y;
};
/// <summary>Checks if this point is within the game's map bounds.</summary>
///
/// @note If the Broodwar pointer is not initialized, this function will check validity
/// against the largest (256x256) map size.
///
/// @retval true If it is a valid position and on the map/playing field.
/// @retval false If this is not a valid position.
///
/// @see makeValid
bool isValid() const;
/// <summary>Checks if this point is within the game's map bounds, if not, then it will set
/// the x and y values to be within map bounds.</summary> For example, if x is less than 0,
/// then x is set to 0.
///
/// @note If the Broodwar pointer is not initialized, this function will check validity
/// against the largest (256x256) map size.
///
/// @returns A reference to itself.
/// @see isValid
Point &makeValid();
/// <summary>Gets an accurate distance measurement from this point to the given position.</summary>
///
/// @note This function impedes performance. In most cases you should use getApproxDistance.
///
/// <param name="position">
/// The target position to get the distance to.
/// </param>
///
/// @returns A double representing the distance between this point and \p position.
/// @see getApproxDistance
double getDistance(const Point<T,Scale> &position) const
{
return ((*this) - position).getLength();
};
/// <summary>Gets the length of this point from the top left corner of the map.</summary>
///
/// @note This function impedes performance. In most cases you should use getApproxDistance.
///
/// @returns A double representing the length of this point from (0,0).
/// @see getApproxDistance
double getLength() const
{
double x = (double)this->x;
double y = (double)this->y;
return sqrt(x * x + y * y);
};
/// <summary>Retrieves the approximate distance using an algorithm from Starcraft: Broodwar.</summary>
///
/// @note This function is desired because it uses the same "imperfect" algorithm used in
/// Broodwar, so that calculations will be consistent with the game. It is also optimized
/// for performance.
///
/// <param name="position">
/// The target point to measure the distance to.
/// </param>
///
/// @returns An integer representing the distance between this point and \p position.
/// @see getDistance
int getApproxDistance(const Point<T,Scale> &position) const
{
unsigned int min = abs((int)(this->x - position.x));
unsigned int max = abs((int)(this->y - position.y));
if ( max < min )
std::swap(min, max);
if ( min < (max >> 2) )
return max;
unsigned int minCalc = (3*min) >> 3;
return (minCalc >> 5) + minCalc + max - (max >> 4) - (max >> 6);
};
/// <summary>Sets the maximum x and y values.</summary> If the current x or y values exceed
/// the given maximum, then values are set to the maximum.
///
/// <param name="max_x">
/// Maximum x value.
/// </param>
/// <param name="max_y">
/// Maximum y value.
/// </param>
///
/// @returns A reference to itself.
/// @see setMin
Point &setMax(T max_x, T max_y)
{
if ( x > max_x )
x = max_x;
if ( y > max_y )
y = max_y;
return *this;
};
/// @overload
Point &setMax(const Point<T,Scale> &max)
{
this->setMax(max.x, max.y);
return *this;
};
/// <summary>Sets the minimum x and y values.</summary> If the current x or y values are
/// below the given minimum, then values are set to the minimum.
///
/// <param name="min_x">
/// Minimum x value.
/// </param>
/// <param name="min_y">
/// Minimum y value.
/// </param>
///
/// @returns A reference to itself.
/// @see setMax
Point &setMin(T min_x, T min_y)
{
if ( x < min_x )
x = min_x;
if ( y < min_y )
y = min_y;
return *this;
};
/// @overload
Point &setMin(const Point<T,Scale> &min)
{
this->setMin(min.x, min.y);
return *this;
};
/// <summary>The x and y members for this class.</summary>
///
/// Simply reference these members when retrieving a position's x and y values.
T x = T{}, y = T{};
};
/// <summary>The scale of a @ref Position. Each position corresponds to a 1x1 pixel area.</summary>
/// @see Position
const int POSITION_SCALE = 1;
/// <summary>The scale of a @ref WalkPosition. Each walk position corresponds to an 8x8 pixel area.</summary>
/// @see WalkPosition
const int WALKPOSITION_SCALE = 8;
/// <summary>The scale of a @ref TilePosition. Each tile position corresponds to a 32x32 pixel area.</summary>
/// @see TilePosition
const int TILEPOSITION_SCALE = 32;
/// <summary>Indicates a position that is 1x1 pixel in size. This is the most precise position type.</summary>
/// @see Positions
typedef BWAPI::Point<int, POSITION_SCALE> Position;
/// <summary>List of special @ref Position constants.</summary>
namespace Positions
{
/// @hideinitializer
const Position Invalid{32000 / POSITION_SCALE, 32000 / POSITION_SCALE};
/// @hideinitializer
const Position None{32000 / POSITION_SCALE, 32032 / POSITION_SCALE};
/// @hideinitializer
const Position Unknown{32000 / POSITION_SCALE, 32064 / POSITION_SCALE};
const Position Origin{0, 0};
}
/// <summary>Indicates a position that is 8x8 pixels in size.</summary>
/// @see Game::isWalkable, WalkPositions
typedef BWAPI::Point<int, WALKPOSITION_SCALE> WalkPosition;
/// <summary>List of special @ref WalkPosition constants.</summary>
namespace WalkPositions
{
/// @hideinitializer
const WalkPosition Invalid{32000 / WALKPOSITION_SCALE, 32000 / WALKPOSITION_SCALE};
/// @hideinitializer
const WalkPosition None{32000 / WALKPOSITION_SCALE, 32032 / WALKPOSITION_SCALE};
/// @hideinitializer
const WalkPosition Unknown{32000 / WALKPOSITION_SCALE, 32064 / WALKPOSITION_SCALE};
const WalkPosition Origin{0,0};
}
/// <summary>Indicates a position that is 32x32 pixels in size. Typically used for building placement.</summary>
/// @see TilePositions
typedef BWAPI::Point<int, TILEPOSITION_SCALE> TilePosition;
/// <summary>List of special @ref TilePosition constants.</summary>
namespace TilePositions
{
/// @hideinitializer
const TilePosition Invalid{32000 / TILEPOSITION_SCALE, 32000 / TILEPOSITION_SCALE};
/// @hideinitializer
const TilePosition None{32000 / TILEPOSITION_SCALE, 32032 / TILEPOSITION_SCALE};
/// @hideinitializer
const TilePosition Unknown{32000 / TILEPOSITION_SCALE, 32064 / TILEPOSITION_SCALE};
const TilePosition Origin{0, 0};
}
static_assert(sizeof(Position) == 8, "Expected BWAPI Position to be 8 bytes.");
static_assert(sizeof(TilePosition) == 8, "Expected BWAPI Position to be 8 bytes.");
static_assert(sizeof(WalkPosition) == 8, "Expected BWAPI Position to be 8 bytes.");
}

View file

@ -1,79 +0,0 @@
#pragma once
#include <BWAPI/Position.h>
namespace BWAPI
{
class UnitInterface;
typedef UnitInterface *Unit;
/// <summary>PositionOrUnit is a class that is either a Position <b>or</b> a Unit.</summary>
/// The purpose of this class is to reduce interface overhead by combining two commonly passed
/// values into one, and to allow more function overloads with less effort.
class PositionOrUnit
{
public:
/// <summary>Unit constructor. Assigns this class to contain a unit.</summary>
///
/// <param name="unit">
/// The unit to assign to this class.
/// </param>
PositionOrUnit(Unit unit = nullptr);
/// <summary>Position constructor. Assigns this class to contain a position.</summary>
///
/// <param name="pos">
/// The position to assign to this class.
/// </param>
PositionOrUnit(Position pos);
/// <summary>Unit assignment operator. Assigns a unit to this class.</summary>
PositionOrUnit &operator =(Unit pUnit);
/// <summary>Position assignment operator. Assigns a position to this class.</summary>
PositionOrUnit &operator =(Position pos);
/// <summary>Indicates if a Unit is currently held in this class.</summary>
///
/// @returns true if the value contained within this class is considered a unit, and false if
/// it is a position.
bool isUnit() const;
/// <summary>Retrieves the Unit attached to this class, if there is one.</summary>
///
/// @returns The Unit that was assigned to this class.
/// @retval nullptr If this class does not contain a unit, or if nullptr was assigned to
/// this class as a Unit.
Unit getUnit() const;
/// <summary>Indicates if a Position is currently held in this class.</summary>
///
/// @returns true if the value contained within this class is considered a position, and false
/// if it is a unit.
bool isPosition() const;
/// <summary>Retrieves the position if it was assigned to this class, otherwise it will
/// retrieve the position of the unit contained within this class if there is one.</summary>
///
/// @returns Position that was stored if there is one. If not, then the position of the unit
/// will be used instead.
/// @retval Positions::None if a nullptr Unit was assigned to this class.
Position getPosition() const;
private:
/// @cond HIDDEN
union
{
struct
{
int x, y;
} position;
struct
{
Unit pUnit;
int y;
} unit;
};
/// @endcond
};
}

View file

@ -1,107 +0,0 @@
#pragma once
#include <BWAPI/Type.h>
namespace BWAPI
{
class UnitType;
/// <summary>Namespace containing all valid races.</summary>
/// @see Race
namespace Races
{
/// <summary>Enumeration of races.</summary>
/// @see Race
namespace Enum
{
/// <summary>Enumeration of races.</summary>
/// @see Race
enum Enum
{
Zerg = 0,
Terran,
Protoss,
Other,
Unused,
Select,
Random,
None,
Unknown,
MAX
};
};
}
/// <summary>The Race object is used to get information about a particular race.</summary> For
/// example, the default worker and supply provider UnitType.
///
/// As you should already know, Starcraft has three races: @Terran , @Protoss , and @Zerg .
/// @see UnitType::getRace, PlayerInterface::getRace, Races
/// @ingroup TypeClasses
class Race : public Type<Race, Races::Enum::Unknown>
{
public:
/// @copydoc Type::Type(int)
Race(int id = Races::Enum::None);
/// <summary>Retrieves the default worker type for this Race.</summary>
///
/// @note In Starcraft, workers are the units that are used to construct structures.
///
/// @returns UnitType of the worker that this race uses.
UnitType getWorker() const;
/// <summary>Retrieves the default resource center UnitType that is used to create expansions for
/// this Race.</summary>
///
/// @note In Starcraft, the center is the very first structure of the Race's technology
/// tree. Also known as its base of operations or resource depot.
///
/// @returns UnitType of the center that this race uses.
UnitType getCenter() const;
/// <summary>Retrieves the default structure UnitType for this Race that is used to harvest gas from
/// @Geysers.</summary>
///
/// @note In Starcraft, you must first construct a structure over a @Geyser in order to
/// begin harvesting Vespene Gas.
///
/// @returns UnitType of the structure used to harvest gas.
UnitType getRefinery() const;
/// <summary>Retrieves the default transport UnitType for this race that is used to transport ground
/// units across the map.</summary>
///
/// @note In Starcraft, transports will allow you to carry ground units over unpassable
/// terrain.
///
/// @returns UnitType for transportation.
UnitType getTransport() const;
/// <summary>Retrieves the default supply provider UnitType for this race that is used to construct
/// units.</summary>
///
/// @note In Starcraft, training, morphing, or warping in units requires that the player
/// has sufficient supply available for their Race.
///
/// @returns UnitType that provides the player with supply.
UnitType getSupplyProvider() const;
};
/// @ingroup Types
namespace Races
{
/// <summary>Retrieves the set of all valid races.</summary>
///
/// @returns Race::set containing all the Race types.
const Race::set& allRaces();
extern const Race Zerg;
extern const Race Terran;
extern const Race Protoss;
extern const Race Random;
extern const Race None;
extern const Race Unknown;
}
static_assert(sizeof(Race) == sizeof(int), "Expected type to resolve to primitive size.");
}

View file

@ -1,134 +0,0 @@
#pragma once
#include <BWAPI/Position.h>
#include <BWAPI/Filters.h>
#include <BWAPI/UnaryFilter.h>
#include <BWAPI/Interface.h>
namespace BWAPI
{
class Regionset;
class Unitset;
class RegionInterface;
typedef RegionInterface *Region;
/// <summary>Region objects are created by Starcraft: Broodwar to contain several tiles with the same
/// properties, and create a node in pathfinding and other algorithms.</summary> Regions may not contain
/// detailed information, but have a sufficient amount of data to identify general chokepoints,
/// accessibility to neighboring terrain, be used in general pathing algorithms, and used as
/// nodes to rally units to.
///
/// Most parameters that are available are explicitly assigned by Broodwar itself.
///
/// @see Game::getAllRegions, Game::getRegionAt, UnitInterface::getRegion
/// @ingroup Interface
class RegionInterface : public Interface<RegionInterface>
{
protected:
virtual ~RegionInterface() {};
public:
/// <summary>Retrieves a unique identifier for this region.</summary>
///
/// @note This identifier is explicitly assigned by Broodwar.
///
/// @returns An integer that represents this region.
/// @see Game::getRegion
virtual int getID() const = 0;
/// <summary>Retrieves a unique identifier for a group of regions that are all connected and
/// accessible by each other.</summary> That is, all accessible regions will have the same
/// group ID. This function is generally used to check if a path is available between two
/// points in constant time.
///
/// @note This identifier is explicitly assigned by Broodwar.
///
/// @returns An integer that represents the group of regions that this one is attached to.
virtual int getRegionGroupID() const = 0;
/// <summary>Retrieves the center of the region.</summary> This position is used as the node
/// of the region.
///
/// @returns A Position indicating the center location of the Region, in pixels.
virtual BWAPI::Position getCenter() const = 0;
/// <summary>Checks if this region is part of higher ground.</summary> Higher ground may be
/// used in strategic placement of units and structures.
///
/// @returns true if this region is part of strategic higher ground, and false otherwise.
virtual bool isHigherGround() const = 0;
/// <summary>Retrieves a value that represents the strategic advantage of this region relative
/// to other regions.</summary> A value of 2 may indicate a possible choke point, and a value
/// of 3 indicates a signficant strategic position.
///
/// @note This value is explicitly assigned by Broodwar.
///
/// @returns An integer indicating this region's strategic potential.
virtual int getDefensePriority() const = 0;
/// <summary>Retrieves the state of accessibility of the region.</summary> The region is
/// considered accessible if it can be accessed by ground units.
///
/// @returns true if ground units can traverse this region, and false if the tiles in this
/// region are inaccessible or unwalkable.
virtual bool isAccessible() const = 0;
/// <summary>Retrieves the set of neighbor Regions that this one is connected to.</summary>
///
/// @returns A reference to a Regionset containing the neighboring Regions.
virtual const Regionset &getNeighbors() const = 0;
/// <summary>Retrieves the approximate left boundary of the region.</summary>
///
/// @returns The x coordinate, in pixels, of the approximate left boundary of the region.
virtual int getBoundsLeft() const = 0;
/// <summary>Retrieves the approximate top boundary of the region.</summary>
///
/// @returns The y coordinate, in pixels, of the approximate top boundary of the region.
virtual int getBoundsTop() const = 0;
/// <summary>Retrieves the approximate right boundary of the region.</summary>
///
/// @returns The x coordinate, in pixels, of the approximate right boundary of the region.
virtual int getBoundsRight() const = 0;
/// <summary>Retrieves the approximate bottom boundary of the region.</summary>
///
/// @returns The y coordinate, in pixels, of the approximate bottom boundary of the region.
virtual int getBoundsBottom() const = 0;
/// <summary>Retrieves the closest accessible neighbor region.</summary>
///
/// @returns The closest Region that is accessible.
virtual BWAPI::Region getClosestAccessibleRegion() const = 0;
/// <summary>Retrieves the closest inaccessible neighbor region.</summary>
///
/// @returns The closest Region that is inaccessible.
virtual BWAPI::Region getClosestInaccessibleRegion() const = 0;
/// <summary>Retrieves the center-to-center distance between two regions.</summary>
///
/// <param name="other">
/// The target Region to calculate distance to.
/// </param>
/// @returns The integer distance from this Region to \p other.
int getDistance(BWAPI::Region other) const;
/// <summary>Retrieves a Unitset containing all the units that are in this region.</summary>
/// Also has the ability to filter the units before the creation of the Unitset.
///
/// <param name="pred"> (optional)
/// If this parameter is used, it is a UnitFilter or function predicate that will retrieve
/// only the units whose attributes match the given criteria. If omitted, then a default
/// value of nullptr is used, in which case there is no filter.
/// </param>
///
/// @returns A Unitset containing all units in this region that have met the requirements
/// of \p pred.
///
/// @see UnitFilter
Unitset getUnits(const UnitFilter &pred = nullptr) const;
};
};

View file

@ -1,26 +0,0 @@
#pragma once
#include "SetContainer.h"
#include <BWAPI/Position.h>
#include <BWAPI/Filters.h>
namespace BWAPI
{
// Forward Declarations
class RegionInterface;
typedef RegionInterface *Region;
class Unitset;
/// <summary>A container that holds a set of Region objects.</summary>
class Regionset : public SetContainer<BWAPI::Region, std::hash<void*>>
{
public:
/// @copydoc RegionInterface::getCenter
Position getCenter() const;
/// @copydoc RegionInterface::getUnits
Unitset getUnits(const UnitFilter &pred = nullptr) const;
};
}

View file

@ -1,55 +0,0 @@
#pragma once
#include <unordered_set>
#include <set>
namespace BWAPI
{
template <class T, class HashT>
using SetContainerUnderlyingT = std::unordered_set < T, HashT >;
/// <summary>This container is used to wrap convenience functions for BWAPI and be used as a
/// bridge with a built-in set type.</summary>
///
/// @tparam T
/// Type that this set contains.
/// @tparam HashT
/// Hash type. Defaults to integral hashing for BWAPI usage.
template <class T, class HashT = std::hash<int>>
class SetContainer : public SetContainerUnderlyingT < T, HashT >
{
public:
SetContainer() : SetContainerUnderlyingT<T, HashT>() {}
SetContainer(SetContainer const &other) : SetContainerUnderlyingT<T, HashT>(other) {}
SetContainer(SetContainer &&other) : SetContainerUnderlyingT<T, HashT>(std::forward<SetContainer>(other)) {}
SetContainer(std::initializer_list<T> ilist) : SetContainerUnderlyingT<T, HashT>(ilist) {}
template <class IterT>
SetContainer(IterT _begin, IterT _end) : SetContainerUnderlyingT<T, HashT>(_begin, _end) {}
/// <summary>Iterates the set and erases each element x where pred(x) returns true.</summary>
///
/// <param name="pred">
/// Predicate for removing elements.
/// </param>
/// @see std::erase_if
template<class Pred>
void erase_if(const Pred& pred) {
auto it = this->begin();
while (it != this->end()) {
if (pred(*it)) it = this->erase(it);
else ++it;
}
};
/// <summary>Checks if this set contains a specific value.</summary>
///
/// <param name="value">
/// Value to search for.
/// </param>
bool contains(T const &value) const
{
return count(value) != 0;
}
};
}

View file

@ -1,214 +0,0 @@
#pragma once
#include <BWAPI/Type.h>
#include <BWAPI/UnitType.h>
namespace BWAPI
{
class UnitType;
class WeaponType;
class Order;
class Race;
/// <summary>Namespace containing tech types.</summary>
/// @see TechType
namespace TechTypes
{
/// <summary>Enumeration of Tech Types.</summary>
/// @see TechType
namespace Enum
{
/// <summary>Enumeration of Tech Types.</summary>
/// @see TechType
enum Enum
{
Stim_Packs = 0,
Lockdown,
EMP_Shockwave,
Spider_Mines,
Scanner_Sweep,
Tank_Siege_Mode,
Defensive_Matrix,
Irradiate,
Yamato_Gun,
Cloaking_Field,
Personnel_Cloaking,
Burrowing,
Infestation,
Spawn_Broodlings,
Dark_Swarm,
Plague,
Consume,
Ensnare,
Parasite,
Psionic_Storm,
Hallucination,
Recall,
Stasis_Field,
Archon_Warp,
Restoration,
Disruption_Web,
Unused_26,
Mind_Control,
Dark_Archon_Meld,
Feedback,
Optical_Flare,
Maelstrom,
Lurker_Aspect,
Unused_33,
Healing,
None = 44,
Nuclear_Strike,
Unknown,
MAX
};
};
}
/// <summary>The TechType (or Technology Type, also referred to as an Ability) represents a Unit's ability
/// which can be researched with UnitInterface::research or used with UnitInterface::useTech.</summary>
/// In order for a Unit to use its own specialized ability, it must first be available and researched.
///
/// @see TechTypes
/// @ingroup TypeClasses
class TechType : public Type<TechType, TechTypes::Enum::Unknown>
{
public:
/// @copydoc Type::Type(int)
TechType(int id = TechTypes::Enum::None);
/// <summary>Retrieves the race that is required to research or use the TechType.</summary>
///
/// @note There is an exception where @Infested_Kerrigan can use @Psi_Storm. This does not
/// apply to the behavior of this function.
///
/// @returns Race object indicating which race is designed to use this technology type.
Race getRace() const;
/// <summary>Retrieves the mineral cost of researching this technology.</summary>
///
/// @returns Amount of minerals needed in order to research this technology.
int mineralPrice() const;
/// <summary>Retrieves the vespene gas cost of researching this technology.</summary>
///
/// @returns Amount of vespene gas needed in order to research this technology.
int gasPrice() const;
/// <summary>Retrieves the number of frames needed to research the tech type.</summary>
///
/// @returns The time, in frames, it will take for the research to complete.
/// @see UnitInterface::getRemainingResearchTime
int researchTime() const;
/// <summary>Retrieves the amount of energy needed to use this TechType as an ability.</summary>
///
/// @returns Energy cost of the ability.
/// @see UnitInterface::getEnergy
int energyCost() const;
/// <summary>Retrieves the UnitType that can research this technology.</summary>
///
/// @returns UnitType that is able to research the technology in the game.
/// @retval UnitTypes::None If the technology/ability is either provided for free or never
/// available.
UnitType whatResearches() const;
/// <summary>Retrieves the Weapon that is attached to this tech type.</summary>
/// A technology's WeaponType is used to indicate the range and behaviour of the ability
/// when used by a Unit.
///
/// @returns WeaponType containing information about the ability's behavior.
/// @retval WeaponTypes::None If there is no corresponding WeaponType.
WeaponType getWeapon() const;
/// <summary>Checks if this ability can be used on other units.</summary>
///
/// @returns true if the ability can be used on other units, and false if it can not.
bool targetsUnit() const;
/// <summary>Checks if this ability can be used on the terrain (ground).</summary>
///
/// @returns true if the ability can be used on the terrain.
bool targetsPosition() const;
/// <summary>Retrieves the set of all UnitTypes that are capable of using this ability.</summary>
///
/// @returns Set of UnitTypes that can use this ability when researched.
const UnitType::set& whatUses() const;
/// <summary>Retrieves the Order that a Unit uses when using this ability.</summary>
///
/// @returns Order representing the action a Unit uses to perform this ability
Order getOrder() const;
/// <summary>Retrieves the UnitType required to research this technology.</summary>
/// The required unit type must be a completed unit owned by the player researching the
/// technology.
///
/// @returns UnitType that is needed to research this tech type.
/// @retval UnitTypes::None if no unit is required to research this tech type.
///
/// @see PlayerInterface::completedUnitCount
///
/// @since 4.1.2
UnitType requiredUnit() const;
};
/// @ingroup Types
namespace TechTypes
{
/// <summary>Retrieves the set of all the TechTypes.</summary>
///
/// @returns Set of all available TechTypes.
const TechType::set& allTechTypes();
/// @name Terran Abilities
/// @{
extern const TechType Stim_Packs;
extern const TechType Lockdown;
extern const TechType EMP_Shockwave;
extern const TechType Spider_Mines;
extern const TechType Scanner_Sweep;
extern const TechType Tank_Siege_Mode;
extern const TechType Defensive_Matrix;
extern const TechType Irradiate;
extern const TechType Yamato_Gun;
extern const TechType Cloaking_Field;
extern const TechType Personnel_Cloaking;
extern const TechType Restoration;
extern const TechType Optical_Flare;
extern const TechType Healing;
extern const TechType Nuclear_Strike;
/// @}
/// @name Zerg Abilities
/// @{
extern const TechType Burrowing;
extern const TechType Infestation;
extern const TechType Spawn_Broodlings;
extern const TechType Dark_Swarm;
extern const TechType Plague;
extern const TechType Consume;
extern const TechType Ensnare;
extern const TechType Parasite;
extern const TechType Lurker_Aspect;
/// @}
/// @name Protoss Abilities
/// @{
extern const TechType Psionic_Storm;
extern const TechType Hallucination;
extern const TechType Recall;
extern const TechType Stasis_Field;
extern const TechType Archon_Warp;
extern const TechType Disruption_Web;
extern const TechType Mind_Control;
extern const TechType Dark_Archon_Meld;
extern const TechType Feedback;
extern const TechType Maelstrom;
/// @}
extern const TechType None;
extern const TechType Unknown;
};
static_assert(sizeof(TechType) == sizeof(int), "Expected type to resolve to primitive size.");
}

View file

@ -1,54 +0,0 @@
#pragma once
namespace BWAPI
{
/// <summary>Contains a list of interruptable actions that the tournament module can allow or deny.</summary>
/// @see TournamentModule::onAction
namespace Tournament
{
/// <summary>Contains a list of interruptable actions that the tournament module can allow or deny.</summary>
/// @see TournamentModule::onAction
enum ActionID
{
/// @see Game::enableFlag
EnableFlag,
/// @see Game::pauseGame
PauseGame,
/// @see Game::resumeGame
ResumeGame,
/// @see Game::leaveGame
LeaveGame,
/// @see Game::setLocalSpeed
SetLocalSpeed,
/// @see Game::setTextSize
SetTextSize,
/// @see Game::setLatCom
SetLatCom,
/// @see Game::setGUI
SetGUI,
/// @see Game::setMap
SetMap,
/// @see Game::setFrameSkip
SetFrameSkip,
/// @see Game::printf
Printf,
/// @see Game::sendText
SendText,
/// @see Game::setCommandOptimizationLevel
SetCommandOptimizationLevel
};
};
};

View file

@ -1,160 +0,0 @@
#pragma once
#include <BWAPI/SetContainer.h>
#include <string>
#include <cctype>
#include <deque>
#include <unordered_map>
#include <algorithm>
#include <iostream>
namespace BWAPI
{
template<class T, int UnknownId> class Type;
/// <summary>Base superclass for all BWAPI Types.</summary>
///
/// @tparam T
/// The type class that this Type is representing.
///
/// @tparam UnknownId
/// The enum ID of the unknown entry, which is also treated as the last entry for type
/// validity.
template<class T, int UnknownId>
class Type
{
protected:
/// @cond HIDDEN
/// <summary>Primitive storage unit for the type identifier (type id).</summary>
int tid;
/// <summary>Array of strings containing the type names.</summary>
static const std::string typeNames[UnknownId+1];
/// <summary>Type that maps names to their type values.</summary>
typedef std::unordered_map<std::string,T> typeMapT;
/// @endcond
private:
static typeMapT typeMapInit()
{
typeMapT result(UnknownId+1);
for ( int i = 0; i < UnknownId + 1; ++i ) // include unknown
{
std::string n( typeNames[i] );
// erase-remove idiom, eliminates spaces and underscores from the string
n.erase( std::remove_if(n.begin(), n.end(), [](char const &c){ return isspace(c) || c == '_'; }), n.end() );
// Make lowercase
std::transform (n.begin (), n.end (), n.begin (), ::tolower);
result.insert( typeMapT::value_type(n, T(i)) );
}
return result;
}
public:
/// <summary>Expected type constructor.</summary> If the type is an invalid type, then it
/// becomes Types::Unknown. A type is invalid if its value is less than 0 or greater than
/// Types::Unknown.
///
/// <param name="id">
/// The id that corresponds to this type. It is typically an integer value that corresponds
/// to an internal Broodwar type. If the given id is invalid, then it becomes Types::Unknown.
/// </param>
explicit Type(int id) : tid( id < 0 || id > UnknownId ? UnknownId : id ) {};
/// <summary>A set type that contains the current type.</summary>
typedef SetContainer<T> set;
/// <summary>A list type that contains the current type.</summary>
typedef std::deque<T> list;
/// <summary>Conversion/convenience operator to convert this type to its primitive type.</summary>
///
/// @returns An integer representation of this type.
inline operator int() const { return this->tid; };
/// <summary>Retrieves this type's identifier as an integer.</summary>
///
/// @returns An integer representation of this type.
inline int getID() const { return this->tid; };
/// <summary>Checks if the current type has a valid identifier.</summary> The purpose of
/// this function is to prevent buffer overflows if a type has been handled improperly.
///
/// A type is valid if it is between 0 and Unknown (inclusive).
///
/// @returns true If this type is valid and false otherwise.
inline bool isValid() const { return this->tid >= 0 && this->tid <= UnknownId; };
/// <summary>Retrieves the variable name of the type.</summary>
///
/// @returns Reference to std::string object containing the name.
inline const std::string &getName() const
{
return typeNames[this->isValid() ? this->tid : UnknownId];
};
/// @copydoc Type::getName
inline const std::string &toString() const
{
return this->getName();
};
/// <summary>Retrieves the variable name of the type as a c-style string.</summary> Meant to
/// be a convenience member.
///
/// @returns Pointer to constant c-style string containing the name.
inline const char *c_str() const
{
return this->getName().c_str();
};
/// <summary>Output stream operator overload.</summary> Allows printing of the type without
/// calling Type::getName.
///
/// <param name="out">
/// The destination output stream.
/// </param>
/// <param name="t">
/// The type to write as a string.
/// </param>
friend inline std::ostream &operator << (std::ostream &out, const Type<T, UnknownId> &t)
{
return out << t.getName();
};
/// @overload
friend inline std::wostream &operator << (std::wostream &out, const Type<T, UnknownId> &t)
{
std::wstring wideName{ t.getName().begin(), t.getName().end() };
return out << wideName;
};
/// <summary>Searches for the type associated with the given string and returns it.</summary>
///
/// <param name="name">
/// A string containing the name of the type.
/// </param>
/// @returns The type that resolves to the given name.
static T getType(std::string name)
{
// Mapping of strings to types
static const typeMapT typeMap( typeMapInit() );
// erase-remove idiom, eliminates spaces and underscores from the string to search
name.erase( std::remove_if(name.begin(), name.end(), [](char const &c){ return isspace(c) || c == '_'; }), name.end() );
// Make lowercase
std::transform (name.begin (), name.end (), name.begin (), ::tolower);
// Find the type
auto it = typeMap.find(name);
if ( it != typeMap.end() )
return it->second;
// Return unknown if it wasn't found
return T(UnknownId);
};
};
}

View file

@ -1,68 +0,0 @@
#pragma once
#include <functional>
namespace BWAPI
{
/// <summary>UnaryFilter allows for logical functor combinations.</summary>
///
/// @code
/// Unit myUnit;
/// // The following two if statements are equivalent
/// if ( myUnit->getType().isWorker() && myUnit->isCompleted() && myUnit->isIdle() )
/// {}
///
/// if ( (IsWorker && IsCompleted && IsIdle)(myUnit) )
/// {}
/// @endcode
///
/// @tparam PType
/// The type being passed into the predicate, which will be of type bool(PType).
/// @tparam Container (optional)
/// Storage container for the function predicate. It is std::function<bool(PType)> by default.
template <class PType, class Container = std::function<bool(PType)> >
class UnaryFilter
{
private:
Container pred;
public:
// ctor
template < typename T >
UnaryFilter(const T &predicate) : pred(predicate) {}
// Default copy/move ctor/assign and dtor
// logical operators
template <typename T>
inline UnaryFilter<PType,std::function<bool(PType)> > operator &&(const T& other) const
{
return [=](PType v){ return (*this)(v) && other(v); };
};
template <typename T>
inline UnaryFilter<PType,std::function<bool(PType)> > operator ||(const T& other) const
{
return [=](PType v){ return (*this)(v) || other(v); };
};
inline UnaryFilter<PType,std::function<bool(PType)> > operator !() const
{
if ( !this->pred )
return nullptr;
return [=](PType v){ return !(*this)(v); };
};
// call
inline bool operator()(PType v) const
{
return pred(v);
};
// operator bool
inline bool isValid() const
{
return (bool)pred;
};
};
}

File diff suppressed because it is too large Load diff

View file

@ -1,82 +0,0 @@
#pragma once
#include <BWAPI/Position.h>
#include <BWAPI/UnitCommandType.h>
namespace BWAPI
{
// Forwards
class UnitType;
class TechType;
class UpgradeType;
class PositionOrUnit;
class UnitInterface;
typedef UnitInterface *Unit;
class UnitCommand
{
public:
UnitCommand() = default;
UnitCommand(Unit _unit, UnitCommandType _type, Unit _target, int _x, int _y, int _extra);
static UnitCommand attack(Unit unit, PositionOrUnit target, bool shiftQueueCommand = false);
static UnitCommand build(Unit unit, TilePosition target, UnitType type);
static UnitCommand buildAddon(Unit unit, UnitType type);
static UnitCommand train(Unit unit, UnitType type);
static UnitCommand morph(Unit unit, UnitType type);
static UnitCommand research(Unit unit, TechType tech);
static UnitCommand upgrade(Unit unit, UpgradeType upgrade);
static UnitCommand setRallyPoint(Unit unit, PositionOrUnit target);
static UnitCommand move(Unit unit, Position target, bool shiftQueueCommand = false);
static UnitCommand patrol(Unit unit, Position target, bool shiftQueueCommand = false);
static UnitCommand holdPosition(Unit unit, bool shiftQueueCommand = false);
static UnitCommand stop(Unit unit, bool shiftQueueCommand = false);
static UnitCommand follow(Unit unit, Unit target, bool shiftQueueCommand = false);
static UnitCommand gather(Unit unit, Unit target, bool shiftQueueCommand = false);
static UnitCommand returnCargo(Unit unit, bool shiftQueueCommand = false);
static UnitCommand repair(Unit unit, Unit target, bool shiftQueueCommand = false);
static UnitCommand burrow(Unit unit);
static UnitCommand unburrow(Unit unit);
static UnitCommand cloak(Unit unit);
static UnitCommand decloak(Unit unit);
static UnitCommand siege(Unit unit);
static UnitCommand unsiege(Unit unit);
static UnitCommand lift(Unit unit);
static UnitCommand land(Unit unit, TilePosition target);
static UnitCommand load(Unit unit, Unit target, bool shiftQueueCommand = false);
static UnitCommand unload(Unit unit, Unit target);
static UnitCommand unloadAll(Unit unit, bool shiftQueueCommand = false);
static UnitCommand unloadAll(Unit unit, Position target, bool shiftQueueCommand = false);
static UnitCommand rightClick(Unit unit, PositionOrUnit target, bool shiftQueueCommand = false);
static UnitCommand haltConstruction(Unit unit);
static UnitCommand cancelConstruction(Unit unit);
static UnitCommand cancelAddon(Unit unit);
static UnitCommand cancelTrain(Unit unit, int slot = -2);
static UnitCommand cancelMorph(Unit unit);
static UnitCommand cancelResearch(Unit unit);
static UnitCommand cancelUpgrade(Unit unit);
static UnitCommand useTech(Unit unit,TechType tech);
static UnitCommand useTech(Unit unit,TechType tech, PositionOrUnit target);
static UnitCommand placeCOP(Unit unit, TilePosition target);
UnitCommandType getType() const;
Unit getUnit() const;
Unit getTarget() const;
Position getTargetPosition() const;
TilePosition getTargetTilePosition() const;
UnitType getUnitType() const;
TechType getTechType() const;
UpgradeType getUpgradeType() const;
int getSlot() const;
bool isQueued() const;
bool operator==(const UnitCommand& other) const;
bool operator!=(const UnitCommand& other) const;
Unit unit = nullptr;
UnitCommandType type = UnitCommandTypes::None;
Unit target = nullptr;
int x = Positions::None.x;
int y = Positions::None.y;
int extra = 0;
};
}

View file

@ -1,138 +0,0 @@
#pragma once
#include <BWAPI/Type.h>
namespace BWAPI
{
/// <summary>Namespace containing unit command types.</summary>
/// @see UnitCommandType
namespace UnitCommandTypes
{
/// <summary>Enumeration of valid unit command types.</summary>
/// @see UnitCommandType
namespace Enum
{
/// <summary>Enumeration of valid unit command types.</summary>
/// @see UnitCommandType
enum Enum
{
Attack_Move = 0,
Attack_Unit,
Build,
Build_Addon,
Train,
Morph,
Research,
Upgrade,
Set_Rally_Position,
Set_Rally_Unit,
Move,
Patrol,
Hold_Position,
Stop,
Follow,
Gather,
Return_Cargo,
Repair,
Burrow,
Unburrow,
Cloak,
Decloak,
Siege,
Unsiege,
Lift,
Land,
Load,
Unload,
Unload_All,
Unload_All_Position,
Right_Click_Position,
Right_Click_Unit,
Halt_Construction,
Cancel_Construction,
Cancel_Addon,
Cancel_Train,
Cancel_Train_Slot,
Cancel_Morph,
Cancel_Research,
Cancel_Upgrade,
Use_Tech,
Use_Tech_Position,
Use_Tech_Unit,
Place_COP,
None,
Unknown,
MAX
};
};
};
/// <summary>A representation of a unit command in BWAPI.</summary> This is used by bots to
/// notify BWAPI which commands to use. BWAPI filters commands accordingly and then converts
/// them to Broodwar commands, which differ in complexity.
///
/// @see UnitCommandTypes
/// @ingroup TypeClasses
class UnitCommandType : public Type<UnitCommandType, UnitCommandTypes::Enum::Unknown>
{
public:
/// @copydoc Type::Type(int)
UnitCommandType(int id = UnitCommandTypes::Enum::None);
};
/// @ingroup Types
namespace UnitCommandTypes
{
/// <summary>Retrieves the set of all valid UnitCommandTypes.</summary>
///
/// @returns Set of UnitCommandTypes.
const UnitCommandType::set& allUnitCommandTypes();
extern const UnitCommandType Attack_Move;
extern const UnitCommandType Attack_Unit;
extern const UnitCommandType Build;
extern const UnitCommandType Build_Addon;
extern const UnitCommandType Train;
extern const UnitCommandType Morph;
extern const UnitCommandType Research;
extern const UnitCommandType Upgrade;
extern const UnitCommandType Set_Rally_Position;
extern const UnitCommandType Set_Rally_Unit;
extern const UnitCommandType Move;
extern const UnitCommandType Patrol;
extern const UnitCommandType Hold_Position;
extern const UnitCommandType Stop;
extern const UnitCommandType Follow;
extern const UnitCommandType Gather;
extern const UnitCommandType Return_Cargo;
extern const UnitCommandType Repair;
extern const UnitCommandType Burrow;
extern const UnitCommandType Unburrow;
extern const UnitCommandType Cloak;
extern const UnitCommandType Decloak;
extern const UnitCommandType Siege;
extern const UnitCommandType Unsiege;
extern const UnitCommandType Lift;
extern const UnitCommandType Land;
extern const UnitCommandType Load;
extern const UnitCommandType Unload;
extern const UnitCommandType Unload_All;
extern const UnitCommandType Unload_All_Position;
extern const UnitCommandType Right_Click_Position;
extern const UnitCommandType Right_Click_Unit;
extern const UnitCommandType Halt_Construction;
extern const UnitCommandType Cancel_Construction;
extern const UnitCommandType Cancel_Addon;
extern const UnitCommandType Cancel_Train;
extern const UnitCommandType Cancel_Train_Slot;
extern const UnitCommandType Cancel_Morph;
extern const UnitCommandType Cancel_Research;
extern const UnitCommandType Cancel_Upgrade;
extern const UnitCommandType Use_Tech;
extern const UnitCommandType Use_Tech_Position;
extern const UnitCommandType Use_Tech_Unit;
extern const UnitCommandType Place_COP;
extern const UnitCommandType None;
extern const UnitCommandType Unknown;
}
static_assert(sizeof(UnitCommandType) == sizeof(int), "Expected type to resolve to primitive size.");
}

View file

@ -1,64 +0,0 @@
#pragma once
#include <BWAPI/Type.h>
namespace BWAPI
{
/// <summary>Namespace containing unit size types.</summary>
///
/// @see UnitSizeType
///
/// [View on Starcraft Campendium (Official Website)](http://classic.battle.net/scc/gs/damage.shtml)<br>
namespace UnitSizeTypes
{
/// <summary>Enumeration of unit size types.</summary>
/// @see UnitSizeType
namespace Enum
{
/// <summary>Enumeration of unit size types.</summary>
/// @see UnitSizeType
enum Enum
{
Independent = 0,
Small,
Medium,
Large,
None,
Unknown,
MAX
};
};
};
/// <summary>Size types are used by unit types in Broodwar to determine how much damage will be
/// applied.</summary> This corresponds with DamageType for several different damage reduction
/// applications.
///
/// @see DamageType, UnitType, UnitSizeTypes
///
/// [View on Starcraft Campendium (Official Website)](http://classic.battle.net/scc/gs/damage.shtml)<br>
/// @ingroup TypeClasses
class UnitSizeType : public Type<UnitSizeType, UnitSizeTypes::Enum::Unknown>
{
public:
/// @copydoc Type::Type(int)
UnitSizeType(int id = UnitSizeTypes::Enum::None);
};
/// @ingroup Types
namespace UnitSizeTypes
{
/// <summary>Retrieves the set of all valid UnitSizeTypes.</summary>
///
/// @returns Set of all UnitSizeTypes.
const UnitSizeType::set& allUnitSizeTypes();
extern const UnitSizeType Independent;
extern const UnitSizeType Small;
extern const UnitSizeType Medium;
extern const UnitSizeType Large;
extern const UnitSizeType None;
extern const UnitSizeType Unknown;
}
static_assert(sizeof(UnitSizeType) == sizeof(int), "Expected type to resolve to primitive size.");
}

File diff suppressed because it is too large Load diff

View file

@ -1,186 +0,0 @@
#pragma once
#include "SetContainer.h"
#include <BWAPI/Position.h>
#include <BWAPI/PositionUnit.h>
#include <BWAPI/Filters.h>
namespace BWAPI
{
// Forward declarations
class UnitType;
class Regionset;
class UnitCommand;
class TechType;
/// <summary>The Unitset is a container for a set of pointers to Unit objects. It is typically
/// used for groups of units instead of having to manage each Unit individually.</summary>
///
/// @see Unit
class Unitset : public SetContainer<BWAPI::Unit, std::hash<void*>>
{
public:
/// <summary>A blank Unitset containing no elements.</summary> This is typically used as a
/// return value for BWAPI interface functions that have encountered an error.
static const Unitset none;
/// <summary>Calculates the average of all valid Unit positions in this set.</summary>
///
/// @returns Average Position of all units in the set.
///
/// @see UnitInterface::getPosition
Position getPosition() const;
/// <summary>Creates a single set containing all units that are loaded into units of this set.</summary>
///
/// @returns The set of all loaded units.
///
/// @see UnitInterface::getLoadedUnits
Unitset getLoadedUnits() const;
/// <summary>Creates a single set containing all the @Interceptors of all @Carriers in this set.</summary>
///
/// @returns The set of all @Interceptors .
///
/// @see UnitInterface::getInterceptors
Unitset getInterceptors() const;
/// <summary>Creates a single set containing all the @Larvae of all @Hatcheries, @Lairs, and
/// @Hives in this set.</summary>
///
/// @returns The set of all @Larvae .
///
/// @see UnitInterface::getLarva
Unitset getLarva() const;
/// <summary>Sets the client info for every unit in this set.</summary>
///
/// <param name="clientInfo"> (optional)
/// A pointer to client information, managed by the AI module, or nullptr if client
/// information is to be cleared.
/// </param>
/// <param name="index"> (optional)
/// An key value for the client info mapping so that more than one piece of data can be
/// mapped to the same unit.
/// </param>
///
/// @see UnitInterface::setClientInfo
void setClientInfo(void *clientInfo = nullptr, int index = 0) const;
/// @overload
void setClientInfo(int clientInfo = 0, int index = 0) const;
/// @copydoc UnitInterface::getUnitsInRadius
Unitset getUnitsInRadius(int radius, const UnitFilter &pred = nullptr) const;
/// @copydoc UnitInterface::getClosestUnit
Unit getClosestUnit(const UnitFilter &pred = nullptr, int radius = 999999) const;
/// @name Unit Commands
/// @{
/// @copydoc UnitInterface::issueCommand
bool issueCommand(UnitCommand command) const;
/// @copydoc UnitInterface::attack
bool attack(PositionOrUnit target, bool shiftQueueCommand = false) const;
/// @copydoc UnitInterface::build
bool build(UnitType type, TilePosition target = TilePositions::None) const;
/// @copydoc UnitInterface::buildAddon
bool buildAddon(UnitType type) const;
/// @copydoc UnitInterface::train
bool train(UnitType type) const;
/// @copydoc UnitInterface::morph
bool morph(UnitType type) const;
/// @copydoc UnitInterface::setRallyPoint
bool setRallyPoint(PositionOrUnit target) const;
/// @copydoc UnitInterface::move
bool move(Position target, bool shiftQueueCommand = false) const;
/// @copydoc UnitInterface::patrol
bool patrol(Position target, bool shiftQueueCommand = false) const;
/// @copydoc UnitInterface::holdPosition
bool holdPosition(bool shiftQueueCommand = false) const;
/// @copydoc UnitInterface::stop
bool stop(bool shiftQueueCommand = false) const;
/// @copydoc UnitInterface::follow
bool follow(Unit target, bool shiftQueueCommand = false) const;
/// @copydoc UnitInterface::gather
bool gather(Unit target, bool shiftQueueCommand = false) const;
/// @copydoc UnitInterface::returnCargo
bool returnCargo(bool shiftQueueCommand = false) const;
/// @copydoc UnitInterface::repair
bool repair(Unit target, bool shiftQueueCommand = false) const;
/// @copydoc UnitInterface::burrow
bool burrow() const;
/// @copydoc UnitInterface::unburrow
bool unburrow() const;
/// @copydoc UnitInterface::cloak
bool cloak() const;
/// @copydoc UnitInterface::decloak
bool decloak() const;
/// @copydoc UnitInterface::siege
bool siege() const;
/// @copydoc UnitInterface::unsiege
bool unsiege() const;
/// @copydoc UnitInterface::lift
bool lift() const;
/// @copydoc UnitInterface::load
bool load(Unit target, bool shiftQueueCommand = false) const;
/// @copydoc UnitInterface::unloadAll(bool)
bool unloadAll(bool shiftQueueCommand = false) const;
/// @copydoc UnitInterface::unloadAll(Position,bool)
bool unloadAll(Position target, bool shiftQueueCommand = false) const;
/// @copydoc UnitInterface::rightClick
bool rightClick(PositionOrUnit target, bool shiftQueueCommand = false) const;
/// @copydoc UnitInterface::haltConstruction
bool haltConstruction() const;
/// @copydoc UnitInterface::cancelConstruction
bool cancelConstruction() const;
/// @copydoc UnitInterface::cancelAddon
bool cancelAddon() const;
/// @copydoc UnitInterface::cancelTrain
bool cancelTrain(int slot = -2) const;
/// @copydoc UnitInterface::cancelMorph
bool cancelMorph() const;
/// @copydoc UnitInterface::cancelResearch
bool cancelResearch() const;
/// @copydoc UnitInterface::cancelUpgrade
bool cancelUpgrade() const;
/// @copydoc UnitInterface::useTech
bool useTech(TechType tech, PositionOrUnit target = nullptr) const;
///@}
};
}

View file

@ -1,249 +0,0 @@
#pragma once
#include <BWAPI/Type.h>
#include <BWAPI/UnitType.h>
namespace BWAPI
{
class Race;
/// <summary>Namespace of upgrade types.</summary>
namespace UpgradeTypes
{
/// <summary>Enumeration of upgrade types.</summary>
namespace Enum
{
/// <summary>Enumeration of upgrade types.</summary>
enum Enum
{
Terran_Infantry_Armor = 0,
Terran_Vehicle_Plating = 1,
Terran_Ship_Plating = 2,
Zerg_Carapace = 3,
Zerg_Flyer_Carapace = 4,
Protoss_Ground_Armor = 5,
Protoss_Air_Armor = 6,
Terran_Infantry_Weapons = 7,
Terran_Vehicle_Weapons = 8,
Terran_Ship_Weapons = 9,
Zerg_Melee_Attacks = 10,
Zerg_Missile_Attacks = 11,
Zerg_Flyer_Attacks = 12,
Protoss_Ground_Weapons = 13,
Protoss_Air_Weapons = 14,
Protoss_Plasma_Shields = 15,
U_238_Shells = 16,
Ion_Thrusters = 17,
Titan_Reactor = 19,
Ocular_Implants = 20,
Moebius_Reactor = 21,
Apollo_Reactor = 22,
Colossus_Reactor = 23,
Ventral_Sacs = 24,
Antennae = 25,
Pneumatized_Carapace = 26,
Metabolic_Boost = 27,
Adrenal_Glands = 28,
Muscular_Augments = 29,
Grooved_Spines = 30,
Gamete_Meiosis = 31,
Metasynaptic_Node = 32,
Singularity_Charge = 33,
Leg_Enhancements = 34,
Scarab_Damage = 35,
Reaver_Capacity = 36,
Gravitic_Drive = 37,
Sensor_Array = 38,
Gravitic_Boosters = 39,
Khaydarin_Amulet = 40,
Apial_Sensors = 41,
Gravitic_Thrusters = 42,
Carrier_Capacity = 43,
Khaydarin_Core = 44,
Argus_Jewel = 47,
Argus_Talisman = 49,
Caduceus_Reactor = 51,
Chitinous_Plating = 52,
Anabolic_Synthesis = 53,
Charon_Boosters = 54,
Upgrade_60 = 60,
None = 61,
Unknown,
MAX
};
}
}
/// <summary>The upgrade type represents a passive upgrade that can be obtained with
/// UnitInterface::upgrade. </summary>
///
/// @see UpgradeTypes
///
/// @ingroup TypeClasses
class UpgradeType : public Type<UpgradeType, UpgradeTypes::Enum::Unknown>
{
public:
/// @copydoc Type::Type(int)
UpgradeType(int id = UpgradeTypes::Enum::None);
/// <summary>Retrieves the race the upgrade is for.</summary>
/// For example, UpgradeTypes::Terran_Infantry_Armor.getRace() will return Races::Terran.
///
/// @returns Race that this upgrade belongs to.
Race getRace() const;
/// <summary>Returns the mineral price for the upgrade.</summary>
///
/// <param name="level"> (optional)
/// The next upgrade level.
/// </param>
///
/// @note Upgrades start at level 0.
///
/// @returns The mineral cost of the upgrade for the given \p level.
int mineralPrice(int level = 1) const;
/// <summary>The amount that the mineral price increases for each additional upgrade.</summary>
///
/// @returns The mineral cost added to the upgrade after each level.
int mineralPriceFactor() const;
/// <summary>Returns the vespene gas price for the first upgrade.</summary>
///
/// <param name="level"> (optional)
/// The next upgrade level.
/// </param>
///
/// @note Upgrades start at level 0.
///
/// @returns The gas cost of the upgrade for the given \p level.
int gasPrice(int level = 1) const;
/// <summary>Returns the amount that the vespene gas price increases for each additional upgrade.</summary>
///
/// @returns The gas cost added to the upgrade after each level.
int gasPriceFactor() const;
/// <summary>Returns the number of frames needed to research the first upgrade.</summary>
///
/// <param name="level"> (optional)
/// The next upgrade level.
/// </param>
///
/// @note Upgrades start at level 0.
///
/// @returns The time cost of the upgrade for the given \p level.
int upgradeTime(int level = 1) const;
/// <summary>Returns the number of frames that the upgrade time increases for each additional upgrade.</summary>
///
/// @returns The time cost added to the upgrade after each level.
int upgradeTimeFactor() const;
/// <summary>Returns the maximum number of times the upgrade can be researched.</summary>
///
/// @returns Maximum number of times this upgrade can be upgraded.
int maxRepeats() const;
/// <summary>Returns the type of unit that researches the upgrade.</summary>
///
/// @returns The UnitType that is used to upgrade this type.
UnitType whatUpgrades() const;
/// <summary>Returns the type of unit that is required for the upgrade.</summary> The player
/// must have at least one of these units completed in order to start upgrading this upgrade.
///
/// <param name="level"> (optional)
/// The next upgrade level.
/// </param>
///
/// @note Upgrades start at level 0.
///
/// @returns UnitType required to obtain this upgrade.
UnitType whatsRequired(int level = 1) const;
/// <summary>Returns the set of units that are affected by this upgrade.</summary>
///
/// @returns Set of unit types that passively use this upgrade type.
const UnitType::set& whatUses() const;
};
/// @ingroup Types
namespace UpgradeTypes
{
/// <summary>Returns the set of all the UpgradeTypes.</summary>
///
/// @returns UpgradeType::set containing all of the well-defined UpgradeTypes.
const UpgradeType::set& allUpgradeTypes();
/// @name Terran Upgrades
/// @{
extern const UpgradeType Terran_Infantry_Armor;
extern const UpgradeType Terran_Vehicle_Plating;
extern const UpgradeType Terran_Ship_Plating;
extern const UpgradeType Terran_Infantry_Weapons;
extern const UpgradeType Terran_Vehicle_Weapons;
extern const UpgradeType Terran_Ship_Weapons;
extern const UpgradeType U_238_Shells;
extern const UpgradeType Ion_Thrusters;
extern const UpgradeType Titan_Reactor;
extern const UpgradeType Ocular_Implants;
extern const UpgradeType Moebius_Reactor;
extern const UpgradeType Apollo_Reactor;
extern const UpgradeType Colossus_Reactor;
extern const UpgradeType Caduceus_Reactor;
extern const UpgradeType Charon_Boosters;
/// @}
/// @name Zerg Upgrades
/// @{
extern const UpgradeType Zerg_Carapace;
extern const UpgradeType Zerg_Flyer_Carapace;
extern const UpgradeType Zerg_Melee_Attacks;
extern const UpgradeType Zerg_Missile_Attacks;
extern const UpgradeType Zerg_Flyer_Attacks;
extern const UpgradeType Ventral_Sacs;
extern const UpgradeType Antennae;
extern const UpgradeType Pneumatized_Carapace;
extern const UpgradeType Metabolic_Boost;
extern const UpgradeType Adrenal_Glands;
extern const UpgradeType Muscular_Augments;
extern const UpgradeType Grooved_Spines;
extern const UpgradeType Gamete_Meiosis;
extern const UpgradeType Metasynaptic_Node;
extern const UpgradeType Chitinous_Plating;
extern const UpgradeType Anabolic_Synthesis;
/// @}
/// @name Protoss Upgrades
/// @{
extern const UpgradeType Protoss_Ground_Armor;
extern const UpgradeType Protoss_Air_Armor;
extern const UpgradeType Protoss_Ground_Weapons;
extern const UpgradeType Protoss_Air_Weapons;
extern const UpgradeType Protoss_Plasma_Shields;
extern const UpgradeType Singularity_Charge;
extern const UpgradeType Leg_Enhancements;
extern const UpgradeType Scarab_Damage;
extern const UpgradeType Reaver_Capacity;
extern const UpgradeType Gravitic_Drive;
extern const UpgradeType Sensor_Array;
extern const UpgradeType Gravitic_Boosters;
extern const UpgradeType Khaydarin_Amulet;
extern const UpgradeType Apial_Sensors;
extern const UpgradeType Gravitic_Thrusters;
extern const UpgradeType Carrier_Capacity;
extern const UpgradeType Khaydarin_Core;
extern const UpgradeType Argus_Jewel;
extern const UpgradeType Argus_Talisman;
/// @}
extern const UpgradeType Upgrade_60;
extern const UpgradeType None;
extern const UpgradeType Unknown;
}
static_assert(sizeof(UpgradeType) == sizeof(int), "Expected type to resolve to primitive size.");
}

View file

@ -1,443 +0,0 @@
#pragma once
#include <BWAPI/Type.h>
namespace BWAPI
{
class TechType;
class UpgradeType;
class DamageType;
class ExplosionType;
class UnitType;
/// <summary>namespace containing weapon types.</summary>
/// @see WeaponType
namespace WeaponTypes
{
/// <summary>Enumeration of weapon types.</summary>
/// @see WeaponType
namespace Enum
{
/// <summary>Enumeration of weapon types.</summary>
/// @see WeaponType
enum Enum
{
Gauss_Rifle = 0,
Gauss_Rifle_Jim_Raynor = 1,
C_10_Canister_Rifle = 2,
C_10_Canister_Rifle_Sarah_Kerrigan = 3,
Fragmentation_Grenade = 4,
Fragmentation_Grenade_Jim_Raynor = 5,
Spider_Mines = 6,
Twin_Autocannons = 7,
Hellfire_Missile_Pack = 8,
Twin_Autocannons_Alan_Schezar = 9,
Hellfire_Missile_Pack_Alan_Schezar = 10,
Arclite_Cannon = 11,
Arclite_Cannon_Edmund_Duke = 12,
Fusion_Cutter = 13,
Gemini_Missiles = 15,
Burst_Lasers = 16,
Gemini_Missiles_Tom_Kazansky = 17,
Burst_Lasers_Tom_Kazansky = 18,
ATS_Laser_Battery = 19,
ATA_Laser_Battery = 20,
ATS_Laser_Battery_Hero = 21,
ATA_Laser_Battery_Hero = 22,
ATS_Laser_Battery_Hyperion = 23,
ATA_Laser_Battery_Hyperion = 24,
Flame_Thrower = 25,
Flame_Thrower_Gui_Montag = 26,
Arclite_Shock_Cannon = 27,
Arclite_Shock_Cannon_Edmund_Duke = 28,
Longbolt_Missile = 29,
Yamato_Gun = 30,
Nuclear_Strike = 31,
Lockdown = 32,
EMP_Shockwave = 33,
Irradiate = 34,
Claws = 35,
Claws_Devouring_One = 36,
Claws_Infested_Kerrigan = 37,
Needle_Spines = 38,
Needle_Spines_Hunter_Killer = 39,
Kaiser_Blades = 40,
Kaiser_Blades_Torrasque = 41,
Toxic_Spores = 42,
Spines = 43,
Acid_Spore = 46,
Acid_Spore_Kukulza = 47,
Glave_Wurm = 48,
Glave_Wurm_Kukulza = 49,
Seeker_Spores = 52,
Subterranean_Tentacle = 53,
Suicide_Infested_Terran = 54,
Suicide_Scourge = 55,
Parasite = 56,
Spawn_Broodlings = 57,
Ensnare = 58,
Dark_Swarm = 59,
Plague = 60,
Consume = 61,
Particle_Beam = 62,
Psi_Blades = 64,
Psi_Blades_Fenix = 65,
Phase_Disruptor = 66,
Phase_Disruptor_Fenix = 67,
Psi_Assault = 69,
Psionic_Shockwave = 70,
Psionic_Shockwave_TZ_Archon = 71,
Dual_Photon_Blasters = 73,
Anti_Matter_Missiles = 74,
Dual_Photon_Blasters_Mojo = 75,
Anti_Matter_Missiles_Mojo = 76,
Phase_Disruptor_Cannon = 77,
Phase_Disruptor_Cannon_Danimoth = 78,
Pulse_Cannon = 79,
STS_Photon_Cannon = 80,
STA_Photon_Cannon = 81,
Scarab = 82,
Stasis_Field = 83,
Psionic_Storm = 84,
Warp_Blades_Zeratul = 85,
Warp_Blades_Hero = 86,
Platform_Laser_Battery = 92,
Independant_Laser_Battery = 93,
Twin_Autocannons_Floor_Trap = 96,
Hellfire_Missile_Pack_Wall_Trap = 97,
Flame_Thrower_Wall_Trap = 98,
Hellfire_Missile_Pack_Floor_Trap = 99,
Neutron_Flare = 100,
Disruption_Web = 101,
Restoration = 102,
Halo_Rockets = 103,
Corrosive_Acid = 104,
Mind_Control = 105,
Feedback = 106,
Optical_Flare = 107,
Maelstrom = 108,
Subterranean_Spines = 109,
Warp_Blades = 111,
C_10_Canister_Rifle_Samir_Duran = 112,
C_10_Canister_Rifle_Infested_Duran = 113,
Dual_Photon_Blasters_Artanis = 114,
Anti_Matter_Missiles_Artanis = 115,
C_10_Canister_Rifle_Alexei_Stukov = 116,
None = 130,
Unknown,
MAX
};
}
}
/// <summary>This object identifies a weapon type used by a unit to attack and deal damage.</summary>
/// Some weapon types can be upgraded while others are used for special abilities.
///
/// @see WeaponTypes
/// @ingroup TypeClasses
class WeaponType : public Type<WeaponType, WeaponTypes::Enum::Unknown>
{
public:
/// @copydoc Type::Type(int)
WeaponType(int id = WeaponTypes::Enum::None);
/// <summary>Retrieves the technology type that must be researched before this weapon can
/// be used.</summary>
///
/// @returns TechType required by this weapon.
/// @retval TechTypes::None if no tech type is required to use this weapon.
/// @see TechType::getWeapon
TechType getTech() const;
/// <summary>Retrieves the unit type that is intended to use this weapon type.</summary>
///
/// @note There is a rare case where some hero unit types use the same weapon.
///
/// @todo specify which types use the same weapon
///
/// @returns The UnitType that uses this weapon.
/// @see UnitType::groundWeapon, UnitType::airWeapon
UnitType whatUses() const;
/// <summary>Retrieves the base amount of damage that this weapon can deal per attack.</summary>
///
/// @note That this damage amount must go through a DamageType and UnitSizeType filter
/// before it is applied to a unit.
///
/// @returns Amount of base damage that this weapon deals.
int damageAmount() const;
/// <summary>Determines the bonus amount of damage that this weapon type increases by for every
/// upgrade to this type.</summary>
///
/// @see upgradeType
/// @returns Amount of damage added for every weapon upgrade.
int damageBonus() const;
/// <summary>Retrieves the base amount of cooldown time between each attack, in frames.</summary>
///
/// @returns The amount of base cooldown applied to the unit after an attack.
/// @see UnitInterface::getGroundWeaponCooldown, UnitInterface::getAirWeaponCooldown
int damageCooldown() const;
/// <summary>Obtains the intended number of missiles/attacks that are used.</summary>
/// This is used to multiply with the damage amount to obtain the full amount of damage
/// for an attack.
///
/// @returns The damage factor multiplied by the amount to obtain the total damage.
/// @see damageAmount
int damageFactor() const;
/// <summary>Retrieves the upgrade type that increases this weapon's damage output.</summary>
///
/// @returns The UpgradeType used to upgrade this weapon's damage.
/// @see damageBonus
UpgradeType upgradeType() const;
/// <summary>Retrieves the damage type that this weapon applies to a unit type.</summary>
///
/// @returns DamageType used for damage calculation.
/// @see DamageType, UnitSizeType
DamageType damageType() const;
/// <summary>Retrieves the explosion type that indicates how the weapon deals damage.</summary>
///
/// @returns ExplosionType identifying how damage is applied to a target location.
ExplosionType explosionType() const;
/// <summary>Retrieves the minimum attack range of the weapon, measured in pixels.</summary>
/// This value is 0 for almost all weapon types, except for WeaponTypes::Arclite_Shock_Cannon
/// and WeaponTypes::Arclite_Shock_Cannon_Edmund_Duke.
///
/// @returns Minimum attack range, in pixels.
int minRange() const;
/// <summary>Retrieves the maximum attack range of the weapon, measured in pixels.</summary>
///
/// @returns Maximum attack range, in pixels.
int maxRange() const;
/// <summary>Retrieves the inner radius used for splash damage calculations, in pixels.</summary>
///
/// @returns Radius of the inner splash area, in pixels.
///
/// @todo Add damage calculation.
int innerSplashRadius() const;
/// <summary>Retrieves the middle radius used for splash damage calculations, in pixels.</summary>
///
/// @returns Radius of the middle splash area, in pixels.
///
/// @todo Add damage calculation.
int medianSplashRadius() const;
/// <summary>Retrieves the outer radius used for splash damage calculations, in pixels.</summary>
///
/// @returns Radius of the outer splash area, in pixels.
///
/// @todo Add damage calculation.
int outerSplashRadius() const;
/// <summary>Checks if this weapon type can target air units.</summary>
///
/// @returns true if this weapon type can target air units, and false otherwise.
/// @see UnitInterface::isFlying, UnitType::isFlyer
bool targetsAir() const;
/// <summary>Checks if this weapon type can target ground units.</summary>
///
/// @returns true if this weapon type can target ground units, and false otherwise.
/// @see UnitInterface::isFlying, UnitType::isFlyer
bool targetsGround() const;
/// <summary>Checks if this weapon type can only target mechanical units.</summary>
///
/// @returns true if this weapon type can only target mechanical units, and false otherwise.
/// @see targetsOrgOrMech, UnitType::isMechanical
bool targetsMechanical() const;
/// <summary>Checks if this weapon type can only target organic units.</summary>
///
/// @returns true if this weapon type can only target organic units, and false otherwise.
/// @see targetsOrgOrMech, UnitType::isOrganic
bool targetsOrganic() const;
/// <summary>Checks if this weapon type cannot target structures.</summary>
///
/// @returns true if this weapon type cannot target buildings, and false if it can.
/// @see UnitType::isBuilding
bool targetsNonBuilding() const;
/// <summary>Checks if this weapon type cannot target robotic units.</summary>
///
/// @returns true if this weapon type cannot target robotic units, and false if it can.
/// @see UnitType::isRobotic
bool targetsNonRobotic() const;
/// <summary>Checks if this weapon type can target the ground.</summary>
///
/// @note This is more for attacks like @Psi_Storm which can target a location, not to be
/// confused with attack move.
///
/// @returns true if this weapon type can target a location, and false otherwise.
bool targetsTerrain() const;
/// <summary>Checks if this weapon type can only target organic or mechanical units.</summary>
///
/// @returns true if this weapon type can only target organic or mechanical units, and false otherwise.
/// @see targetsOrganic, targetsMechanical, UnitType::isOrganic, UnitType::isMechanical
bool targetsOrgOrMech() const;
/// <summary>Checks if this weapon type can only target units owned by the same player.</summary>
/// This is used for WeaponTypes::Consume.
///
/// @returns true if this weapon type can only target your own units, and false otherwise.
/// @see UnitInterface::getPlayer
bool targetsOwn() const;
};
/// @ingroup Types
namespace WeaponTypes
{
/// <summary>Retrieves the set of all defined weapon types.</summary> This is a union between
/// the normal and special weapon types.
///
/// @returns set consisting of all defined weapon types.
/// @see normalWeaponTypes, specialWeaponTypes
const WeaponType::set& allWeaponTypes();
/// <summary>Retrieves the set of all defined normal weapon types.</summary> This set contains
/// all weapons that are not used for abilities.
///
/// @returns constant set consisting of all normal weapon types.
const WeaponType::set& normalWeaponTypes();
/// <summary>Retrieves the set of all special weapon types.</summary> This set contains all
/// weapons that are used exclusively for special unit abilities.
///
/// @returns constant set consisting of all special weapon types.
const WeaponType::set& specialWeaponTypes();
/// @name Normal Weapons
///@{
extern const WeaponType Gauss_Rifle;
extern const WeaponType Gauss_Rifle_Jim_Raynor;
extern const WeaponType C_10_Canister_Rifle;
extern const WeaponType C_10_Canister_Rifle_Sarah_Kerrigan;
extern const WeaponType C_10_Canister_Rifle_Samir_Duran;
extern const WeaponType C_10_Canister_Rifle_Infested_Duran;
extern const WeaponType C_10_Canister_Rifle_Alexei_Stukov;
extern const WeaponType Fragmentation_Grenade;
extern const WeaponType Fragmentation_Grenade_Jim_Raynor;
extern const WeaponType Spider_Mines;
extern const WeaponType Twin_Autocannons;
extern const WeaponType Twin_Autocannons_Alan_Schezar;
extern const WeaponType Hellfire_Missile_Pack;
extern const WeaponType Hellfire_Missile_Pack_Alan_Schezar;
extern const WeaponType Arclite_Cannon;
extern const WeaponType Arclite_Cannon_Edmund_Duke;
extern const WeaponType Fusion_Cutter;
extern const WeaponType Gemini_Missiles;
extern const WeaponType Gemini_Missiles_Tom_Kazansky;
extern const WeaponType Burst_Lasers;
extern const WeaponType Burst_Lasers_Tom_Kazansky;
extern const WeaponType ATS_Laser_Battery;
extern const WeaponType ATS_Laser_Battery_Hero;
extern const WeaponType ATS_Laser_Battery_Hyperion;
extern const WeaponType ATA_Laser_Battery;
extern const WeaponType ATA_Laser_Battery_Hero;
extern const WeaponType ATA_Laser_Battery_Hyperion;
extern const WeaponType Flame_Thrower;
extern const WeaponType Flame_Thrower_Gui_Montag;
extern const WeaponType Arclite_Shock_Cannon;
extern const WeaponType Arclite_Shock_Cannon_Edmund_Duke;
extern const WeaponType Longbolt_Missile;
extern const WeaponType Claws;
extern const WeaponType Claws_Devouring_One;
extern const WeaponType Claws_Infested_Kerrigan;
extern const WeaponType Needle_Spines;
extern const WeaponType Needle_Spines_Hunter_Killer;
extern const WeaponType Kaiser_Blades;
extern const WeaponType Kaiser_Blades_Torrasque;
extern const WeaponType Toxic_Spores;
extern const WeaponType Spines;
extern const WeaponType Acid_Spore;
extern const WeaponType Acid_Spore_Kukulza;
extern const WeaponType Glave_Wurm;
extern const WeaponType Glave_Wurm_Kukulza;
extern const WeaponType Seeker_Spores;
extern const WeaponType Subterranean_Tentacle;
extern const WeaponType Suicide_Infested_Terran;
extern const WeaponType Suicide_Scourge;
extern const WeaponType Particle_Beam;
extern const WeaponType Psi_Blades;
extern const WeaponType Psi_Blades_Fenix;
extern const WeaponType Phase_Disruptor;
extern const WeaponType Phase_Disruptor_Fenix;
extern const WeaponType Psi_Assault;
extern const WeaponType Psionic_Shockwave;
extern const WeaponType Psionic_Shockwave_TZ_Archon;
extern const WeaponType Dual_Photon_Blasters;
extern const WeaponType Dual_Photon_Blasters_Mojo;
extern const WeaponType Dual_Photon_Blasters_Artanis;
extern const WeaponType Anti_Matter_Missiles;
extern const WeaponType Anti_Matter_Missiles_Mojo;
extern const WeaponType Anti_Matter_Missiles_Artanis;
extern const WeaponType Phase_Disruptor_Cannon;
extern const WeaponType Phase_Disruptor_Cannon_Danimoth;
extern const WeaponType Pulse_Cannon;
extern const WeaponType STS_Photon_Cannon;
extern const WeaponType STA_Photon_Cannon;
extern const WeaponType Scarab;
extern const WeaponType Neutron_Flare;
extern const WeaponType Halo_Rockets;
extern const WeaponType Corrosive_Acid;
extern const WeaponType Subterranean_Spines;
extern const WeaponType Warp_Blades;
extern const WeaponType Warp_Blades_Hero;
extern const WeaponType Warp_Blades_Zeratul;
extern const WeaponType Independant_Laser_Battery;
extern const WeaponType Twin_Autocannons_Floor_Trap;
extern const WeaponType Hellfire_Missile_Pack_Wall_Trap;
extern const WeaponType Flame_Thrower_Wall_Trap;
extern const WeaponType Hellfire_Missile_Pack_Floor_Trap;
///@}
/// @name Special Weapons
///@{
extern const WeaponType Yamato_Gun;
extern const WeaponType Nuclear_Strike;
extern const WeaponType Lockdown;
extern const WeaponType EMP_Shockwave;
extern const WeaponType Irradiate;
extern const WeaponType Parasite;
extern const WeaponType Spawn_Broodlings;
extern const WeaponType Ensnare;
extern const WeaponType Dark_Swarm;
extern const WeaponType Plague;
extern const WeaponType Consume;
extern const WeaponType Stasis_Field;
extern const WeaponType Psionic_Storm;
extern const WeaponType Disruption_Web;
extern const WeaponType Restoration;
extern const WeaponType Mind_Control;
extern const WeaponType Feedback;
extern const WeaponType Optical_Flare;
extern const WeaponType Maelstrom;
///@}
extern const WeaponType None;
extern const WeaponType Unknown;
}
static_assert(sizeof(WeaponType) == sizeof(int), "Expected type to resolve to primitive size.");
}

View file

@ -1,34 +0,0 @@
#pragma once
typedef char CHAR;
typedef short SHORT;
typedef long LONG;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef int BOOL;
typedef void* HANDLE;
typedef void* PVOID;
typedef void* LPVOID;
#ifndef WINAPI
#define WINAPI __stdcall
#endif
#ifndef APIENTRY
#define APIENTRY WINAPI
#endif
#ifndef DLL_PROCESS_ATTACH
#define DLL_PROCESS_ATTACH 1
#define DLL_THREAD_ATTACH 2
#define DLL_THREAD_DETACH 3
#define DLL_PROCESS_DETACH 0
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif

View file

@ -1,59 +0,0 @@
#pragma once
#include <BWAPI.h>
#include <BWTA/Chokepoint.h>
#include <BWTA/Polygon.h>
#include <BWTA/Region.h>
#include <BWTA/BaseLocation.h>
#include <BWTA/RectangleArray.h>
namespace BWTA
{
void readMap();
void analyze();
void computeDistanceTransform();
void balanceAnalysis();
void cleanMemory();
int getMaxDistanceTransform();
RectangleArray<int>* getDistanceTransformMap();
const std::set<Region*>& getRegions();
const std::set<Chokepoint*>& getChokepoints();
const std::set<BaseLocation*>& getBaseLocations();
const std::set<BaseLocation*>& getStartLocations();
const std::set<Polygon*>& getUnwalkablePolygons();
BaseLocation* getStartLocation(BWAPI::Player player);
Region* getRegion(int x, int y);
Region* getRegion(BWAPI::TilePosition tileposition);
Region* getRegion(BWAPI::Position position);
Chokepoint* getNearestChokepoint(int x, int y);
Chokepoint* getNearestChokepoint(BWAPI::TilePosition tileposition);
Chokepoint* getNearestChokepoint(BWAPI::Position position);
BaseLocation* getNearestBaseLocation(int x, int y);
BaseLocation* getNearestBaseLocation(BWAPI::TilePosition tileposition);
BaseLocation* getNearestBaseLocation(BWAPI::Position position);
Polygon* getNearestUnwalkablePolygon(int x, int y);
Polygon* getNearestUnwalkablePolygon(BWAPI::TilePosition tileposition);
BWAPI::Position getNearestUnwalkablePosition(BWAPI::Position position);
bool isConnected(int x1, int y1, int x2, int y2);
bool isConnected(BWAPI::TilePosition a, BWAPI::TilePosition b);
double getGroundDistance(BWAPI::TilePosition start, BWAPI::TilePosition end);
std::pair<BWAPI::TilePosition, double> getNearestTilePosition(BWAPI::TilePosition start, const std::set<BWAPI::TilePosition>& targets);
std::map<BWAPI::TilePosition, double> getGroundDistances(BWAPI::TilePosition start, const std::set<BWAPI::TilePosition>& targets);
void getGroundDistanceMap(BWAPI::TilePosition start, RectangleArray<double>& distanceMap);
void getGroundWalkDistanceMap(int walkx, int walky, RectangleArray<double>& distanceMap);
std::vector<BWAPI::TilePosition> getShortestPath(BWAPI::TilePosition start, BWAPI::TilePosition end);
std::vector<BWAPI::TilePosition> getShortestPath(BWAPI::TilePosition start, const std::set<BWAPI::TilePosition>& targets);
// HPA* implementation
void buildChokeNodes();
std::list<Chokepoint*> getShortestPath2(BWAPI::TilePosition start, BWAPI::TilePosition target);
int getGroundDistance2(BWAPI::TilePosition start, BWAPI::TilePosition end);
}

View file

@ -1,29 +0,0 @@
#pragma once
#include <BWAPI.h>
namespace BWTA
{
class Region;
class BaseLocation
{
public:
virtual ~BaseLocation(){};
virtual BWAPI::Position getPosition() const = 0;
virtual BWAPI::TilePosition getTilePosition() const = 0;
virtual Region* getRegion() const = 0;
virtual int minerals() const = 0;
virtual int gas() const = 0;
virtual const BWAPI::Unitset &getMinerals() = 0;
virtual const BWAPI::Unitset &getStaticMinerals() const = 0;
virtual const BWAPI::Unitset &getGeysers() const = 0;
virtual double getGroundDistance(BaseLocation* other) const = 0;
virtual double getAirDistance(BaseLocation* other) const = 0;
virtual bool isIsland() const = 0;
virtual bool isMineralOnly() const = 0;
virtual bool isStartLocation() const = 0;
};
}

View file

@ -1,16 +0,0 @@
#pragma once
#include <utility>
#include <BWAPI.h>
namespace BWTA
{
class Region;
class Chokepoint
{
public:
virtual ~Chokepoint(){};
virtual const std::pair<Region*, Region*>& getRegions() const = 0;
virtual const std::pair<BWAPI::Position, BWAPI::Position>& getSides() const = 0;
virtual BWAPI::Position getCenter() const = 0;
virtual double getWidth() const = 0;
};
}

View file

@ -1,19 +0,0 @@
#pragma once
#include <BWAPI.h>
#include <vector>
namespace BWTA
{
class Polygon : public std::vector <BWAPI::Position>
{
public:
Polygon();
Polygon(const Polygon& b);
double getArea() const;
double getPerimeter() const;
BWAPI::Position getCenter() const;
bool isInside(BWAPI::Position p) const;
BWAPI::Position getNearestPoint(BWAPI::Position p) const;
const std::vector<Polygon>& getHoles() const;
std::vector<Polygon> holes;
};
}

View file

@ -1,283 +0,0 @@
#pragma once
namespace BWTA
{
/**
* Template used for work with dynamically initialized array with dimension 2.
*/
template <class Type>
class RectangleArray
{
public :
/**
* Creates the array with the specified proportions.
* @param width Width of the new array.
* @param height Height of the new array.
*/
RectangleArray(unsigned int width = 1, unsigned int height = 1, Type* data = NULL);
/** Copy constructor */
RectangleArray(const RectangleArray<Type>& rectangleArray);
/** Assignment operator */
const RectangleArray& operator=(const RectangleArray<Type>& rectangleArray);
/** Destroys the array and deletes all content of array. */
~RectangleArray(void);
/**
* Gets the width of the array.
* @return width of the array.
*/
unsigned int getWidth(void) const;
/**
* Gets the height of the array.
* @return height of the array.
*/
unsigned int getHeight(void) const;
/**
* Gets item of the array on the specified position.
* @param x horizontal index of the array position.
* @param y vertical index of the array position.
* @return item on the specified position.
*/
Type getItem(unsigned int x, unsigned int y);
Type getItemSafe(unsigned int x, unsigned int y);
inline Type* operator[](int i) { return this->getColumn(i); }
inline Type const * const operator[](int i) const {return this->getColumn(i); }
/**
* Sets item of the array on the specified position.
* @param x horizontal index of the array position.
* @param y vertical index of the array position.
* @param item new value of the field.
*/
void setItem(unsigned int x, unsigned int y, Type *item);
void resize(unsigned int width, unsigned int height);
void saveToFile(const std::string& fileName);
/** Sets all fields of the array to the specified value */
void setTo(const Type& value);
void setBorderTo(const Type& value);
/** Set a rectangle area of the array to the specified values */
void setRectangleTo(unsigned int xLeft, unsigned int yTop, unsigned int xRight, unsigned int yBottom, const Type& value);
private :
bool owner;
/** width of array */
unsigned int width;
/** height of array */
unsigned int height;
/** Array data, stored as linear array of size width*height */
Type *data;
/** Pointers to begins of lines*/
Type **columns;
/**
* Gets data item on the specified index
* @param index index of the data to be returned.
*/
Type getData(unsigned int index);
/**
* Gets the pointer in data to the beginning of line with the specified
* index.
* @param index index of the line.
*/
Type *getColumn(unsigned int index);
/**
* Gets the pointer in data to the beginning of line with the specified
* index.
* @param index index of the line.
*/
const Type *getColumn(unsigned int index) const;
/**
* Sets the width of the array.
* @param width New width of the array.
*/
void setWidth(unsigned int width);
/**
* Sets the height of the array.
* @param height New height of the array.
*/
void setHeight(unsigned int height);
};
//---------------------------------------------- CONSTRUCTOR -----------------------------------------------
template <class Type>
RectangleArray<Type>::RectangleArray(unsigned int width, unsigned int height, Type* data)
{
this->setWidth(width);
this->setHeight(height);
this->owner = (data == NULL);
if (this->owner)
this->data = new Type[this->getWidth()*this->getHeight()];
else
this->data = data;
columns = new Type*[this->getWidth()];
unsigned int i = 0;
for (unsigned int position = 0;i < width; i ++,position += height)
columns[i] = &this->data[position];
}
//-------------------------------------------- COPY CONSTRUCTOR --------------------------------------------
template <class Type>
RectangleArray<Type>::RectangleArray(const RectangleArray<Type>& rectangleArray)
:owner(true)
{
this->setWidth(rectangleArray.getWidth());
this->setHeight(rectangleArray.getHeight());
this->data = new Type[this->getWidth()*this->getHeight()];
columns = new Type*[this->getWidth()];
unsigned int i = 0;
for (unsigned int position = 0;i < width; i ++,position += height)
columns[i] = &data[position];
memcpy(this->data, rectangleArray.data, sizeof(Type)*this->getWidth()*this->getHeight());
}
//------------------------------------------ ASSIGNMENT OPERATOR -------------------------------------------
template <class Type>
const RectangleArray<Type>& RectangleArray<Type>::operator=(const RectangleArray<Type>& rectangleArray)
{
this->setWidth(rectangleArray.getWidth());
this->setHeight(rectangleArray.getHeight());
this->owner = true;
this->data = new Type[this->getWidth()*this->getHeight()];
columns = new Type*[this->getWidth()];
unsigned int i = 0;
for (unsigned int position = 0; i < width; i++, position += height)
columns[i] = &data[position];
memcpy(this->data, rectangleArray.data, sizeof(Type)*this->getWidth()*this->getHeight());
return *this;
}
//----------------------------------------------- DESTRUCTOR -----------------------------------------------
template <class Type>
RectangleArray<Type>::~RectangleArray(void)
{
delete [] columns;
if (this->owner)
delete [] data;
}
//----------------------------------------------- GET WIDTH ------------------------------------------------
template <class Type>
unsigned int RectangleArray<Type>::getWidth(void) const
{
return this->width;
}
//----------------------------------------------- SET WIDTH ------------------------------------------------
template <class Type>
void RectangleArray<Type>::setWidth(unsigned int width)
{
this->width = width;
}
//----------------------------------------------- GET HEIGHT -----------------------------------------------
template <class Type>
unsigned int RectangleArray<Type>::getHeight(void) const
{
return this->height;
}
//----------------------------------------------- SET HEIGHT -----------------------------------------------
template <class Type>
void RectangleArray<Type>::setHeight(unsigned int height)
{
this->height = height;
}
//------------------------------------------------ GET ITEM ------------------------------------------------
template <class Type>
Type RectangleArray<Type>::getItem(unsigned int x, unsigned int y)
{
return this->getColumn(x)[y];
}
//------------------------------------------------ GET ITEM ------------------------------------------------
template <class Type>
Type RectangleArray<Type>::getItemSafe(unsigned int x, unsigned int y)
{
if (x<0 || y<0 || x>=this->width || y>=this->height)
{
return (Type)NULL;
}
return this->getColumn(x)[y];
}
//------------------------------------------------ SET ITEM ------------------------------------------------
template <class Type>
void RectangleArray<Type>::setItem(unsigned int x, unsigned int y, Type* item)
{
this->getColumn(x)[y] = item;
}
//------------------------------------------------ GET LINE ------------------------------------------------
template <class Type>
Type* RectangleArray<Type>::getColumn(unsigned int index)
{
return columns[index];
}
//------------------------------------------------ GET LINE ------------------------------------------------
template <class Type>
const Type* RectangleArray<Type>::getColumn(unsigned int index) const
{
return columns[index];
}
//------------------------------------------------- RESIZE -------------------------------------------------
template <class Type>
void RectangleArray<Type>::resize(unsigned int width, unsigned int height)
{
if (this->getWidth() == width &&
this->getHeight() == height)
return;
delete [] this->columns;
delete [] this->data;
this->setWidth(width);
this->setHeight(height);
this->data = new Type[this->width * this->height];
this->columns = new Type*[this->width];
unsigned int i = 0;
for (unsigned int position = 0;i < this->width; i ++,position += this->height)
columns[i] = &data[position];
}
//---------------------------------------------- SAVE TO FILE ----------------------------------------------
template <class Type>
void RectangleArray<Type>::saveToFile(const std::string& fileName)
{
std::ofstream outputFile(fileName);
if (!outputFile)
exit(1);
for (unsigned int y = 0; y < this->getHeight(); ++y) {
for (unsigned int x = 0; x < this->getWidth(); ++x) {
outputFile << this->getColumn(x)[y];
}
outputFile << std::endl;
}
outputFile.close();
}
//------------------------------------------------- SET TO -------------------------------------------------
template <class Type>
void RectangleArray<Type>::setTo(const Type& value)
{
for (unsigned int i = 0; i < this->getWidth()*this->getHeight(); i++)
this->data[i] = value;
}
//--------------------------------------------- SET BORDER TO ----------------------------------------------
template <class Type>
void RectangleArray<Type>::setBorderTo(const Type& value)
{
for (unsigned int i = 0; i < this->width; i++)
{
this->getColumn(i)[0] = value;
this->getColumn(i)[this->height - 1] = value;
}
for (unsigned int i = 0; i < this->height; i++)
{
this->getColumn(0)[i] = value;
this->getColumn(this->width - 1)[i] = value;
}
}
//------------------------------------------- SET RECTANGLE TO ---------------------------------------------
template <class Type>
void RectangleArray<Type>::setRectangleTo(unsigned int xLeft, unsigned int yTop, unsigned int xRight, unsigned int yBottom, const Type& value) {
xLeft = std::max<int>(xLeft,0);
yTop = std::max<int>(yTop,0);
xRight = std::min<int>(xRight,this->width-1);
yBottom = std::min<int>(yBottom,this->height-1);
for (unsigned int x = xLeft; x <= xRight; x++) {
for (unsigned int y = yTop; y <= yBottom; y++) {
this->getColumn(x)[y] = value;
}
}
}
//----------------------------------------------------------------------------------------------------------
}

View file

@ -1,21 +0,0 @@
#pragma once
#include <BWAPI.h>
#include <set>
#include <BWTA/Polygon.h>
namespace BWTA
{
class Chokepoint;
class BaseLocation;
class Region
{
public:
virtual ~Region() {};
virtual const Polygon& getPolygon() const = 0;
virtual const BWAPI::Position& getCenter() const = 0;
virtual const std::set<Chokepoint*>& getChokepoints() const = 0;
virtual const std::set<BaseLocation*>& getBaseLocations() const = 0;
virtual bool isReachable(Region* region) const = 0;
virtual const std::set<Region*>& getReachableRegions() const = 0;
virtual const int getMaxDistance() const = 0;
};
}

View file

@ -319,17 +319,29 @@ public class CJavaPipeline {
System.out.println("Absolute base path: " + basePath.getAbsolutePath());
System.out.println();
if (System.getenv("BWAPI_HOME") == null || !(new File(System.getenv("BWAPI_HOME")).exists())) {
System.out.println("Missing or unable to read environment variable BWAPI_HOME.");
System.exit(1);
return;
}
if (System.getenv("BWTA_HOME") == null || !(new File(System.getenv("BWTA_HOME")).exists())) {
System.out.println("Missing or unable to read environment variable BWTA_HOME.");
System.exit(1);
return;
}
try {
ignoredClasses.add("Position");
PackageProcessOptions bwapiOptions = new PackageProcessOptions();
bwapiOptions.packageName = "bwapi";
bwapiOptions.cHeadersDir = new File(basePath.getPath() + "/bwapi-includes");
bwapiOptions.manualCopyClassesDir = new File(basePath.getPath() + "/manual-bwapi");
bwapiOptions.cHeadersDir = new File(System.getenv("BWAPI_HOME") + "/include");
bwapiOptions.manualCopyClassesDir = new File(basePath.getPath() + "/manual-bwapi-src");
PackageProcessOptions bwtaOptions = new PackageProcessOptions();
bwtaOptions.packageName = "bwta";
bwtaOptions.cHeadersDir = new File(basePath.getPath() + "/bwta2-includes");
bwtaOptions.cHeadersDir = new File(System.getenv("BWTA_HOME") + "/include");
bwtaOptions.additionalImportClasses = Arrays.asList("bwapi.Position", "bwapi.TilePosition", "bwapi.Player", "bwapi.Unit", "bwapi.Pair");
bwtaOptions.globalClassName = "BWTA";