sc2ai 0.5.0 → 0.6.2
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.aiarenabot +12 -0
- data/docker_build/Dockerfile.ruby +2 -2
- data/docker_build/docker-compose-base-image.yml +0 -1
- data/docker_build/docker-compose-ladderzip.yml +0 -1
- data/docker_build/docker-compose-versus-bot.yml +15 -0
- data/lib/sc2ai/api/data.rb +59 -1
- data/lib/sc2ai/cli/cli.rb +7 -47
- data/lib/sc2ai/cli/ladderzip.rb +6 -1
- data/lib/sc2ai/cli/versus_bot.rb +305 -0
- data/lib/sc2ai/connection/requests.rb +4 -1
- data/lib/sc2ai/local_play/client_manager.rb +3 -1
- data/lib/sc2ai/local_play/match.rb +2 -2
- data/lib/sc2ai/player/game_state.rb +2 -14
- data/lib/sc2ai/player/geo.rb +19 -2
- data/lib/sc2ai/player/units.rb +12 -8
- data/lib/sc2ai/player.rb +29 -7
- 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/ladderzip/bin/ladder.tt +1 -7
- data/lib/templates/ladderzip/ladderbots.json.tt +11 -0
- data/lib/templates/new/.ladderignore +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 +152 -86
- metadata +17 -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
|
@@ -1281,6 +1268,12 @@ module Sc2
|
|
1281
1268
|
# Returns zero to map_height-1 as range
|
1282
1269
|
def map_tile_range_y: () -> ::Range[untyped]
|
1283
1270
|
|
1271
|
+
# Ensures a Sc2::Position's x/y stays in map tile range
|
1272
|
+
# Prevents out of bound exceptions when working with minimap
|
1273
|
+
#
|
1274
|
+
# _@param_ `position`
|
1275
|
+
def clamp_to_grid: ((Sc2::Position | Api::Point2D) position) -> (Sc2::Position | Api::Point2D)
|
1276
|
+
|
1284
1277
|
# Returns whether a x/y (integer) is placeable as per minimap image data.
|
1285
1278
|
# It does not say whether a position is occupied by another building.
|
1286
1279
|
# One pixel covers one whole block. Corrects floats on your behalf
|
@@ -1864,10 +1857,10 @@ module Sc2
|
|
1864
1857
|
# This is called internally when building/morphing/training
|
1865
1858
|
def subtract_cost: (untyped unit_type_id) -> void
|
1866
1859
|
|
1867
|
-
# sord omit - no YARD type given for "unit_type_id
|
1860
|
+
# sord omit - no YARD type given for "unit_type_id", using untyped
|
1868
1861
|
# sord omit - no YARD type given for "quantity:", using untyped
|
1869
1862
|
# Checks whether you have the resources to construct quantity of unit type
|
1870
|
-
def can_afford?: (unit_type_id
|
1863
|
+
def can_afford?: (untyped unit_type_id, ?quantity: untyped) -> bool
|
1871
1864
|
|
1872
1865
|
# sord omit - no YARD type given for "upgrade_id", using untyped
|
1873
1866
|
# Checks whether you have the resources to
|
@@ -1928,6 +1921,9 @@ module Sc2
|
|
1928
1921
|
# _@return_ — a group of neutral units
|
1929
1922
|
attr_accessor effects: Sc2::UnitGroup
|
1930
1923
|
|
1924
|
+
# _@return_ — a group of blip units
|
1925
|
+
attr_accessor blips: Sc2::UnitGroup
|
1926
|
+
|
1931
1927
|
# sord omit - no YARD type given for :upgrades_completed, using untyped
|
1932
1928
|
# Returns the upgrade ids you have acquired such as weapon upgrade and armor upgrade ids.
|
1933
1929
|
# Shorthand for observation.raw_data.player.upgrade_ids
|
@@ -2210,10 +2206,6 @@ module Sc2
|
|
2210
2206
|
# Holds Api::ResponseGameInfo::#start_locations.
|
2211
2207
|
attr_accessor game_info: Api::ResponseGameInfo
|
2212
2208
|
|
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
2209
|
attr_accessor data: (Api::ResponseData | untyped)
|
2218
2210
|
|
2219
2211
|
# _@return_ — snapshot of current game state
|
@@ -2326,10 +2318,10 @@ module Sc2
|
|
2326
2318
|
# This is called internally when building/morphing/training
|
2327
2319
|
def subtract_cost: (untyped unit_type_id) -> void
|
2328
2320
|
|
2329
|
-
# sord omit - no YARD type given for "unit_type_id
|
2321
|
+
# sord omit - no YARD type given for "unit_type_id", using untyped
|
2330
2322
|
# sord omit - no YARD type given for "quantity:", using untyped
|
2331
2323
|
# Checks whether you have the resources to construct quantity of unit type
|
2332
|
-
def can_afford?: (unit_type_id
|
2324
|
+
def can_afford?: (untyped unit_type_id, ?quantity: untyped) -> bool
|
2333
2325
|
|
2334
2326
|
# sord omit - no YARD type given for "upgrade_id", using untyped
|
2335
2327
|
# Checks whether you have the resources to
|
@@ -2441,6 +2433,14 @@ module Sc2
|
|
2441
2433
|
# Adds placement_length to units if applicable
|
2442
2434
|
def decorate_unit_type_placement_length: () -> untyped
|
2443
2435
|
|
2436
|
+
# sord omit - no YARD return type given, using untyped
|
2437
|
+
# Adds values missing from the API
|
2438
|
+
def decorate_missing_values: () -> untyped
|
2439
|
+
|
2440
|
+
# sord omit - no YARD return type given, using untyped
|
2441
|
+
# Adds ground_damage, air_damage, ground_range, air_range, ground_dps and air_dps
|
2442
|
+
def decorate_weapon_helpers: () -> untyped
|
2443
|
+
|
2444
2444
|
# _@return_ — AbilityId => AbilityData
|
2445
2445
|
attr_accessor abilities: (::Hash[Integer, Api::AbilityData] | untyped)
|
2446
2446
|
|
@@ -2585,8 +2585,9 @@ module Sc2
|
|
2585
2585
|
# game_info = observer.api.game_info
|
2586
2586
|
# end
|
2587
2587
|
# ensure
|
2588
|
+
# observer.disconnect
|
2588
2589
|
# Sc2::ClientManager.stop(0)
|
2589
|
-
# end
|
2590
|
+
# end.wait
|
2590
2591
|
# ```
|
2591
2592
|
def start_replay: (
|
2592
2593
|
?replay_path: String?,
|
@@ -2637,11 +2638,10 @@ module Sc2
|
|
2637
2638
|
?effect_id: bool
|
2638
2639
|
) -> Api::ResponseData
|
2639
2640
|
|
2640
|
-
# sord omit - no YARD return type given, using untyped
|
2641
2641
|
# Snapshot of the current game state. Primary source for raw information
|
2642
2642
|
#
|
2643
2643
|
# _@param_ `game_loop` — you wish to wait for (realtime only)
|
2644
|
-
def observation: (?game_loop: Integer?) ->
|
2644
|
+
def observation: (?game_loop: Integer?) -> Api::ResponseObservation
|
2645
2645
|
|
2646
2646
|
# Executes an array of [Api::Action] for a participant
|
2647
2647
|
#
|
@@ -2869,8 +2869,9 @@ module Sc2
|
|
2869
2869
|
# game_info = observer.api.game_info
|
2870
2870
|
# end
|
2871
2871
|
# ensure
|
2872
|
+
# observer.disconnect
|
2872
2873
|
# Sc2::ClientManager.stop(0)
|
2873
|
-
# end
|
2874
|
+
# end.wait
|
2874
2875
|
# ```
|
2875
2876
|
def start_replay: (
|
2876
2877
|
?replay_path: String?,
|
@@ -2921,11 +2922,10 @@ module Sc2
|
|
2921
2922
|
?effect_id: bool
|
2922
2923
|
) -> Api::ResponseData
|
2923
2924
|
|
2924
|
-
# sord omit - no YARD return type given, using untyped
|
2925
2925
|
# Snapshot of the current game state. Primary source for raw information
|
2926
2926
|
#
|
2927
2927
|
# _@param_ `game_loop` — you wish to wait for (realtime only)
|
2928
|
-
def observation: (?game_loop: Integer?) ->
|
2928
|
+
def observation: (?game_loop: Integer?) -> Api::ResponseObservation
|
2929
2929
|
|
2930
2930
|
# Executes an array of [Api::Action] for a participant
|
2931
2931
|
#
|
@@ -3102,6 +3102,7 @@ module Sc2
|
|
3102
3102
|
TYPE_TECHLAB: untyped
|
3103
3103
|
TYPE_REACTOR: ::Array[Integer]
|
3104
3104
|
TYPE_BASES: ::Array[Integer]
|
3105
|
+
TYPE_DETECTORS: ::Array[Integer]
|
3105
3106
|
|
3106
3107
|
# _@param_ `units` — default to be added.
|
3107
3108
|
#
|
@@ -3556,6 +3557,11 @@ module Sc2
|
|
3556
3557
|
# _@return_ — gas structures
|
3557
3558
|
def gas: () -> UnitGroup
|
3558
3559
|
|
3560
|
+
# Selects units passively have Detection
|
3561
|
+
#
|
3562
|
+
# _@return_ — gas structures
|
3563
|
+
def detectors: () -> UnitGroup
|
3564
|
+
|
3559
3565
|
# Selects only units which have finished constructing, i.o.w. build_progress == 1.0
|
3560
3566
|
#
|
3561
3567
|
# _@return_ — complete unit group
|
@@ -3726,6 +3732,7 @@ module Sc2
|
|
3726
3732
|
TYPE_TECHLAB: untyped
|
3727
3733
|
TYPE_REACTOR: ::Array[Integer]
|
3728
3734
|
TYPE_BASES: ::Array[Integer]
|
3735
|
+
TYPE_DETECTORS: ::Array[Integer]
|
3729
3736
|
|
3730
3737
|
# _@param_ `unit_group`
|
3731
3738
|
def initialize: (Sc2::UnitGroup unit_group) -> void
|
@@ -4067,6 +4074,9 @@ module Sc2
|
|
4067
4074
|
|
4068
4075
|
def initialize: () -> void
|
4069
4076
|
|
4077
|
+
# Returns the value of attribute host.
|
4078
|
+
attr_accessor host: untyped
|
4079
|
+
|
4070
4080
|
# Returns the value of attribute clients.
|
4071
4081
|
attr_accessor clients: untyped
|
4072
4082
|
|
@@ -4203,9 +4213,8 @@ module Sc2
|
|
4203
4213
|
# _@param_ `distance` — The distance to move.
|
4204
4214
|
def away_from: (Api::Point2D other, Float distance) -> Api::Point2D
|
4205
4215
|
|
4206
|
-
# sord warn - "Array[Float,Float]" does not appear to be a type
|
4207
4216
|
# Returns [x,y] array tuple
|
4208
|
-
def to_axy: () ->
|
4217
|
+
def to_axy: () -> ::Array[(Float | Float)]
|
4209
4218
|
|
4210
4219
|
# Returns [x,y] array tuple where floats are cast to ints
|
4211
4220
|
# Useful when trying to find the tile which something is on
|
@@ -7902,9 +7911,8 @@ module Api
|
|
7902
7911
|
# _@param_ `distance` — The distance to move.
|
7903
7912
|
def away_from: (Api::Point2D other, Float distance) -> Api::Point2D
|
7904
7913
|
|
7905
|
-
# sord warn - "Array[Float,Float]" does not appear to be a type
|
7906
7914
|
# Returns [x,y] array tuple
|
7907
|
-
def to_axy: () ->
|
7915
|
+
def to_axy: () -> ::Array[(Float | Float)]
|
7908
7916
|
|
7909
7917
|
# Returns [x,y] array tuple where floats are cast to ints
|
7910
7918
|
# Useful when trying to find the tile which something is on
|
@@ -8466,7 +8474,7 @@ module Api
|
|
8466
8474
|
# _@return_ — true if refreshed or false unchanged
|
8467
8475
|
def refresh!: () -> bool
|
8468
8476
|
|
8469
|
-
# Returns static
|
8477
|
+
# Returns static an array of attributes for a unit
|
8470
8478
|
def attributes: () -> ::Array[Api::Attribute]
|
8471
8479
|
|
8472
8480
|
# sord omit - no YARD type given for "attribute", using untyped
|
@@ -8520,7 +8528,7 @@ module Api
|
|
8520
8528
|
# _@return_ — whether unit has attribute :Structure
|
8521
8529
|
def is_structure?: () -> bool
|
8522
8530
|
|
8523
|
-
# Checks if unit is
|
8531
|
+
# Checks if unit is hovering
|
8524
8532
|
#
|
8525
8533
|
# _@return_ — whether unit has attribute :Hover
|
8526
8534
|
def is_hover?: () -> bool
|
@@ -8535,6 +8543,10 @@ module Api
|
|
8535
8543
|
# _@return_ — whether unit has attribute :Summoned
|
8536
8544
|
def is_summoned?: () -> bool
|
8537
8545
|
|
8546
|
+
# Returns whether the unit is cloaked. Revealed cloak units also return true.
|
8547
|
+
# For further distinction, use Unit#cloaked, which uses enum CloakedState
|
8548
|
+
def is_cloaked?: () -> bool
|
8549
|
+
|
8538
8550
|
# Whether unit is effected by buff_id
|
8539
8551
|
#
|
8540
8552
|
# _@param_ `buff_id`
|
@@ -8630,12 +8642,12 @@ module Api
|
|
8630
8642
|
def debug_draw_placement: (?Api::Color? color) -> void
|
8631
8643
|
|
8632
8644
|
# sord omit - no YARD return type given, using untyped
|
8633
|
-
# Draws a sphere around the unit's attack range
|
8645
|
+
# Draws a sphere around the unit's attack range (weapon range + radius)
|
8634
8646
|
#
|
8635
|
-
# _@param_ `weapon_index` — default first weapon, see UnitTypeData
|
8647
|
+
# _@param_ `weapon_index` — default first weapon, see UnitTypeData#weapons
|
8636
8648
|
#
|
8637
8649
|
# _@param_ `color` — optional api color, default red
|
8638
|
-
def debug_fire_range: (?
|
8650
|
+
def debug_fire_range: (?Integer weapon_index, ?Api::Color? color) -> untyped
|
8639
8651
|
|
8640
8652
|
# sord omit - no YARD return type given, using untyped
|
8641
8653
|
# Calculates the distance between self and other
|
@@ -8685,18 +8697,22 @@ module Api
|
|
8685
8697
|
def is_engaged_with?: ((Api::Unit | Integer) unit) -> bool
|
8686
8698
|
|
8687
8699
|
# Checks whether enemy is within range of weapon or ability and can target ground/air.
|
8688
|
-
#
|
8700
|
+
# By default, checks all weapons.
|
8701
|
+
# Pass weapon_index or ability_id to target a specific source of damage.
|
8689
8702
|
#
|
8690
8703
|
# _@param_ `unit` — enemy
|
8691
8704
|
#
|
8692
|
-
# _@param_ `weapon_index` —
|
8705
|
+
# _@param_ `weapon_index` — passing this will select a specific Weapon
|
8693
8706
|
#
|
8694
8707
|
# _@param_ `ability_id` — passing this will override weapon Api::AbilityId::*
|
8695
8708
|
#
|
8696
8709
|
# ```ruby
|
8710
|
+
# queen.can_attack?(enemy, weapon_index: 0) # Air attack
|
8711
|
+
# queen.can_attack?(enemy, weapon_index: 1) # Ground attack
|
8712
|
+
# queen.can_attack?(enemy) # Auto detect (scans all weapons)
|
8697
8713
|
# ghost.can_attack?(enemy, weapon_index: 0, ability_id: Api::AbilityId::SNIPE)
|
8698
8714
|
# ```
|
8699
|
-
def can_attack?: (unit: Api::Unit, ?weapon_index: Integer
|
8715
|
+
def can_attack?: (unit: Api::Unit, ?weapon_index: Integer?, ?ability_id: Integer?) -> bool
|
8700
8716
|
|
8701
8717
|
# Returns whether this unit has an ability available
|
8702
8718
|
# Queries API if necessary
|
@@ -8711,9 +8727,12 @@ module Api
|
|
8711
8727
|
# _@param_ `weapon`
|
8712
8728
|
def can_weapon_target_unit?: (unit: Api::Unit, weapon: Api::Weapon) -> bool
|
8713
8729
|
|
8714
|
-
#
|
8715
|
-
#
|
8716
|
-
|
8730
|
+
# Checks whether an ability can target a unit
|
8731
|
+
#
|
8732
|
+
# _@param_ `unit`
|
8733
|
+
#
|
8734
|
+
# _@param_ `ability`
|
8735
|
+
def can_ability_target_unit?: (unit: Api::Unit, ability: Api::AbilityData) -> bool
|
8717
8736
|
|
8718
8737
|
# Checks whether opposing unit is in the attack range.
|
8719
8738
|
#
|
@@ -14559,9 +14578,8 @@ module Api
|
|
14559
14578
|
# _@param_ `distance` — The distance to move.
|
14560
14579
|
def away_from: (Api::Point2D other, Float distance) -> Api::Point2D
|
14561
14580
|
|
14562
|
-
# sord warn - "Array[Float,Float]" does not appear to be a type
|
14563
14581
|
# Returns [x,y] array tuple
|
14564
|
-
def to_axy: () ->
|
14582
|
+
def to_axy: () -> ::Array[(Float | Float)]
|
14565
14583
|
|
14566
14584
|
# Returns [x,y] array tuple where floats are cast to ints
|
14567
14585
|
# Useful when trying to find the tile which something is on
|
@@ -14817,9 +14835,8 @@ module Api
|
|
14817
14835
|
# _@param_ `distance` — The distance to move.
|
14818
14836
|
def away_from: (Api::Point2D other, Float distance) -> Api::Point2D
|
14819
14837
|
|
14820
|
-
# sord warn - "Array[Float,Float]" does not appear to be a type
|
14821
14838
|
# Returns [x,y] array tuple
|
14822
|
-
def to_axy: () ->
|
14839
|
+
def to_axy: () -> ::Array[(Float | Float)]
|
14823
14840
|
|
14824
14841
|
# Returns [x,y] array tuple where floats are cast to ints
|
14825
14842
|
# Useful when trying to find the tile which something is on
|
@@ -15043,9 +15060,8 @@ module Api
|
|
15043
15060
|
# _@param_ `distance` — The distance to move.
|
15044
15061
|
def away_from: (Api::Point2D other, Float distance) -> Api::Point2D
|
15045
15062
|
|
15046
|
-
# sord warn - "Array[Float,Float]" does not appear to be a type
|
15047
15063
|
# Returns [x,y] array tuple
|
15048
|
-
def to_axy: () ->
|
15064
|
+
def to_axy: () -> ::Array[(Float | Float)]
|
15049
15065
|
|
15050
15066
|
# Returns [x,y] array tuple where floats are cast to ints
|
15051
15067
|
# Useful when trying to find the tile which something is on
|
@@ -15249,9 +15265,8 @@ module Api
|
|
15249
15265
|
# _@param_ `distance` — The distance to move.
|
15250
15266
|
def away_from: (Api::Point2D other, Float distance) -> Api::Point2D
|
15251
15267
|
|
15252
|
-
# sord warn - "Array[Float,Float]" does not appear to be a type
|
15253
15268
|
# Returns [x,y] array tuple
|
15254
|
-
def to_axy: () ->
|
15269
|
+
def to_axy: () -> ::Array[(Float | Float)]
|
15255
15270
|
|
15256
15271
|
# Returns [x,y] array tuple where floats are cast to ints
|
15257
15272
|
# Useful when trying to find the tile which something is on
|
@@ -18798,6 +18813,8 @@ module Api
|
|
18798
18813
|
end
|
18799
18814
|
|
18800
18815
|
class PlayerCommon
|
18816
|
+
include Api::PlayerCommonExt
|
18817
|
+
|
18801
18818
|
# sord omit - no YARD type given for "buff", using untyped
|
18802
18819
|
# sord omit - no YARD return type given, using untyped
|
18803
18820
|
def self.decode: (untyped buff) -> untyped
|
@@ -20406,7 +20423,7 @@ module Api
|
|
20406
20423
|
# _@return_ — true if refreshed or false unchanged
|
20407
20424
|
def refresh!: () -> bool
|
20408
20425
|
|
20409
|
-
# Returns static
|
20426
|
+
# Returns static an array of attributes for a unit
|
20410
20427
|
def attributes: () -> ::Array[Api::Attribute]
|
20411
20428
|
|
20412
20429
|
# sord omit - no YARD type given for "attribute", using untyped
|
@@ -20460,7 +20477,7 @@ module Api
|
|
20460
20477
|
# _@return_ — whether unit has attribute :Structure
|
20461
20478
|
def is_structure?: () -> bool
|
20462
20479
|
|
20463
|
-
# Checks if unit is
|
20480
|
+
# Checks if unit is hovering
|
20464
20481
|
#
|
20465
20482
|
# _@return_ — whether unit has attribute :Hover
|
20466
20483
|
def is_hover?: () -> bool
|
@@ -20475,6 +20492,10 @@ module Api
|
|
20475
20492
|
# _@return_ — whether unit has attribute :Summoned
|
20476
20493
|
def is_summoned?: () -> bool
|
20477
20494
|
|
20495
|
+
# Returns whether the unit is cloaked. Revealed cloak units also return true.
|
20496
|
+
# For further distinction, use Unit#cloaked, which uses enum CloakedState
|
20497
|
+
def is_cloaked?: () -> bool
|
20498
|
+
|
20478
20499
|
# Whether unit is effected by buff_id
|
20479
20500
|
#
|
20480
20501
|
# _@param_ `buff_id`
|
@@ -20570,12 +20591,12 @@ module Api
|
|
20570
20591
|
def debug_draw_placement: (?Api::Color? color) -> void
|
20571
20592
|
|
20572
20593
|
# sord omit - no YARD return type given, using untyped
|
20573
|
-
# Draws a sphere around the unit's attack range
|
20594
|
+
# Draws a sphere around the unit's attack range (weapon range + radius)
|
20574
20595
|
#
|
20575
|
-
# _@param_ `weapon_index` — default first weapon, see UnitTypeData
|
20596
|
+
# _@param_ `weapon_index` — default first weapon, see UnitTypeData#weapons
|
20576
20597
|
#
|
20577
20598
|
# _@param_ `color` — optional api color, default red
|
20578
|
-
def debug_fire_range: (?
|
20599
|
+
def debug_fire_range: (?Integer weapon_index, ?Api::Color? color) -> untyped
|
20579
20600
|
|
20580
20601
|
# sord omit - no YARD return type given, using untyped
|
20581
20602
|
# Calculates the distance between self and other
|
@@ -20625,18 +20646,22 @@ module Api
|
|
20625
20646
|
def is_engaged_with?: ((Api::Unit | Integer) unit) -> bool
|
20626
20647
|
|
20627
20648
|
# Checks whether enemy is within range of weapon or ability and can target ground/air.
|
20628
|
-
#
|
20649
|
+
# By default, checks all weapons.
|
20650
|
+
# Pass weapon_index or ability_id to target a specific source of damage.
|
20629
20651
|
#
|
20630
20652
|
# _@param_ `unit` — enemy
|
20631
20653
|
#
|
20632
|
-
# _@param_ `weapon_index` —
|
20654
|
+
# _@param_ `weapon_index` — passing this will select a specific Weapon
|
20633
20655
|
#
|
20634
20656
|
# _@param_ `ability_id` — passing this will override weapon Api::AbilityId::*
|
20635
20657
|
#
|
20636
20658
|
# ```ruby
|
20659
|
+
# queen.can_attack?(enemy, weapon_index: 0) # Air attack
|
20660
|
+
# queen.can_attack?(enemy, weapon_index: 1) # Ground attack
|
20661
|
+
# queen.can_attack?(enemy) # Auto detect (scans all weapons)
|
20637
20662
|
# ghost.can_attack?(enemy, weapon_index: 0, ability_id: Api::AbilityId::SNIPE)
|
20638
20663
|
# ```
|
20639
|
-
def can_attack?: (unit: Api::Unit, ?weapon_index: Integer
|
20664
|
+
def can_attack?: (unit: Api::Unit, ?weapon_index: Integer?, ?ability_id: Integer?) -> bool
|
20640
20665
|
|
20641
20666
|
# Returns whether this unit has an ability available
|
20642
20667
|
# Queries API if necessary
|
@@ -20651,9 +20676,12 @@ module Api
|
|
20651
20676
|
# _@param_ `weapon`
|
20652
20677
|
def can_weapon_target_unit?: (unit: Api::Unit, weapon: Api::Weapon) -> bool
|
20653
20678
|
|
20654
|
-
#
|
20655
|
-
#
|
20656
|
-
|
20679
|
+
# Checks whether an ability can target a unit
|
20680
|
+
#
|
20681
|
+
# _@param_ `unit`
|
20682
|
+
#
|
20683
|
+
# _@param_ `ability`
|
20684
|
+
def can_ability_target_unit?: (unit: Api::Unit, ability: Api::AbilityData) -> bool
|
20657
20685
|
|
20658
20686
|
# Checks whether opposing unit is in the attack range.
|
20659
20687
|
#
|
@@ -20748,6 +20776,12 @@ module Api
|
|
20748
20776
|
# width = radius * 2
|
20749
20777
|
attr_accessor width: Float
|
20750
20778
|
|
20779
|
+
attr_reader full_health?: bool
|
20780
|
+
|
20781
|
+
attr_reader full_shields?: bool
|
20782
|
+
|
20783
|
+
attr_reader full_energy?: bool
|
20784
|
+
|
20751
20785
|
attr_reader is_flying?: bool
|
20752
20786
|
|
20753
20787
|
attr_reader is_burrowed?: bool
|
@@ -20766,6 +20800,10 @@ module Api
|
|
20766
20800
|
|
20767
20801
|
# Returns whether the unit is grounded (not flying).
|
20768
20802
|
attr_reader is_ground?: bool
|
20803
|
+
|
20804
|
+
# Returns whether the unit is cloaked. Revealed cloak units also return true.
|
20805
|
+
# For further distinction, use Unit#cloaked, which uses enum CloakedState
|
20806
|
+
attr_reader is_cloaked??: bool
|
20769
20807
|
end
|
20770
20808
|
|
20771
20809
|
# Adds additional functionality and fixes quirks with color specifically pertaining to debug commands
|
@@ -20991,9 +21029,8 @@ module Api
|
|
20991
21029
|
# _@param_ `distance` — The distance to move.
|
20992
21030
|
def away_from: (Api::Point2D other, Float distance) -> Api::Point2D
|
20993
21031
|
|
20994
|
-
# sord warn - "Array[Float,Float]" does not appear to be a type
|
20995
21032
|
# Returns [x,y] array tuple
|
20996
|
-
def to_axy: () ->
|
21033
|
+
def to_axy: () -> ::Array[(Float | Float)]
|
20997
21034
|
|
20998
21035
|
# Returns [x,y] array tuple where floats are cast to ints
|
20999
21036
|
# Useful when trying to find the tile which something is on
|
@@ -21021,6 +21058,17 @@ module Api
|
|
21021
21058
|
end
|
21022
21059
|
end
|
21023
21060
|
|
21061
|
+
# Adds additional functionality to message object Api::Point2D
|
21062
|
+
module PlayerCommonExt
|
21063
|
+
attr_accessor supply_cap: Integer
|
21064
|
+
|
21065
|
+
attr_accessor supply_used: Integer
|
21066
|
+
|
21067
|
+
attr_accessor supply_army: Integer
|
21068
|
+
|
21069
|
+
attr_accessor supply_workers: Integer
|
21070
|
+
end
|
21071
|
+
|
21024
21072
|
# Adds additional functionality to message object Api::Unit
|
21025
21073
|
module PointDistanceExtension
|
21026
21074
|
end
|
@@ -21047,6 +21095,24 @@ module Api
|
|
21047
21095
|
#
|
21048
21096
|
# _@return_ — side-length for placement
|
21049
21097
|
attr_accessor placement_length: (Integer | untyped)
|
21098
|
+
|
21099
|
+
# Ground weapon range or 0.0 when it can't shoot ground
|
21100
|
+
attr_accessor ground_range: (Float | untyped)
|
21101
|
+
|
21102
|
+
# Air weapon range or 0.0 when it can't shoot air
|
21103
|
+
attr_accessor air_range: (Float | untyped)
|
21104
|
+
|
21105
|
+
# Ground weapon damage or 0.0
|
21106
|
+
attr_accessor ground_damage: (Float | untyped)
|
21107
|
+
|
21108
|
+
# Air weapon damage or 0.0
|
21109
|
+
attr_accessor air_damage: (Float | untyped)
|
21110
|
+
|
21111
|
+
# Ground weapon damage per second or 0.0
|
21112
|
+
attr_accessor ground_dps: (Float | untyped)
|
21113
|
+
|
21114
|
+
# Air weapon damage per second or 0.0
|
21115
|
+
attr_accessor air_dps: (Float | untyped)
|
21050
21116
|
end
|
21051
21117
|
|
21052
21118
|
# This module make sure that a read from method ability_id always returns the proper source id
|