sc2ai 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/data/sc2ai/protocol/data.proto +1 -1
- data/data/sc2ai/protocol/raw.proto +1 -1
- data/docker_build/Dockerfile.ruby +16 -16
- data/lib/sc2ai/api/data.rb +59 -1
- data/lib/sc2ai/cli/cli.rb +5 -20
- data/lib/sc2ai/connection/requests.rb +4 -1
- data/lib/sc2ai/local_play/match.rb +2 -2
- data/lib/sc2ai/player/game_state.rb +0 -7
- data/lib/sc2ai/player/units.rb +12 -8
- data/lib/sc2ai/player.rb +26 -1
- data/lib/sc2ai/protocol/extensions/player_common.rb +25 -0
- data/lib/sc2ai/protocol/extensions/position.rb +1 -1
- data/lib/sc2ai/protocol/extensions/unit.rb +59 -14
- data/lib/sc2ai/protocol/extensions/unit_type_data.rb +30 -0
- data/lib/sc2ai/unit_group/filter_ext.rb +23 -2
- data/lib/sc2ai/version.rb +1 -1
- data/lib/templates/new/api/data.proto +1 -1
- data/lib/templates/new/api/raw.proto +1 -1
- data/lib/templates/new/run_example_match.rb.tt +1 -1
- data/sig/sc2ai.rbs +143 -86
- metadata +13 -16
@@ -23,6 +23,36 @@ module Api
|
|
23
23
|
# i.e. 2 for Supply Depot (2x2)
|
24
24
|
# @return [Integer] side-length for placement
|
25
25
|
attr_accessor :placement_length
|
26
|
+
|
27
|
+
# @!attribute ground_range
|
28
|
+
# Ground weapon range or 0.0 when it can't shoot ground
|
29
|
+
# @return [Float]
|
30
|
+
attr_accessor :ground_range
|
31
|
+
|
32
|
+
# @!attribute air_range
|
33
|
+
# Air weapon range or 0.0 when it can't shoot air
|
34
|
+
# @return [Float]
|
35
|
+
attr_accessor :air_range
|
36
|
+
|
37
|
+
# @!attribute ground_damage
|
38
|
+
# Ground weapon damage or 0.0
|
39
|
+
# @return [Float]
|
40
|
+
attr_accessor :ground_damage
|
41
|
+
|
42
|
+
# @!attribute air_damage
|
43
|
+
# Air weapon damage or 0.0
|
44
|
+
# @return [Float]
|
45
|
+
attr_accessor :air_damage
|
46
|
+
|
47
|
+
# @!attribute ground_dps
|
48
|
+
# Ground weapon damage per second or 0.0
|
49
|
+
# @return [Float]
|
50
|
+
attr_accessor :ground_dps
|
51
|
+
|
52
|
+
# @!attribute air_dps
|
53
|
+
# Air weapon damage per second or 0.0
|
54
|
+
# @return [Float]
|
55
|
+
attr_accessor :air_dps
|
26
56
|
end
|
27
57
|
end
|
28
58
|
Api::UnitTypeData.prepend Api::UnitTypeDataExtension
|
@@ -74,6 +74,18 @@ module Sc2
|
|
74
74
|
Api::UnitTypeId::HATCHERY, Api::UnitTypeId::HIVE, Api::UnitTypeId::LAIR,
|
75
75
|
Api::UnitTypeId::NEXUS
|
76
76
|
].freeze
|
77
|
+
|
78
|
+
# An array of passive detector unit types.
|
79
|
+
# Does not include units with detection abilities, such as Oracle/Ghost
|
80
|
+
# @return [Array<Integer>]
|
81
|
+
TYPE_DETECTORS = [
|
82
|
+
Api::UnitTypeId::RAVEN, Api::UnitTypeId::MISSILETURRET,
|
83
|
+
Api::UnitTypeId::OBSERVER, Api::UnitTypeId::OBSERVERSIEGEMODE,
|
84
|
+
Api::UnitTypeId::PHOTONCANNON,
|
85
|
+
Api::UnitTypeId::OVERSEER, Api::UnitTypeId::OVERSEERSIEGEMODE,
|
86
|
+
Api::UnitTypeId::SPORECRAWLER
|
87
|
+
].freeze
|
88
|
+
|
77
89
|
# Returns a new UnitGroup containing all units matching unit type id(s)
|
78
90
|
# Multiple values work as an "OR" filter
|
79
91
|
# @example
|
@@ -254,6 +266,12 @@ module Sc2
|
|
254
266
|
alias_method :extractors, :gas
|
255
267
|
alias_method :assimilators, :gas
|
256
268
|
|
269
|
+
# Selects units passively have Detection
|
270
|
+
# @return [UnitGroup] gas structures
|
271
|
+
def detectors
|
272
|
+
select_type(TYPE_DETECTORS)
|
273
|
+
end
|
274
|
+
|
257
275
|
# Selects only units which have finished constructing, i.o.w. build_progress == 1.0
|
258
276
|
# @return [UnitGroup] complete unit group
|
259
277
|
def completed
|
@@ -374,7 +392,7 @@ module Sc2
|
|
374
392
|
select_type(Api::UnitTypeId::CREEPTUMORBURROWED)
|
375
393
|
end
|
376
394
|
|
377
|
-
#
|
395
|
+
# PROTOSS ---
|
378
396
|
|
379
397
|
# Selects pylons
|
380
398
|
# @return [Sc2::UnitGroup] pylons
|
@@ -416,7 +434,10 @@ module Sc2
|
|
416
434
|
# @param pos [Sc2::Position] unit.pos or a point of any kind
|
417
435
|
# @return [Sc2::UnitGroup, Api::Unit, nil] return group or single unit if amount is not supplied
|
418
436
|
def nearest_to(pos:, amount: nil)
|
419
|
-
|
437
|
+
unless amount.nil?
|
438
|
+
return UnitGroup.new if amount <= 0
|
439
|
+
return self if amount > @units.size
|
440
|
+
end
|
420
441
|
|
421
442
|
if use_kdtree
|
422
443
|
if amount.nil?
|
data/lib/sc2ai/version.rb
CHANGED
@@ -89,7 +89,7 @@ message UnitTypeData {
|
|
89
89
|
optional float sight_range = 25; // Range unit reveals vision.
|
90
90
|
|
91
91
|
repeated uint32 tech_alias = 21 [packed=false]; // Other units that satisfy the same tech requirement.
|
92
|
-
optional uint32 unit_alias = 22
|
92
|
+
optional uint32 unit_alias = 22; // The morphed variant of this unit.
|
93
93
|
|
94
94
|
optional uint32 tech_requirement = 23; // Structure required to build this unit. (Or any with the same tech_alias)
|
95
95
|
optional bool require_attached = 24; // Whether tech_requirement is an add-on.
|