Skip to content

Commit

Permalink
feat: add unit#build_reactor and unit#tech_lab's queue_command variab…
Browse files Browse the repository at this point in the history
…les, incase they need to land and then build.
  • Loading branch information
dysonreturns committed Mar 11, 2024
1 parent afb0e5e commit e5d6e95
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
1 change: 0 additions & 1 deletion lib/sc2ai/player/geometry.rb
Expand Up @@ -549,7 +549,6 @@ def geysers_for_base(base)
expansions[pos]
end


# Gets buildable point grid for squares of size, i.e. 3 = 3x3 placements
# Uses pathing grid internally, to ignore taken positions
# Does not query the api and is generally fast.
Expand Down
14 changes: 9 additions & 5 deletions lib/sc2ai/protocol/extensions/unit.rb
Expand Up @@ -481,20 +481,24 @@ def has_tech_lab

# For Terran builds a tech lab add-on on the current structure
# @return [void]
def build_reactor
build(unit_type_id: Api::UnitTypeId::REACTOR)
def build_reactor(queue_command: false)
build(unit_type_id: Api::UnitTypeId::REACTOR, queue_command:)
end

# For Terran builds a tech lab add-on on the current structure
# @return [void]
def build_tech_lab
build(unit_type_id: Api::UnitTypeId::TECHLAB)
def build_tech_lab(queue_command: false)
build(unit_type_id: Api::UnitTypeId::TECHLAB, queue_command:)
end

# GENERAL Convenience functions ---

# ...

private

# @private
# Reduces repitition in the is_*action*?(target:) methods
# Reduces repetition in the is_*action*?(target:) methods
def is_performing_ability_on_target?(abilities, target: nil)
# Exit if not actioning the ability
return false unless is_performing_ability?(abilities)
Expand Down
35 changes: 29 additions & 6 deletions sig/sc2ai.rbs
Expand Up @@ -1928,6 +1928,25 @@ module Sc2
# ```
def expansions_unoccupied: () -> (SORD_ERROR_HashApiPoint2D | UnitGroup)

# Gets minerals for a base or base position
#
# _@param_ `base` — base Unit or Position
#
# _@return_ — UnitGroup of minerals for the base
def minerals_for_base: ((Api::Unit | Sc2::Position) base) -> Sc2::UnitGroup

# Gets geysers for a base or base position
#
# _@param_ `base` — base Unit or Position
#
# _@return_ — UnitGroup of geysers for the base
def geysers_for_base: ((Api::Unit | Sc2::Position) base) -> Sc2::UnitGroup

# _@param_ `base` — base Unit or Position
#
# _@return_ — UnitGroup of resources (minerals+geysers)
def resources_for_base: ((Api::Unit | Sc2::Position) base) -> Sc2::UnitGroup

# sord omit - no YARD type given for "in_power:", using untyped
# Gets buildable point grid for squares of size, i.e. 3 = 3x3 placements
# Uses pathing grid internally, to ignore taken positions
Expand Down Expand Up @@ -8843,15 +8862,17 @@ module Api
# ```
def has_tech_lab: () -> bool

# sord omit - no YARD type given for "queue_command:", using untyped
# For Terran builds a tech lab add-on on the current structure
def build_reactor: () -> void
def build_reactor: (?queue_command: untyped) -> void

# sord omit - no YARD type given for "queue_command:", using untyped
# For Terran builds a tech lab add-on on the current structure
def build_tech_lab: () -> void
def build_tech_lab: (?queue_command: untyped) -> void

# sord omit - no YARD type given for "abilities", using untyped
# sord omit - no YARD type given for "target:", using untyped
# Reduces repitition in the is_*action*?(target:) methods
# Reduces repetition in the is_*action*?(target:) methods
def is_performing_ability_on_target?: (untyped abilities, ?target: untyped) -> bool

# Every unit gets access back to the bot to allow api access.
Expand Down Expand Up @@ -9881,15 +9902,17 @@ module Api
# ```
def has_tech_lab: () -> bool

# sord omit - no YARD type given for "queue_command:", using untyped
# For Terran builds a tech lab add-on on the current structure
def build_reactor: () -> void
def build_reactor: (?queue_command: untyped) -> void

# sord omit - no YARD type given for "queue_command:", using untyped
# For Terran builds a tech lab add-on on the current structure
def build_tech_lab: () -> void
def build_tech_lab: (?queue_command: untyped) -> void

# sord omit - no YARD type given for "abilities", using untyped
# sord omit - no YARD type given for "target:", using untyped
# Reduces repitition in the is_*action*?(target:) methods
# Reduces repetition in the is_*action*?(target:) methods
def is_performing_ability_on_target?: (untyped abilities, ?target: untyped) -> bool
end

Expand Down

0 comments on commit e5d6e95

Please sign in to comment.