UpgradeType¶
-
class
BWAPI.UpgradeType¶ The upgrade type represents a passive upgrade that can be obtained with
Unit.upgrade().See also
Constructors
-
UpgradeType([id = UpgradeTypes.Enum.None])¶ Expected type constructor.
If the type is an invalid type, then it becomes
Unknown. A type is invalid if its value is less than 0 or greater thanUnknown.Parameters: id (int) – 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 Unknown.
Member Functions
-
getID() → int¶ Retrieves this type’s identifier as an integer.
Returns: An integer representation of this type. Return type: int
-
isValid() → boolean¶ Checks if the current type has a valid identifier. 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: trueif this type is valid andfalseotherwise.Return type: boolean
-
getName() → string¶ Returns: The variable name of the type. Return type: string
-
gasPrice([level = 1]) → int¶ Returns the vespene gas price for the first upgrade.
Parameters: level (int) – (optional) The next upgrade level. Returns: The gas cost of the upgrade for the given level.Return type: int Note
Upgrades start at level 0.
-
gasPriceFactor() → int¶ Returns the amount that the vespene gas price increases for each additional upgrade.
Returns: The gas cost added to the upgrade after each level. Return type: int
-
getRace() → Race¶ Retrieves the race the upgrade is for.
For example,
BWAPI.UpgradeTypes.Terran_Infantry_Armor:getRace()will returnRaces.Terran.Returns: Racethat this upgrade belongs to.Return type: BWAPI.Race
-
maxRepeats() → int¶ Returns the maximum number of times the upgrade can be researched.
Returns: Maximum number of times this upgrade can be upgraded. Return type: int
-
mineralPrice([level = 1]) → int¶ Returns the mineral price for the upgrade.
Parameters: level (int) – (optional) The next upgrade level. Returns: The mineral cost of the upgrade for the given level.Return type: int Note
Upgrades start at level 0.
-
mineralPriceFactor() → int¶ The amount that the mineral price increases for each additional upgrade.
Returns: The mineral cost added to the upgrade after each level. Return type: int
-
upgradeTime([level = 1]) → int¶ Returns the number of frames needed to research the first upgrade.
Parameters: level (int) – (optional) The next upgrade level. Returns: The time cost of the upgrade for the given level.Return type: int Note
Upgrades start at level 0.
-
upgradeTimeFactor() → int¶ Returns the number of frames that the upgrade time increases for each additional upgrade.
Returns: The time cost added to the upgrade after each level. Return type: int
-
whatsRequired([level = 1]) → UnitType¶ Returns the type of unit that is required for the upgrade.
The player must have at least one of these units completed in order to start upgrading this upgrade.
Parameters: level (int) – (optional) The next upgrade level. Returns: UnitTyperequired to obtain this upgrade.Return type: BWAPI.UnitTypeNote
Upgrades start at level 0.
-
whatUpgrades() → UnitType¶ Returns the type of unit that researches the upgrade.
Returns: The UnitTypethat is used to upgrade this type.Return type: BWAPI.UnitType
-
whatUses() → UnitTypeset¶ Returns the set of units that are affected by this upgrade.
Returns: Set of unit types that passively use this upgrade type. Return type: BWAPI.UnitTypeset
-
UpgradeTypeset¶
-
class
BWAPI.UpgradeTypeset¶ A container for a set of
UpgradeTypeobjects.Constructors
-
UpgradeTypeset()¶ Default constructor.
-
UpgradeTypeset(set) Copy constructor.
Parameters: set (BWAPI.UpgradeTypeset) – The UpgradeTypeset to copy.
-
UpgradeTypeset(tbl) Constructor to convert a Lua table to a set. Any values in the table that are of type
UpgradeTypeare added to the set.Parameters: tbl (table) – A table containing UpgradeTypeobjects.
Member Functions
-
iterator() → iteratorFunction¶ Returns an iterator function intended to be used in
forloops (e.g.for item in set:iterator() do).Returns: An iterator function that will return the next value in the set with each successive call. Return type: function
-
asTable() → table¶ Returns the values of the set as an array-like Lua table.
Note
The ordering of the returned table is arbitrary (due to sets being unordered in the C++ implementation).
Returns: An array-like Lua table containing each value in the set. Return type: table
-
count(val) → int¶ Searches the set for elements with a value of
valand returns the number of elements found. Because sets do not allow for duplicate values, this means that the function will return either1or0. Because of this, it’s recommended to usecontains()instead.See also
-
contains(val) → boolean¶ Checks if this set contains a specific value.
Returns: trueif the set contains the specified value, orfalseotherwise.Return type: boolean
-
size() → int¶ Returns: The number of values in the set. Return type: int Note
set:size()is exactly equivalent to#set
-
empty() → boolean¶ Returns: trueif the set is empty (size() == 0), orfalseotherwise.Return type: boolean
-
insert(val)¶ Inserts the value into the set.
Note
Sets cannot contain duplicate values. If the value already exists in the set, the set will not be modified.
-
erase(val) → numElementsErased¶ Removes
valfrom the set if it exists.Returns: The number of elements removed. Because sets do not allow for duplicate values, this means that the function will return either 1or0.Return type: int
-
clear()¶ Removes all elements from the set, leaving it with a size of 0.
-
eraseIf(pred)¶ Iterates the set and erases each element x where pred(x) returns true. The set is modified in place.
Parameters: pred (function) – A predicate function that takes a value and returns truefor values that should be erased andfalseotherwise.
-
filter(pred)¶ Iterates the set and erases each element x where pred(x) returns false. The set is modified in place.
Parameters: pred (function) – A predicate function that takes a value and returns truefor values that should be kept andfalsefor elements that should be erased.
-