BWAPI
SnippyHolloW-BroodwarBotQ-f01ab56/src/Macro/Task.h
Go to the documentation of this file.
00001 #pragma once
00002 #include <BWAPI.h>
00003 #include "Macro/Resources.h"
00004 namespace TaskTypes
00005 {
00006   enum Enum
00007   {
00008     None,
00009     Unit,
00010     Tech,
00011     Upgrade
00012   };
00013 }
00014 /* A Task object is either a UnitType, TechType, or UpgradeType (+ level) with state information about the current status of the Task
00015    May want to split into TaskType class (purely unit/upgrade/tech type information) and Task class (holds TaskType + status information) in the future,
00016    but this works for now.
00017 */
00018 class Task
00019 {
00020   public:
00021     Task();
00022     Task(const BWAPI::UnitType t,                             const BWAPI::TilePosition p = BWAPI::TilePositions::None);
00023     Task(const BWAPI::TechType t,                             const BWAPI::TilePosition p = BWAPI::TilePositions::None);
00024     Task(const BWAPI::UpgradeType t, int l = -1,              const BWAPI::TilePosition p = BWAPI::TilePositions::None);
00025 
00026     Task& operator=(const Task t);
00027     Task& setType(const BWAPI::UnitType t,    const BWAPI::TilePosition p = BWAPI::TilePositions::None);
00028     Task& setType(const BWAPI::TechType t,    const BWAPI::TilePosition p = BWAPI::TilePositions::None);
00029     Task& setType(const BWAPI::UpgradeType t, int l = -1,    const BWAPI::TilePosition p = BWAPI::TilePositions::None);
00030     Task& setLevel(int l);
00031     Task& setTilePosition(const BWAPI::TilePosition p);
00032 
00033     bool operator==(void* ptr) const;
00034     bool operator!=(void* ptr) const;
00035     bool operator==(const Task &t) const;
00036     bool operator<(const Task &t) const;
00037     bool operator==(const BWAPI::UnitType &t) const;
00038     bool operator==(const BWAPI::TechType &t) const;
00039     bool operator==(const BWAPI::UpgradeType &t) const;
00040     bool operator==(const BWAPI::TilePosition &p) const;
00041 
00042     /* Returns true if the given unit is executing this task */
00043     bool isBeingExecutedBy(const BWAPI::Unit* unit) const;
00044 
00045     /* Returns TaskTypes::Unit, TaskTypes::Tech, or TaskTypes::Upgrade */
00046     TaskTypes::Enum getType() const;
00047 
00049     BWAPI::UnitType getUnit() const;
00050 
00052     BWAPI::TechType getTech() const;
00053 
00055     BWAPI::UpgradeType getUpgrade() const;
00056 
00058     int getLevel() const;
00059 
00061     BWAPI::TilePosition getTilePosition() const;
00062 
00064     BWAPI::UnitType getWorkerType() const;
00065 
00067     BWAPI::Race getRace() const;
00068 
00070     std::map<BWAPI::UnitType, int> getRequiredUnits() const;
00071 
00072     /* Cost of the UnitType, TechType, or UpgradeType (incl level) */
00073     Resources getResources() const;
00074 
00075     /* Build Time, Research Time, or Upgrade Time (incl level) */
00076     int getTime() const;
00077 
00078     /* Name of the UnitType, TechType, or UpgradeType */
00079     std::string getName() const;
00080 
00082     std::string getVerb() const;
00083 
00085     void setEarliestStartTime(int time);
00086     int getEarliestStartTime() const;
00087 
00089     void setStartTime(int time);
00090     int getStartTime() const;
00092     int getFinishTime() const;
00093 
00095     int getRemainingTime() const;
00096 
00097     void setSpentResources(bool spent);
00098     bool hasSpentResources() const;
00099 
00100     void setExecuting(bool exec);
00101     bool isExecuting() const;
00102 
00103     void setReservedResourcesThisFrame(bool reserved);
00104     bool hasReservedResourcesThisFrame() const;
00105 
00106     void setReservedFinishDataThisFrame(bool reserved);
00107     bool hasReservedFinishDataThisFrame() const;
00108 
00109     void setCompleted(bool c);
00110     bool isCompleted() const;
00111 
00112   private:
00113     TaskTypes::Enum type;
00114     int id;
00115     int level;
00116     BWAPI::TilePosition position;
00117     int earliestStartTime;
00118     int startTime;
00119     bool spentResources;
00120     bool reservedResourcesThisFrame;
00121     bool reservedFinishDataThisFrame;
00122     bool completed;
00123     bool executing;
00124 };
00125 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines