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
data/sig/sc2ai.rbs
CHANGED
@@ -396,6 +396,9 @@ module Sc2
|
|
396
396
|
# _@return_ — ladder matches will set an opponent id
|
397
397
|
attr_accessor opponent_id: String
|
398
398
|
|
399
|
+
# _@return_ — callbacks implemented on player class
|
400
|
+
attr_accessor callbacks_defined: ::Array[Symbol]
|
401
|
+
|
399
402
|
# An object which interacts with an SC2 client and is game-aware.
|
400
403
|
class Bot < Sc2::Player
|
401
404
|
include Sc2::Player::Units
|
@@ -406,7 +409,6 @@ module Sc2
|
|
406
409
|
|
407
410
|
def initialize: (race: Integer, name: String) -> void
|
408
411
|
|
409
|
-
# sord omit - no YARD return type given, using untyped
|
410
412
|
# Override to customize initialization
|
411
413
|
# Alias of before_join
|
412
414
|
# You can enable_feature_layer=true, set step_count, define
|
@@ -418,7 +420,7 @@ module Sc2
|
|
418
420
|
#
|
419
421
|
# end
|
420
422
|
# ```
|
421
|
-
def configure: () ->
|
423
|
+
def configure: () -> void
|
422
424
|
|
423
425
|
# TODO: If this suffices for Bot and Observer, they should share this code.
|
424
426
|
# Initializes and refreshes game data and runs the game loop
|
@@ -426,17 +428,14 @@ module Sc2
|
|
426
428
|
# _@return_ — One of Api::Result::VICTORY, Api::Result::DEFEAT, Api::Result::TIE, Api::Result::UNDECIDED
|
427
429
|
def play: () -> Integer
|
428
430
|
|
429
|
-
# sord omit - no YARD return type given, using untyped
|
430
431
|
# Override to perform steps before first on_step gets called.
|
431
432
|
# Current game_loop is 0 and @api is available
|
432
|
-
def on_start: () ->
|
433
|
+
def on_start: () -> void
|
433
434
|
|
434
|
-
# sord omit - no YARD return type given, using untyped
|
435
435
|
# Override to implement your own game logic.
|
436
436
|
# Gets called whenever the game moves forward.
|
437
|
-
def on_step: () ->
|
437
|
+
def on_step: () -> void
|
438
438
|
|
439
|
-
# sord omit - no YARD return type given, using untyped
|
440
439
|
# Override to handle game result (:Victory/:Loss/:Tie)
|
441
440
|
# Called when game has ended with a result, i.e. result = :Victory
|
442
441
|
#
|
@@ -451,30 +450,26 @@ module Sc2
|
|
451
450
|
# end
|
452
451
|
# end
|
453
452
|
# ```
|
454
|
-
def on_finish: (Symbol result) ->
|
453
|
+
def on_finish: (Symbol result) -> void
|
455
454
|
|
456
|
-
# sord omit - no YARD return type given, using untyped
|
457
455
|
# Called when Random race is first detected.
|
458
456
|
# Override to handle race identification of random enemy.
|
459
457
|
#
|
460
458
|
# _@param_ `race` — see {Api::Race}
|
461
|
-
def on_random_race_detected: (Integer race) ->
|
459
|
+
def on_random_race_detected: (Integer race) -> void
|
462
460
|
|
463
|
-
# sord omit - no YARD return type given, using untyped
|
464
461
|
# Called on step if errors are present. Equivalent of UI red text errors.
|
465
462
|
# Override to read action errors.
|
466
463
|
#
|
467
464
|
# _@param_ `errors`
|
468
|
-
def on_action_errors: (::Array[Api::ActionError] errors) ->
|
465
|
+
def on_action_errors: (::Array[Api::ActionError] errors) -> void
|
469
466
|
|
470
|
-
# sord omit - no YARD return type given, using untyped
|
471
467
|
# Actions this player performed since the last Observation.
|
472
468
|
# Override to read actions successfully performed
|
473
469
|
#
|
474
470
|
# _@param_ `actions` — a list of actions which were performed
|
475
|
-
def on_actions_performed: (::Array[Api::Action] actions) ->
|
471
|
+
def on_actions_performed: (::Array[Api::Action] actions) -> void
|
476
472
|
|
477
|
-
# sord omit - no YARD return type given, using untyped
|
478
473
|
# Callback when observation.alerts is populated
|
479
474
|
# Override to use alerts or read Player.observation.alerts
|
480
475
|
#
|
@@ -492,22 +487,19 @@ module Sc2
|
|
492
487
|
# ```
|
493
488
|
#
|
494
489
|
# _@see_ `enum` — Alert in sc2api.proto for options
|
495
|
-
def on_alerts: (::Array[Integer] alerts) ->
|
490
|
+
def on_alerts: (::Array[Integer] alerts) -> void
|
496
491
|
|
497
|
-
# sord omit - no YARD return type given, using untyped
|
498
492
|
# Callback when upgrades are completed, multiple might finish on the same observation.
|
499
493
|
#
|
500
494
|
# _@param_ `upgrade_ids` — Api::UpgradeId::*
|
501
|
-
def on_upgrades_completed: (::Array[Integer] upgrade_ids) ->
|
495
|
+
def on_upgrades_completed: (::Array[Integer] upgrade_ids) -> void
|
502
496
|
|
503
497
|
# sord omit - no YARD type given for "unit", using untyped
|
504
|
-
# sord omit - no YARD return type given, using untyped
|
505
498
|
# Callback, on observation parse when iterating over every unit
|
506
499
|
# Can be useful for decorating additional properties on a unit before on_step
|
507
500
|
# A Sc2::Player should override this to decorate additional properties
|
508
|
-
def on_parse_observation_unit: (untyped unit) ->
|
501
|
+
def on_parse_observation_unit: (untyped unit) -> void
|
509
502
|
|
510
|
-
# sord omit - no YARD return type given, using untyped
|
511
503
|
# Callback for unit destroyed. Tags might be found in `previous.all_units`
|
512
504
|
# This excludes unknown objects, like projectiles and only shows things the API has "seen" as a unit
|
513
505
|
# Override to use in your bot class or use Player.
|
@@ -515,16 +507,14 @@ module Sc2
|
|
515
507
|
# _@param_ `unit`
|
516
508
|
#
|
517
509
|
# _@see_ `Sc2::Player::Units#units_destroyed`
|
518
|
-
def on_unit_destroyed: (Api::Unit unit) ->
|
510
|
+
def on_unit_destroyed: (Api::Unit unit) -> void
|
519
511
|
|
520
|
-
# sord omit - no YARD return type given, using untyped
|
521
512
|
# Callback for unit created.
|
522
513
|
# Override to use in your bot class.
|
523
514
|
#
|
524
515
|
# _@param_ `unit`
|
525
|
-
def on_unit_created: (Api::Unit unit) ->
|
516
|
+
def on_unit_created: (Api::Unit unit) -> void
|
526
517
|
|
527
|
-
# sord omit - no YARD return type given, using untyped
|
528
518
|
# Callback for unit type changing.
|
529
519
|
# To detect certain unit creations, you should use this method to watch morphs.
|
530
520
|
# Override to use in your bot class or use Player.
|
@@ -532,30 +522,27 @@ module Sc2
|
|
532
522
|
# _@param_ `unit`
|
533
523
|
#
|
534
524
|
# _@param_ `previous_unit_type_id` — Api::UnitTypeId::*
|
535
|
-
def on_unit_type_changed: (Api::Unit unit, Integer previous_unit_type_id) ->
|
525
|
+
def on_unit_type_changed: (Api::Unit unit, Integer previous_unit_type_id) -> void
|
536
526
|
|
537
|
-
# sord omit - no YARD return type given, using untyped
|
538
527
|
# Callback for structure building began
|
539
528
|
# Override to use in your bot class.
|
540
529
|
#
|
541
530
|
# _@param_ `unit`
|
542
|
-
def on_structure_started: (Api::Unit unit) ->
|
531
|
+
def on_structure_started: (Api::Unit unit) -> void
|
543
532
|
|
544
|
-
# sord omit - no YARD return type given, using untyped
|
545
533
|
# Callback for structure building is completed
|
546
534
|
# Override to use in your bot class or use Player.
|
547
535
|
#
|
548
536
|
# _@param_ `unit`
|
549
|
-
def on_structure_completed: (Api::Unit unit) ->
|
537
|
+
def on_structure_completed: (Api::Unit unit) -> void
|
550
538
|
|
551
|
-
# sord omit - no YARD return type given, using untyped
|
552
539
|
# Callback for unit (Unit/Structure) taking damage
|
553
540
|
# Override to use in your bot class or use Player.
|
554
541
|
#
|
555
542
|
# _@param_ `unit`
|
556
543
|
#
|
557
544
|
# _@param_ `amount` — of damage
|
558
|
-
def on_unit_damaged: (Api::Unit unit, Integer amount) ->
|
545
|
+
def on_unit_damaged: (Api::Unit unit, Integer amount) -> void
|
559
546
|
|
560
547
|
# sord omit - no YARD return type given, using untyped
|
561
548
|
# Writes the current observation as json to data/debug_observation.json
|
@@ -1016,10 +1003,10 @@ module Sc2
|
|
1016
1003
|
# This is called internally when building/morphing/training
|
1017
1004
|
def subtract_cost: (untyped unit_type_id) -> void
|
1018
1005
|
|
1019
|
-
# sord omit - no YARD type given for "unit_type_id
|
1006
|
+
# sord omit - no YARD type given for "unit_type_id", using untyped
|
1020
1007
|
# sord omit - no YARD type given for "quantity:", using untyped
|
1021
1008
|
# Checks whether you have the resources to construct quantity of unit type
|
1022
|
-
def can_afford?: (unit_type_id
|
1009
|
+
def can_afford?: (untyped unit_type_id, ?quantity: untyped) -> bool
|
1023
1010
|
|
1024
1011
|
# sord omit - no YARD type given for "upgrade_id", using untyped
|
1025
1012
|
# Checks whether you have the resources to
|
@@ -1146,10 +1133,10 @@ module Sc2
|
|
1146
1133
|
# This is called internally when building/morphing/training
|
1147
1134
|
def subtract_cost: (untyped unit_type_id) -> void
|
1148
1135
|
|
1149
|
-
# sord omit - no YARD type given for "unit_type_id
|
1136
|
+
# sord omit - no YARD type given for "unit_type_id", using untyped
|
1150
1137
|
# sord omit - no YARD type given for "quantity:", using untyped
|
1151
1138
|
# Checks whether you have the resources to construct quantity of unit type
|
1152
|
-
def can_afford?: (unit_type_id
|
1139
|
+
def can_afford?: (untyped unit_type_id, ?quantity: untyped) -> bool
|
1153
1140
|
|
1154
1141
|
# sord omit - no YARD type given for "upgrade_id", using untyped
|
1155
1142
|
# Checks whether you have the resources to
|
@@ -1864,10 +1851,10 @@ module Sc2
|
|
1864
1851
|
# This is called internally when building/morphing/training
|
1865
1852
|
def subtract_cost: (untyped unit_type_id) -> void
|
1866
1853
|
|
1867
|
-
# sord omit - no YARD type given for "unit_type_id
|
1854
|
+
# sord omit - no YARD type given for "unit_type_id", using untyped
|
1868
1855
|
# sord omit - no YARD type given for "quantity:", using untyped
|
1869
1856
|
# Checks whether you have the resources to construct quantity of unit type
|
1870
|
-
def can_afford?: (unit_type_id
|
1857
|
+
def can_afford?: (untyped unit_type_id, ?quantity: untyped) -> bool
|
1871
1858
|
|
1872
1859
|
# sord omit - no YARD type given for "upgrade_id", using untyped
|
1873
1860
|
# Checks whether you have the resources to
|
@@ -1928,6 +1915,9 @@ module Sc2
|
|
1928
1915
|
# _@return_ — a group of neutral units
|
1929
1916
|
attr_accessor effects: Sc2::UnitGroup
|
1930
1917
|
|
1918
|
+
# _@return_ — a group of blip units
|
1919
|
+
attr_accessor blips: Sc2::UnitGroup
|
1920
|
+
|
1931
1921
|
# sord omit - no YARD type given for :upgrades_completed, using untyped
|
1932
1922
|
# Returns the upgrade ids you have acquired such as weapon upgrade and armor upgrade ids.
|
1933
1923
|
# Shorthand for observation.raw_data.player.upgrade_ids
|
@@ -2210,10 +2200,6 @@ module Sc2
|
|
2210
2200
|
# Holds Api::ResponseGameInfo::#start_locations.
|
2211
2201
|
attr_accessor game_info: Api::ResponseGameInfo
|
2212
2202
|
|
2213
|
-
# This is the last loop at which game_info was set.
|
2214
|
-
# Used to determine staleness.
|
2215
|
-
attr_accessor game_info_loop: Integer
|
2216
|
-
|
2217
2203
|
attr_accessor data: (Api::ResponseData | untyped)
|
2218
2204
|
|
2219
2205
|
# _@return_ — snapshot of current game state
|
@@ -2326,10 +2312,10 @@ module Sc2
|
|
2326
2312
|
# This is called internally when building/morphing/training
|
2327
2313
|
def subtract_cost: (untyped unit_type_id) -> void
|
2328
2314
|
|
2329
|
-
# sord omit - no YARD type given for "unit_type_id
|
2315
|
+
# sord omit - no YARD type given for "unit_type_id", using untyped
|
2330
2316
|
# sord omit - no YARD type given for "quantity:", using untyped
|
2331
2317
|
# Checks whether you have the resources to construct quantity of unit type
|
2332
|
-
def can_afford?: (unit_type_id
|
2318
|
+
def can_afford?: (untyped unit_type_id, ?quantity: untyped) -> bool
|
2333
2319
|
|
2334
2320
|
# sord omit - no YARD type given for "upgrade_id", using untyped
|
2335
2321
|
# Checks whether you have the resources to
|
@@ -2441,6 +2427,14 @@ module Sc2
|
|
2441
2427
|
# Adds placement_length to units if applicable
|
2442
2428
|
def decorate_unit_type_placement_length: () -> untyped
|
2443
2429
|
|
2430
|
+
# sord omit - no YARD return type given, using untyped
|
2431
|
+
# Adds values missing from the API
|
2432
|
+
def decorate_missing_values: () -> untyped
|
2433
|
+
|
2434
|
+
# sord omit - no YARD return type given, using untyped
|
2435
|
+
# Adds ground_damage, air_damage, ground_range, air_range, ground_dps and air_dps
|
2436
|
+
def decorate_weapon_helpers: () -> untyped
|
2437
|
+
|
2444
2438
|
# _@return_ — AbilityId => AbilityData
|
2445
2439
|
attr_accessor abilities: (::Hash[Integer, Api::AbilityData] | untyped)
|
2446
2440
|
|
@@ -2585,8 +2579,9 @@ module Sc2
|
|
2585
2579
|
# game_info = observer.api.game_info
|
2586
2580
|
# end
|
2587
2581
|
# ensure
|
2582
|
+
# observer.disconnect
|
2588
2583
|
# Sc2::ClientManager.stop(0)
|
2589
|
-
# end
|
2584
|
+
# end.wait
|
2590
2585
|
# ```
|
2591
2586
|
def start_replay: (
|
2592
2587
|
?replay_path: String?,
|
@@ -2637,11 +2632,10 @@ module Sc2
|
|
2637
2632
|
?effect_id: bool
|
2638
2633
|
) -> Api::ResponseData
|
2639
2634
|
|
2640
|
-
# sord omit - no YARD return type given, using untyped
|
2641
2635
|
# Snapshot of the current game state. Primary source for raw information
|
2642
2636
|
#
|
2643
2637
|
# _@param_ `game_loop` — you wish to wait for (realtime only)
|
2644
|
-
def observation: (?game_loop: Integer?) ->
|
2638
|
+
def observation: (?game_loop: Integer?) -> Api::ResponseObservation
|
2645
2639
|
|
2646
2640
|
# Executes an array of [Api::Action] for a participant
|
2647
2641
|
#
|
@@ -2869,8 +2863,9 @@ module Sc2
|
|
2869
2863
|
# game_info = observer.api.game_info
|
2870
2864
|
# end
|
2871
2865
|
# ensure
|
2866
|
+
# observer.disconnect
|
2872
2867
|
# Sc2::ClientManager.stop(0)
|
2873
|
-
# end
|
2868
|
+
# end.wait
|
2874
2869
|
# ```
|
2875
2870
|
def start_replay: (
|
2876
2871
|
?replay_path: String?,
|
@@ -2921,11 +2916,10 @@ module Sc2
|
|
2921
2916
|
?effect_id: bool
|
2922
2917
|
) -> Api::ResponseData
|
2923
2918
|
|
2924
|
-
# sord omit - no YARD return type given, using untyped
|
2925
2919
|
# Snapshot of the current game state. Primary source for raw information
|
2926
2920
|
#
|
2927
2921
|
# _@param_ `game_loop` — you wish to wait for (realtime only)
|
2928
|
-
def observation: (?game_loop: Integer?) ->
|
2922
|
+
def observation: (?game_loop: Integer?) -> Api::ResponseObservation
|
2929
2923
|
|
2930
2924
|
# Executes an array of [Api::Action] for a participant
|
2931
2925
|
#
|
@@ -3102,6 +3096,7 @@ module Sc2
|
|
3102
3096
|
TYPE_TECHLAB: untyped
|
3103
3097
|
TYPE_REACTOR: ::Array[Integer]
|
3104
3098
|
TYPE_BASES: ::Array[Integer]
|
3099
|
+
TYPE_DETECTORS: ::Array[Integer]
|
3105
3100
|
|
3106
3101
|
# _@param_ `units` — default to be added.
|
3107
3102
|
#
|
@@ -3556,6 +3551,11 @@ module Sc2
|
|
3556
3551
|
# _@return_ — gas structures
|
3557
3552
|
def gas: () -> UnitGroup
|
3558
3553
|
|
3554
|
+
# Selects units passively have Detection
|
3555
|
+
#
|
3556
|
+
# _@return_ — gas structures
|
3557
|
+
def detectors: () -> UnitGroup
|
3558
|
+
|
3559
3559
|
# Selects only units which have finished constructing, i.o.w. build_progress == 1.0
|
3560
3560
|
#
|
3561
3561
|
# _@return_ — complete unit group
|
@@ -3726,6 +3726,7 @@ module Sc2
|
|
3726
3726
|
TYPE_TECHLAB: untyped
|
3727
3727
|
TYPE_REACTOR: ::Array[Integer]
|
3728
3728
|
TYPE_BASES: ::Array[Integer]
|
3729
|
+
TYPE_DETECTORS: ::Array[Integer]
|
3729
3730
|
|
3730
3731
|
# _@param_ `unit_group`
|
3731
3732
|
def initialize: (Sc2::UnitGroup unit_group) -> void
|
@@ -4203,9 +4204,8 @@ module Sc2
|
|
4203
4204
|
# _@param_ `distance` — The distance to move.
|
4204
4205
|
def away_from: (Api::Point2D other, Float distance) -> Api::Point2D
|
4205
4206
|
|
4206
|
-
# sord warn - "Array[Float,Float]" does not appear to be a type
|
4207
4207
|
# Returns [x,y] array tuple
|
4208
|
-
def to_axy: () ->
|
4208
|
+
def to_axy: () -> ::Array[(Float | Float)]
|
4209
4209
|
|
4210
4210
|
# Returns [x,y] array tuple where floats are cast to ints
|
4211
4211
|
# Useful when trying to find the tile which something is on
|
@@ -7902,9 +7902,8 @@ module Api
|
|
7902
7902
|
# _@param_ `distance` — The distance to move.
|
7903
7903
|
def away_from: (Api::Point2D other, Float distance) -> Api::Point2D
|
7904
7904
|
|
7905
|
-
# sord warn - "Array[Float,Float]" does not appear to be a type
|
7906
7905
|
# Returns [x,y] array tuple
|
7907
|
-
def to_axy: () ->
|
7906
|
+
def to_axy: () -> ::Array[(Float | Float)]
|
7908
7907
|
|
7909
7908
|
# Returns [x,y] array tuple where floats are cast to ints
|
7910
7909
|
# Useful when trying to find the tile which something is on
|
@@ -8466,7 +8465,7 @@ module Api
|
|
8466
8465
|
# _@return_ — true if refreshed or false unchanged
|
8467
8466
|
def refresh!: () -> bool
|
8468
8467
|
|
8469
|
-
# Returns static
|
8468
|
+
# Returns static an array of attributes for a unit
|
8470
8469
|
def attributes: () -> ::Array[Api::Attribute]
|
8471
8470
|
|
8472
8471
|
# sord omit - no YARD type given for "attribute", using untyped
|
@@ -8520,7 +8519,7 @@ module Api
|
|
8520
8519
|
# _@return_ — whether unit has attribute :Structure
|
8521
8520
|
def is_structure?: () -> bool
|
8522
8521
|
|
8523
|
-
# Checks if unit is
|
8522
|
+
# Checks if unit is hovering
|
8524
8523
|
#
|
8525
8524
|
# _@return_ — whether unit has attribute :Hover
|
8526
8525
|
def is_hover?: () -> bool
|
@@ -8535,6 +8534,10 @@ module Api
|
|
8535
8534
|
# _@return_ — whether unit has attribute :Summoned
|
8536
8535
|
def is_summoned?: () -> bool
|
8537
8536
|
|
8537
|
+
# Returns whether the unit is cloaked. Revealed cloak units also return true.
|
8538
|
+
# For further distinction, use Unit#cloaked, which uses enum CloakedState
|
8539
|
+
def is_cloaked?: () -> bool
|
8540
|
+
|
8538
8541
|
# Whether unit is effected by buff_id
|
8539
8542
|
#
|
8540
8543
|
# _@param_ `buff_id`
|
@@ -8630,12 +8633,12 @@ module Api
|
|
8630
8633
|
def debug_draw_placement: (?Api::Color? color) -> void
|
8631
8634
|
|
8632
8635
|
# sord omit - no YARD return type given, using untyped
|
8633
|
-
# Draws a sphere around the unit's attack range
|
8636
|
+
# Draws a sphere around the unit's attack range (weapon range + radius)
|
8634
8637
|
#
|
8635
|
-
# _@param_ `weapon_index` — default first weapon, see UnitTypeData
|
8638
|
+
# _@param_ `weapon_index` — default first weapon, see UnitTypeData#weapons
|
8636
8639
|
#
|
8637
8640
|
# _@param_ `color` — optional api color, default red
|
8638
|
-
def debug_fire_range: (?
|
8641
|
+
def debug_fire_range: (?Integer weapon_index, ?Api::Color? color) -> untyped
|
8639
8642
|
|
8640
8643
|
# sord omit - no YARD return type given, using untyped
|
8641
8644
|
# Calculates the distance between self and other
|
@@ -8685,18 +8688,22 @@ module Api
|
|
8685
8688
|
def is_engaged_with?: ((Api::Unit | Integer) unit) -> bool
|
8686
8689
|
|
8687
8690
|
# Checks whether enemy is within range of weapon or ability and can target ground/air.
|
8688
|
-
#
|
8691
|
+
# By default, checks all weapons.
|
8692
|
+
# Pass weapon_index or ability_id to target a specific source of damage.
|
8689
8693
|
#
|
8690
8694
|
# _@param_ `unit` — enemy
|
8691
8695
|
#
|
8692
|
-
# _@param_ `weapon_index` —
|
8696
|
+
# _@param_ `weapon_index` — passing this will select a specific Weapon
|
8693
8697
|
#
|
8694
8698
|
# _@param_ `ability_id` — passing this will override weapon Api::AbilityId::*
|
8695
8699
|
#
|
8696
8700
|
# ```ruby
|
8701
|
+
# queen.can_attack?(enemy, weapon_index: 0) # Air attack
|
8702
|
+
# queen.can_attack?(enemy, weapon_index: 1) # Ground attack
|
8703
|
+
# queen.can_attack?(enemy) # Auto detect (scans all weapons)
|
8697
8704
|
# ghost.can_attack?(enemy, weapon_index: 0, ability_id: Api::AbilityId::SNIPE)
|
8698
8705
|
# ```
|
8699
|
-
def can_attack?: (unit: Api::Unit, ?weapon_index: Integer
|
8706
|
+
def can_attack?: (unit: Api::Unit, ?weapon_index: Integer?, ?ability_id: Integer?) -> bool
|
8700
8707
|
|
8701
8708
|
# Returns whether this unit has an ability available
|
8702
8709
|
# Queries API if necessary
|
@@ -8711,9 +8718,12 @@ module Api
|
|
8711
8718
|
# _@param_ `weapon`
|
8712
8719
|
def can_weapon_target_unit?: (unit: Api::Unit, weapon: Api::Weapon) -> bool
|
8713
8720
|
|
8714
|
-
#
|
8715
|
-
#
|
8716
|
-
|
8721
|
+
# Checks whether an ability can target a unit
|
8722
|
+
#
|
8723
|
+
# _@param_ `unit`
|
8724
|
+
#
|
8725
|
+
# _@param_ `ability`
|
8726
|
+
def can_ability_target_unit?: (unit: Api::Unit, ability: Api::AbilityData) -> bool
|
8717
8727
|
|
8718
8728
|
# Checks whether opposing unit is in the attack range.
|
8719
8729
|
#
|
@@ -14559,9 +14569,8 @@ module Api
|
|
14559
14569
|
# _@param_ `distance` — The distance to move.
|
14560
14570
|
def away_from: (Api::Point2D other, Float distance) -> Api::Point2D
|
14561
14571
|
|
14562
|
-
# sord warn - "Array[Float,Float]" does not appear to be a type
|
14563
14572
|
# Returns [x,y] array tuple
|
14564
|
-
def to_axy: () ->
|
14573
|
+
def to_axy: () -> ::Array[(Float | Float)]
|
14565
14574
|
|
14566
14575
|
# Returns [x,y] array tuple where floats are cast to ints
|
14567
14576
|
# Useful when trying to find the tile which something is on
|
@@ -14817,9 +14826,8 @@ module Api
|
|
14817
14826
|
# _@param_ `distance` — The distance to move.
|
14818
14827
|
def away_from: (Api::Point2D other, Float distance) -> Api::Point2D
|
14819
14828
|
|
14820
|
-
# sord warn - "Array[Float,Float]" does not appear to be a type
|
14821
14829
|
# Returns [x,y] array tuple
|
14822
|
-
def to_axy: () ->
|
14830
|
+
def to_axy: () -> ::Array[(Float | Float)]
|
14823
14831
|
|
14824
14832
|
# Returns [x,y] array tuple where floats are cast to ints
|
14825
14833
|
# Useful when trying to find the tile which something is on
|
@@ -15043,9 +15051,8 @@ module Api
|
|
15043
15051
|
# _@param_ `distance` — The distance to move.
|
15044
15052
|
def away_from: (Api::Point2D other, Float distance) -> Api::Point2D
|
15045
15053
|
|
15046
|
-
# sord warn - "Array[Float,Float]" does not appear to be a type
|
15047
15054
|
# Returns [x,y] array tuple
|
15048
|
-
def to_axy: () ->
|
15055
|
+
def to_axy: () -> ::Array[(Float | Float)]
|
15049
15056
|
|
15050
15057
|
# Returns [x,y] array tuple where floats are cast to ints
|
15051
15058
|
# Useful when trying to find the tile which something is on
|
@@ -15249,9 +15256,8 @@ module Api
|
|
15249
15256
|
# _@param_ `distance` — The distance to move.
|
15250
15257
|
def away_from: (Api::Point2D other, Float distance) -> Api::Point2D
|
15251
15258
|
|
15252
|
-
# sord warn - "Array[Float,Float]" does not appear to be a type
|
15253
15259
|
# Returns [x,y] array tuple
|
15254
|
-
def to_axy: () ->
|
15260
|
+
def to_axy: () -> ::Array[(Float | Float)]
|
15255
15261
|
|
15256
15262
|
# Returns [x,y] array tuple where floats are cast to ints
|
15257
15263
|
# Useful when trying to find the tile which something is on
|
@@ -18798,6 +18804,8 @@ module Api
|
|
18798
18804
|
end
|
18799
18805
|
|
18800
18806
|
class PlayerCommon
|
18807
|
+
include Api::PlayerCommonExt
|
18808
|
+
|
18801
18809
|
# sord omit - no YARD type given for "buff", using untyped
|
18802
18810
|
# sord omit - no YARD return type given, using untyped
|
18803
18811
|
def self.decode: (untyped buff) -> untyped
|
@@ -20406,7 +20414,7 @@ module Api
|
|
20406
20414
|
# _@return_ — true if refreshed or false unchanged
|
20407
20415
|
def refresh!: () -> bool
|
20408
20416
|
|
20409
|
-
# Returns static
|
20417
|
+
# Returns static an array of attributes for a unit
|
20410
20418
|
def attributes: () -> ::Array[Api::Attribute]
|
20411
20419
|
|
20412
20420
|
# sord omit - no YARD type given for "attribute", using untyped
|
@@ -20460,7 +20468,7 @@ module Api
|
|
20460
20468
|
# _@return_ — whether unit has attribute :Structure
|
20461
20469
|
def is_structure?: () -> bool
|
20462
20470
|
|
20463
|
-
# Checks if unit is
|
20471
|
+
# Checks if unit is hovering
|
20464
20472
|
#
|
20465
20473
|
# _@return_ — whether unit has attribute :Hover
|
20466
20474
|
def is_hover?: () -> bool
|
@@ -20475,6 +20483,10 @@ module Api
|
|
20475
20483
|
# _@return_ — whether unit has attribute :Summoned
|
20476
20484
|
def is_summoned?: () -> bool
|
20477
20485
|
|
20486
|
+
# Returns whether the unit is cloaked. Revealed cloak units also return true.
|
20487
|
+
# For further distinction, use Unit#cloaked, which uses enum CloakedState
|
20488
|
+
def is_cloaked?: () -> bool
|
20489
|
+
|
20478
20490
|
# Whether unit is effected by buff_id
|
20479
20491
|
#
|
20480
20492
|
# _@param_ `buff_id`
|
@@ -20570,12 +20582,12 @@ module Api
|
|
20570
20582
|
def debug_draw_placement: (?Api::Color? color) -> void
|
20571
20583
|
|
20572
20584
|
# sord omit - no YARD return type given, using untyped
|
20573
|
-
# Draws a sphere around the unit's attack range
|
20585
|
+
# Draws a sphere around the unit's attack range (weapon range + radius)
|
20574
20586
|
#
|
20575
|
-
# _@param_ `weapon_index` — default first weapon, see UnitTypeData
|
20587
|
+
# _@param_ `weapon_index` — default first weapon, see UnitTypeData#weapons
|
20576
20588
|
#
|
20577
20589
|
# _@param_ `color` — optional api color, default red
|
20578
|
-
def debug_fire_range: (?
|
20590
|
+
def debug_fire_range: (?Integer weapon_index, ?Api::Color? color) -> untyped
|
20579
20591
|
|
20580
20592
|
# sord omit - no YARD return type given, using untyped
|
20581
20593
|
# Calculates the distance between self and other
|
@@ -20625,18 +20637,22 @@ module Api
|
|
20625
20637
|
def is_engaged_with?: ((Api::Unit | Integer) unit) -> bool
|
20626
20638
|
|
20627
20639
|
# Checks whether enemy is within range of weapon or ability and can target ground/air.
|
20628
|
-
#
|
20640
|
+
# By default, checks all weapons.
|
20641
|
+
# Pass weapon_index or ability_id to target a specific source of damage.
|
20629
20642
|
#
|
20630
20643
|
# _@param_ `unit` — enemy
|
20631
20644
|
#
|
20632
|
-
# _@param_ `weapon_index` —
|
20645
|
+
# _@param_ `weapon_index` — passing this will select a specific Weapon
|
20633
20646
|
#
|
20634
20647
|
# _@param_ `ability_id` — passing this will override weapon Api::AbilityId::*
|
20635
20648
|
#
|
20636
20649
|
# ```ruby
|
20650
|
+
# queen.can_attack?(enemy, weapon_index: 0) # Air attack
|
20651
|
+
# queen.can_attack?(enemy, weapon_index: 1) # Ground attack
|
20652
|
+
# queen.can_attack?(enemy) # Auto detect (scans all weapons)
|
20637
20653
|
# ghost.can_attack?(enemy, weapon_index: 0, ability_id: Api::AbilityId::SNIPE)
|
20638
20654
|
# ```
|
20639
|
-
def can_attack?: (unit: Api::Unit, ?weapon_index: Integer
|
20655
|
+
def can_attack?: (unit: Api::Unit, ?weapon_index: Integer?, ?ability_id: Integer?) -> bool
|
20640
20656
|
|
20641
20657
|
# Returns whether this unit has an ability available
|
20642
20658
|
# Queries API if necessary
|
@@ -20651,9 +20667,12 @@ module Api
|
|
20651
20667
|
# _@param_ `weapon`
|
20652
20668
|
def can_weapon_target_unit?: (unit: Api::Unit, weapon: Api::Weapon) -> bool
|
20653
20669
|
|
20654
|
-
#
|
20655
|
-
#
|
20656
|
-
|
20670
|
+
# Checks whether an ability can target a unit
|
20671
|
+
#
|
20672
|
+
# _@param_ `unit`
|
20673
|
+
#
|
20674
|
+
# _@param_ `ability`
|
20675
|
+
def can_ability_target_unit?: (unit: Api::Unit, ability: Api::AbilityData) -> bool
|
20657
20676
|
|
20658
20677
|
# Checks whether opposing unit is in the attack range.
|
20659
20678
|
#
|
@@ -20748,6 +20767,12 @@ module Api
|
|
20748
20767
|
# width = radius * 2
|
20749
20768
|
attr_accessor width: Float
|
20750
20769
|
|
20770
|
+
attr_reader full_health?: bool
|
20771
|
+
|
20772
|
+
attr_reader full_shields?: bool
|
20773
|
+
|
20774
|
+
attr_reader full_energy?: bool
|
20775
|
+
|
20751
20776
|
attr_reader is_flying?: bool
|
20752
20777
|
|
20753
20778
|
attr_reader is_burrowed?: bool
|
@@ -20766,6 +20791,10 @@ module Api
|
|
20766
20791
|
|
20767
20792
|
# Returns whether the unit is grounded (not flying).
|
20768
20793
|
attr_reader is_ground?: bool
|
20794
|
+
|
20795
|
+
# Returns whether the unit is cloaked. Revealed cloak units also return true.
|
20796
|
+
# For further distinction, use Unit#cloaked, which uses enum CloakedState
|
20797
|
+
attr_reader is_cloaked??: bool
|
20769
20798
|
end
|
20770
20799
|
|
20771
20800
|
# Adds additional functionality and fixes quirks with color specifically pertaining to debug commands
|
@@ -20991,9 +21020,8 @@ module Api
|
|
20991
21020
|
# _@param_ `distance` — The distance to move.
|
20992
21021
|
def away_from: (Api::Point2D other, Float distance) -> Api::Point2D
|
20993
21022
|
|
20994
|
-
# sord warn - "Array[Float,Float]" does not appear to be a type
|
20995
21023
|
# Returns [x,y] array tuple
|
20996
|
-
def to_axy: () ->
|
21024
|
+
def to_axy: () -> ::Array[(Float | Float)]
|
20997
21025
|
|
20998
21026
|
# Returns [x,y] array tuple where floats are cast to ints
|
20999
21027
|
# Useful when trying to find the tile which something is on
|
@@ -21021,6 +21049,17 @@ module Api
|
|
21021
21049
|
end
|
21022
21050
|
end
|
21023
21051
|
|
21052
|
+
# Adds additional functionality to message object Api::Point2D
|
21053
|
+
module PlayerCommonExt
|
21054
|
+
attr_accessor supply_cap: Integer
|
21055
|
+
|
21056
|
+
attr_accessor supply_used: Integer
|
21057
|
+
|
21058
|
+
attr_accessor supply_army: Integer
|
21059
|
+
|
21060
|
+
attr_accessor supply_workers: Integer
|
21061
|
+
end
|
21062
|
+
|
21024
21063
|
# Adds additional functionality to message object Api::Unit
|
21025
21064
|
module PointDistanceExtension
|
21026
21065
|
end
|
@@ -21047,6 +21086,24 @@ module Api
|
|
21047
21086
|
#
|
21048
21087
|
# _@return_ — side-length for placement
|
21049
21088
|
attr_accessor placement_length: (Integer | untyped)
|
21089
|
+
|
21090
|
+
# Ground weapon range or 0.0 when it can't shoot ground
|
21091
|
+
attr_accessor ground_range: (Float | untyped)
|
21092
|
+
|
21093
|
+
# Air weapon range or 0.0 when it can't shoot air
|
21094
|
+
attr_accessor air_range: (Float | untyped)
|
21095
|
+
|
21096
|
+
# Ground weapon damage or 0.0
|
21097
|
+
attr_accessor ground_damage: (Float | untyped)
|
21098
|
+
|
21099
|
+
# Air weapon damage or 0.0
|
21100
|
+
attr_accessor air_damage: (Float | untyped)
|
21101
|
+
|
21102
|
+
# Ground weapon damage per second or 0.0
|
21103
|
+
attr_accessor ground_dps: (Float | untyped)
|
21104
|
+
|
21105
|
+
# Air weapon damage per second or 0.0
|
21106
|
+
attr_accessor air_dps: (Float | untyped)
|
21050
21107
|
end
|
21051
21108
|
|
21052
21109
|
# This module make sure that a read from method ability_id always returns the proper source id
|