sc2ai 0.4.3 → 0.5.0

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.
@@ -130,7 +130,7 @@ module Api
130
130
 
131
131
  unknown_bytes = +"".b
132
132
  val = tag
133
- while val != 0
133
+ loop do
134
134
  byte = val & 0x7F
135
135
 
136
136
  val >>= 7
@@ -141,6 +141,7 @@ module Api
141
141
 
142
142
  byte |= 0x80 if val != 0
143
143
  unknown_bytes << byte
144
+ break if val == 0
144
145
  end
145
146
 
146
147
  case wire_type
@@ -215,7 +216,7 @@ module Api
215
216
  end
216
217
 
217
218
  val = value
218
- while val != 0
219
+ loop do
219
220
  byte = val & 0x7F
220
221
 
221
222
  val >>= 7
@@ -226,6 +227,7 @@ module Api
226
227
 
227
228
  byte |= 0x80 if val != 0
228
229
  unknown_bytes << byte
230
+ break if val == 0
229
231
  end
230
232
 
231
233
  unknown_bytes << buff.byteslice(index, value)
@@ -632,10 +634,38 @@ module Api
632
634
 
633
635
  def to_h
634
636
  result = {}
635
- result["renders".to_sym] = @renders.to_h
636
- result["minimap_renders".to_sym] = @minimap_renders.to_h
637
+
638
+ result[:"renders"] = @renders.to_h
639
+ result[:"minimap_renders"] = @minimap_renders.to_h
640
+
641
+ result
642
+ end
643
+
644
+ def as_json(options = {})
645
+ result = {}
646
+
647
+ result["renders"] = (
648
+ if @renders.nil?
649
+ {}
650
+ else
651
+ @renders.as_json(options)
652
+ end
653
+ ) if !options[:compact] || has_renders?
654
+ result["minimapRenders"] = (
655
+ if @minimap_renders.nil?
656
+ {}
657
+ else
658
+ @minimap_renders.as_json(options)
659
+ end
660
+ ) if !options[:compact] || has_minimap_renders?
661
+
637
662
  result
638
663
  end
664
+
665
+ def to_json(as_json_options = {})
666
+ require "json"
667
+ JSON.dump(as_json(as_json_options))
668
+ end
639
669
  end
640
670
  class FeatureLayers
641
671
  def self.decode(buff)
@@ -1267,7 +1297,7 @@ module Api
1267
1297
 
1268
1298
  unknown_bytes = +"".b
1269
1299
  val = tag
1270
- while val != 0
1300
+ loop do
1271
1301
  byte = val & 0x7F
1272
1302
 
1273
1303
  val >>= 7
@@ -1278,6 +1308,7 @@ module Api
1278
1308
 
1279
1309
  byte |= 0x80 if val != 0
1280
1310
  unknown_bytes << byte
1311
+ break if val == 0
1281
1312
  end
1282
1313
 
1283
1314
  case wire_type
@@ -1352,7 +1383,7 @@ module Api
1352
1383
  end
1353
1384
 
1354
1385
  val = value
1355
- while val != 0
1386
+ loop do
1356
1387
  byte = val & 0x7F
1357
1388
 
1358
1389
  val >>= 7
@@ -1363,6 +1394,7 @@ module Api
1363
1394
 
1364
1395
  byte |= 0x80 if val != 0
1365
1396
  unknown_bytes << byte
1397
+ break if val == 0
1366
1398
  end
1367
1399
 
1368
1400
  unknown_bytes << buff.byteslice(index, value)
@@ -5800,35 +5832,222 @@ module Api
5800
5832
 
5801
5833
  def to_h
5802
5834
  result = {}
5803
- result["height_map".to_sym] = @height_map.to_h
5804
- result["visibility_map".to_sym] = @visibility_map.to_h
5805
- result["creep".to_sym] = @creep.to_h
5806
- result["power".to_sym] = @power.to_h
5807
- result["player_id".to_sym] = @player_id.to_h
5808
- result["unit_type".to_sym] = @unit_type.to_h
5809
- result["selected".to_sym] = @selected.to_h
5810
- result["unit_hit_points".to_sym] = @unit_hit_points.to_h
5811
- result["unit_hit_points_ratio".to_sym] = @unit_hit_points_ratio.to_h
5812
- result["unit_energy".to_sym] = @unit_energy.to_h
5813
- result["unit_energy_ratio".to_sym] = @unit_energy_ratio.to_h
5814
- result["unit_shields".to_sym] = @unit_shields.to_h
5815
- result["unit_shields_ratio".to_sym] = @unit_shields_ratio.to_h
5816
- result["player_relative".to_sym] = @player_relative.to_h
5817
- result["unit_density_aa".to_sym] = @unit_density_aa.to_h
5818
- result["unit_density".to_sym] = @unit_density.to_h
5819
- result["effects".to_sym] = @effects.to_h
5820
- result["hallucinations".to_sym] = @hallucinations.to_h
5821
- result["cloaked".to_sym] = @cloaked.to_h
5822
- result["blip".to_sym] = @blip.to_h
5823
- result["buffs".to_sym] = @buffs.to_h
5824
- result["buff_duration".to_sym] = @buff_duration.to_h
5825
- result["active".to_sym] = @active.to_h
5826
- result["build_progress".to_sym] = @build_progress.to_h
5827
- result["buildable".to_sym] = @buildable.to_h
5828
- result["pathable".to_sym] = @pathable.to_h
5829
- result["placeholder".to_sym] = @placeholder.to_h
5835
+
5836
+ result[:"height_map"] = @height_map.to_h
5837
+ result[:"visibility_map"] = @visibility_map.to_h
5838
+ result[:"creep"] = @creep.to_h
5839
+ result[:"power"] = @power.to_h
5840
+ result[:"player_id"] = @player_id.to_h
5841
+ result[:"unit_type"] = @unit_type.to_h
5842
+ result[:"selected"] = @selected.to_h
5843
+ result[:"unit_hit_points"] = @unit_hit_points.to_h
5844
+ result[:"unit_energy"] = @unit_energy.to_h
5845
+ result[:"unit_shields"] = @unit_shields.to_h
5846
+ result[:"player_relative"] = @player_relative.to_h
5847
+ result[:"unit_density_aa"] = @unit_density_aa.to_h
5848
+ result[:"unit_density"] = @unit_density.to_h
5849
+ result[:"unit_hit_points_ratio"] = @unit_hit_points_ratio.to_h
5850
+ result[:"unit_energy_ratio"] = @unit_energy_ratio.to_h
5851
+ result[:"unit_shields_ratio"] = @unit_shields_ratio.to_h
5852
+ result[:"effects"] = @effects.to_h
5853
+ result[:"hallucinations"] = @hallucinations.to_h
5854
+ result[:"cloaked"] = @cloaked.to_h
5855
+ result[:"blip"] = @blip.to_h
5856
+ result[:"buffs"] = @buffs.to_h
5857
+ result[:"active"] = @active.to_h
5858
+ result[:"buff_duration"] = @buff_duration.to_h
5859
+ result[:"build_progress"] = @build_progress.to_h
5860
+ result[:"buildable"] = @buildable.to_h
5861
+ result[:"pathable"] = @pathable.to_h
5862
+ result[:"placeholder"] = @placeholder.to_h
5863
+
5864
+ result
5865
+ end
5866
+
5867
+ def as_json(options = {})
5868
+ result = {}
5869
+
5870
+ result["heightMap"] = (
5871
+ if @height_map.nil?
5872
+ {}
5873
+ else
5874
+ @height_map.as_json(options)
5875
+ end
5876
+ ) if !options[:compact] || has_height_map?
5877
+ result["visibilityMap"] = (
5878
+ if @visibility_map.nil?
5879
+ {}
5880
+ else
5881
+ @visibility_map.as_json(options)
5882
+ end
5883
+ ) if !options[:compact] || has_visibility_map?
5884
+ result["creep"] = @creep.nil? ? {} : @creep.as_json(options) if !options[
5885
+ :compact
5886
+ ] || has_creep?
5887
+ result["power"] = @power.nil? ? {} : @power.as_json(options) if !options[
5888
+ :compact
5889
+ ] || has_power?
5890
+ result["playerId"] = (
5891
+ if @player_id.nil?
5892
+ {}
5893
+ else
5894
+ @player_id.as_json(options)
5895
+ end
5896
+ ) if !options[:compact] || has_player_id?
5897
+ result["unitType"] = (
5898
+ if @unit_type.nil?
5899
+ {}
5900
+ else
5901
+ @unit_type.as_json(options)
5902
+ end
5903
+ ) if !options[:compact] || has_unit_type?
5904
+ result["selected"] = (
5905
+ if @selected.nil?
5906
+ {}
5907
+ else
5908
+ @selected.as_json(options)
5909
+ end
5910
+ ) if !options[:compact] || has_selected?
5911
+ result["unitHitPoints"] = (
5912
+ if @unit_hit_points.nil?
5913
+ {}
5914
+ else
5915
+ @unit_hit_points.as_json(options)
5916
+ end
5917
+ ) if !options[:compact] || has_unit_hit_points?
5918
+ result["unitEnergy"] = (
5919
+ if @unit_energy.nil?
5920
+ {}
5921
+ else
5922
+ @unit_energy.as_json(options)
5923
+ end
5924
+ ) if !options[:compact] || has_unit_energy?
5925
+ result["unitShields"] = (
5926
+ if @unit_shields.nil?
5927
+ {}
5928
+ else
5929
+ @unit_shields.as_json(options)
5930
+ end
5931
+ ) if !options[:compact] || has_unit_shields?
5932
+ result["playerRelative"] = (
5933
+ if @player_relative.nil?
5934
+ {}
5935
+ else
5936
+ @player_relative.as_json(options)
5937
+ end
5938
+ ) if !options[:compact] || has_player_relative?
5939
+ result["unitDensityAa"] = (
5940
+ if @unit_density_aa.nil?
5941
+ {}
5942
+ else
5943
+ @unit_density_aa.as_json(options)
5944
+ end
5945
+ ) if !options[:compact] || has_unit_density_aa?
5946
+ result["unitDensity"] = (
5947
+ if @unit_density.nil?
5948
+ {}
5949
+ else
5950
+ @unit_density.as_json(options)
5951
+ end
5952
+ ) if !options[:compact] || has_unit_density?
5953
+ result["unitHitPointsRatio"] = (
5954
+ if @unit_hit_points_ratio.nil?
5955
+ {}
5956
+ else
5957
+ @unit_hit_points_ratio.as_json(options)
5958
+ end
5959
+ ) if !options[:compact] || has_unit_hit_points_ratio?
5960
+ result["unitEnergyRatio"] = (
5961
+ if @unit_energy_ratio.nil?
5962
+ {}
5963
+ else
5964
+ @unit_energy_ratio.as_json(options)
5965
+ end
5966
+ ) if !options[:compact] || has_unit_energy_ratio?
5967
+ result["unitShieldsRatio"] = (
5968
+ if @unit_shields_ratio.nil?
5969
+ {}
5970
+ else
5971
+ @unit_shields_ratio.as_json(options)
5972
+ end
5973
+ ) if !options[:compact] || has_unit_shields_ratio?
5974
+ result["effects"] = (
5975
+ if @effects.nil?
5976
+ {}
5977
+ else
5978
+ @effects.as_json(options)
5979
+ end
5980
+ ) if !options[:compact] || has_effects?
5981
+ result["hallucinations"] = (
5982
+ if @hallucinations.nil?
5983
+ {}
5984
+ else
5985
+ @hallucinations.as_json(options)
5986
+ end
5987
+ ) if !options[:compact] || has_hallucinations?
5988
+ result["cloaked"] = (
5989
+ if @cloaked.nil?
5990
+ {}
5991
+ else
5992
+ @cloaked.as_json(options)
5993
+ end
5994
+ ) if !options[:compact] || has_cloaked?
5995
+ result["blip"] = @blip.nil? ? {} : @blip.as_json(options) if !options[
5996
+ :compact
5997
+ ] || has_blip?
5998
+ result["buffs"] = @buffs.nil? ? {} : @buffs.as_json(options) if !options[
5999
+ :compact
6000
+ ] || has_buffs?
6001
+ result["active"] = (
6002
+ if @active.nil?
6003
+ {}
6004
+ else
6005
+ @active.as_json(options)
6006
+ end
6007
+ ) if !options[:compact] || has_active?
6008
+ result["buffDuration"] = (
6009
+ if @buff_duration.nil?
6010
+ {}
6011
+ else
6012
+ @buff_duration.as_json(options)
6013
+ end
6014
+ ) if !options[:compact] || has_buff_duration?
6015
+ result["buildProgress"] = (
6016
+ if @build_progress.nil?
6017
+ {}
6018
+ else
6019
+ @build_progress.as_json(options)
6020
+ end
6021
+ ) if !options[:compact] || has_build_progress?
6022
+ result["buildable"] = (
6023
+ if @buildable.nil?
6024
+ {}
6025
+ else
6026
+ @buildable.as_json(options)
6027
+ end
6028
+ ) if !options[:compact] || has_buildable?
6029
+ result["pathable"] = (
6030
+ if @pathable.nil?
6031
+ {}
6032
+ else
6033
+ @pathable.as_json(options)
6034
+ end
6035
+ ) if !options[:compact] || has_pathable?
6036
+ result["placeholder"] = (
6037
+ if @placeholder.nil?
6038
+ {}
6039
+ else
6040
+ @placeholder.as_json(options)
6041
+ end
6042
+ ) if !options[:compact] || has_placeholder?
6043
+
5830
6044
  result
5831
6045
  end
6046
+
6047
+ def to_json(as_json_options = {})
6048
+ require "json"
6049
+ JSON.dump(as_json(as_json_options))
6050
+ end
5832
6051
  end
5833
6052
  class FeatureLayersMinimap
5834
6053
  def self.decode(buff)
@@ -6140,7 +6359,7 @@ module Api
6140
6359
 
6141
6360
  unknown_bytes = +"".b
6142
6361
  val = tag
6143
- while val != 0
6362
+ loop do
6144
6363
  byte = val & 0x7F
6145
6364
 
6146
6365
  val >>= 7
@@ -6151,6 +6370,7 @@ module Api
6151
6370
 
6152
6371
  byte |= 0x80 if val != 0
6153
6372
  unknown_bytes << byte
6373
+ break if val == 0
6154
6374
  end
6155
6375
 
6156
6376
  case wire_type
@@ -6225,7 +6445,7 @@ module Api
6225
6445
  end
6226
6446
 
6227
6447
  val = value
6228
- while val != 0
6448
+ loop do
6229
6449
  byte = val & 0x7F
6230
6450
 
6231
6451
  val >>= 7
@@ -6236,6 +6456,7 @@ module Api
6236
6456
 
6237
6457
  byte |= 0x80 if val != 0
6238
6458
  unknown_bytes << byte
6459
+ break if val == 0
6239
6460
  end
6240
6461
 
6241
6462
  unknown_bytes << buff.byteslice(index, value)
@@ -8083,19 +8304,106 @@ module Api
8083
8304
 
8084
8305
  def to_h
8085
8306
  result = {}
8086
- result["height_map".to_sym] = @height_map.to_h
8087
- result["visibility_map".to_sym] = @visibility_map.to_h
8088
- result["creep".to_sym] = @creep.to_h
8089
- result["camera".to_sym] = @camera.to_h
8090
- result["player_id".to_sym] = @player_id.to_h
8091
- result["player_relative".to_sym] = @player_relative.to_h
8092
- result["selected".to_sym] = @selected.to_h
8093
- result["alerts".to_sym] = @alerts.to_h
8094
- result["buildable".to_sym] = @buildable.to_h
8095
- result["pathable".to_sym] = @pathable.to_h
8096
- result["unit_type".to_sym] = @unit_type.to_h
8307
+
8308
+ result[:"height_map"] = @height_map.to_h
8309
+ result[:"visibility_map"] = @visibility_map.to_h
8310
+ result[:"creep"] = @creep.to_h
8311
+ result[:"camera"] = @camera.to_h
8312
+ result[:"player_id"] = @player_id.to_h
8313
+ result[:"player_relative"] = @player_relative.to_h
8314
+ result[:"selected"] = @selected.to_h
8315
+ result[:"unit_type"] = @unit_type.to_h
8316
+ result[:"alerts"] = @alerts.to_h
8317
+ result[:"buildable"] = @buildable.to_h
8318
+ result[:"pathable"] = @pathable.to_h
8319
+
8320
+ result
8321
+ end
8322
+
8323
+ def as_json(options = {})
8324
+ result = {}
8325
+
8326
+ result["heightMap"] = (
8327
+ if @height_map.nil?
8328
+ {}
8329
+ else
8330
+ @height_map.as_json(options)
8331
+ end
8332
+ ) if !options[:compact] || has_height_map?
8333
+ result["visibilityMap"] = (
8334
+ if @visibility_map.nil?
8335
+ {}
8336
+ else
8337
+ @visibility_map.as_json(options)
8338
+ end
8339
+ ) if !options[:compact] || has_visibility_map?
8340
+ result["creep"] = @creep.nil? ? {} : @creep.as_json(options) if !options[
8341
+ :compact
8342
+ ] || has_creep?
8343
+ result["camera"] = (
8344
+ if @camera.nil?
8345
+ {}
8346
+ else
8347
+ @camera.as_json(options)
8348
+ end
8349
+ ) if !options[:compact] || has_camera?
8350
+ result["playerId"] = (
8351
+ if @player_id.nil?
8352
+ {}
8353
+ else
8354
+ @player_id.as_json(options)
8355
+ end
8356
+ ) if !options[:compact] || has_player_id?
8357
+ result["playerRelative"] = (
8358
+ if @player_relative.nil?
8359
+ {}
8360
+ else
8361
+ @player_relative.as_json(options)
8362
+ end
8363
+ ) if !options[:compact] || has_player_relative?
8364
+ result["selected"] = (
8365
+ if @selected.nil?
8366
+ {}
8367
+ else
8368
+ @selected.as_json(options)
8369
+ end
8370
+ ) if !options[:compact] || has_selected?
8371
+ result["unitType"] = (
8372
+ if @unit_type.nil?
8373
+ {}
8374
+ else
8375
+ @unit_type.as_json(options)
8376
+ end
8377
+ ) if !options[:compact] || has_unit_type?
8378
+ result["alerts"] = (
8379
+ if @alerts.nil?
8380
+ {}
8381
+ else
8382
+ @alerts.as_json(options)
8383
+ end
8384
+ ) if !options[:compact] || has_alerts?
8385
+ result["buildable"] = (
8386
+ if @buildable.nil?
8387
+ {}
8388
+ else
8389
+ @buildable.as_json(options)
8390
+ end
8391
+ ) if !options[:compact] || has_buildable?
8392
+ result["pathable"] = (
8393
+ if @pathable.nil?
8394
+ {}
8395
+ else
8396
+ @pathable.as_json(options)
8397
+ end
8398
+ ) if !options[:compact] || has_pathable?
8399
+
8097
8400
  result
8098
8401
  end
8402
+
8403
+ def to_json(as_json_options = {})
8404
+ require "json"
8405
+ JSON.dump(as_json(as_json_options))
8406
+ end
8099
8407
  end
8100
8408
  class ObservationRender
8101
8409
  def self.decode(buff)
@@ -8224,7 +8532,7 @@ module Api
8224
8532
 
8225
8533
  unknown_bytes = +"".b
8226
8534
  val = tag
8227
- while val != 0
8535
+ loop do
8228
8536
  byte = val & 0x7F
8229
8537
 
8230
8538
  val >>= 7
@@ -8235,6 +8543,7 @@ module Api
8235
8543
 
8236
8544
  byte |= 0x80 if val != 0
8237
8545
  unknown_bytes << byte
8546
+ break if val == 0
8238
8547
  end
8239
8548
 
8240
8549
  case wire_type
@@ -8309,7 +8618,7 @@ module Api
8309
8618
  end
8310
8619
 
8311
8620
  val = value
8312
- while val != 0
8621
+ loop do
8313
8622
  byte = val & 0x7F
8314
8623
 
8315
8624
  val >>= 7
@@ -8320,6 +8629,7 @@ module Api
8320
8629
 
8321
8630
  byte |= 0x80 if val != 0
8322
8631
  unknown_bytes << byte
8632
+ break if val == 0
8323
8633
  end
8324
8634
 
8325
8635
  unknown_bytes << buff.byteslice(index, value)
@@ -8718,10 +9028,34 @@ module Api
8718
9028
 
8719
9029
  def to_h
8720
9030
  result = {}
8721
- result["map".to_sym] = @map.to_h
8722
- result["minimap".to_sym] = @minimap.to_h
9031
+
9032
+ result[:"map"] = @map.to_h
9033
+ result[:"minimap"] = @minimap.to_h
9034
+
9035
+ result
9036
+ end
9037
+
9038
+ def as_json(options = {})
9039
+ result = {}
9040
+
9041
+ result["map"] = @map.nil? ? {} : @map.as_json(options) if !options[
9042
+ :compact
9043
+ ] || has_map?
9044
+ result["minimap"] = (
9045
+ if @minimap.nil?
9046
+ {}
9047
+ else
9048
+ @minimap.as_json(options)
9049
+ end
9050
+ ) if !options[:compact] || has_minimap?
9051
+
8723
9052
  result
8724
9053
  end
9054
+
9055
+ def to_json(as_json_options = {})
9056
+ require "json"
9057
+ JSON.dump(as_json(as_json_options))
9058
+ end
8725
9059
  end
8726
9060
  class ActionSpatial
8727
9061
  def self.decode(buff)
@@ -8876,7 +9210,7 @@ module Api
8876
9210
 
8877
9211
  unknown_bytes = +"".b
8878
9212
  val = tag
8879
- while val != 0
9213
+ loop do
8880
9214
  byte = val & 0x7F
8881
9215
 
8882
9216
  val >>= 7
@@ -8887,6 +9221,7 @@ module Api
8887
9221
 
8888
9222
  byte |= 0x80 if val != 0
8889
9223
  unknown_bytes << byte
9224
+ break if val == 0
8890
9225
  end
8891
9226
 
8892
9227
  case wire_type
@@ -8961,7 +9296,7 @@ module Api
8961
9296
  end
8962
9297
 
8963
9298
  val = value
8964
- while val != 0
9299
+ loop do
8965
9300
  byte = val & 0x7F
8966
9301
 
8967
9302
  val >>= 7
@@ -8972,6 +9307,7 @@ module Api
8972
9307
 
8973
9308
  byte |= 0x80 if val != 0
8974
9309
  unknown_bytes << byte
9310
+ break if val == 0
8975
9311
  end
8976
9312
 
8977
9313
  unknown_bytes << buff.byteslice(index, value)
@@ -9708,9 +10044,65 @@ module Api
9708
10044
 
9709
10045
  def to_h
9710
10046
  result = {}
9711
- send("action").tap { |f| result[f.to_sym] = send(f) if f }
10047
+
10048
+ resolved_action = self.action
10049
+
10050
+ result[:"unit_command"] = @unit_command.to_h if resolved_action ==
10051
+ :"unit_command"
10052
+ result[:"camera_move"] = @camera_move.to_h if resolved_action ==
10053
+ :"camera_move"
10054
+ result[
10055
+ :"unit_selection_point"
10056
+ ] = @unit_selection_point.to_h if resolved_action ==
10057
+ :"unit_selection_point"
10058
+ result[
10059
+ :"unit_selection_rect"
10060
+ ] = @unit_selection_rect.to_h if resolved_action == :"unit_selection_rect"
10061
+
10062
+ result
10063
+ end
10064
+
10065
+ def as_json(options = {})
10066
+ result = {}
10067
+
10068
+ resolved_action = self.action
10069
+
10070
+ result["unitCommand"] = (
10071
+ if @unit_command.nil?
10072
+ {}
10073
+ else
10074
+ @unit_command.as_json(options)
10075
+ end
10076
+ ) if resolved_action == :"unit_command"
10077
+ result["cameraMove"] = (
10078
+ if @camera_move.nil?
10079
+ {}
10080
+ else
10081
+ @camera_move.as_json(options)
10082
+ end
10083
+ ) if resolved_action == :"camera_move"
10084
+ result["unitSelectionPoint"] = (
10085
+ if @unit_selection_point.nil?
10086
+ {}
10087
+ else
10088
+ @unit_selection_point.as_json(options)
10089
+ end
10090
+ ) if resolved_action == :"unit_selection_point"
10091
+ result["unitSelectionRect"] = (
10092
+ if @unit_selection_rect.nil?
10093
+ {}
10094
+ else
10095
+ @unit_selection_rect.as_json(options)
10096
+ end
10097
+ ) if resolved_action == :"unit_selection_rect"
10098
+
9712
10099
  result
9713
10100
  end
10101
+
10102
+ def to_json(as_json_options = {})
10103
+ require "json"
10104
+ JSON.dump(as_json(as_json_options))
10105
+ end
9714
10106
  end
9715
10107
  class ActionSpatialUnitCommand
9716
10108
  def self.decode(buff)
@@ -9891,7 +10283,7 @@ module Api
9891
10283
 
9892
10284
  unknown_bytes = +"".b
9893
10285
  val = tag
9894
- while val != 0
10286
+ loop do
9895
10287
  byte = val & 0x7F
9896
10288
 
9897
10289
  val >>= 7
@@ -9902,6 +10294,7 @@ module Api
9902
10294
 
9903
10295
  byte |= 0x80 if val != 0
9904
10296
  unknown_bytes << byte
10297
+ break if val == 0
9905
10298
  end
9906
10299
 
9907
10300
  case wire_type
@@ -9976,7 +10369,7 @@ module Api
9976
10369
  end
9977
10370
 
9978
10371
  val = value
9979
- while val != 0
10372
+ loop do
9980
10373
  byte = val & 0x7F
9981
10374
 
9982
10375
  val >>= 7
@@ -9987,6 +10380,7 @@ module Api
9987
10380
 
9988
10381
  byte |= 0x80 if val != 0
9989
10382
  unknown_bytes << byte
10383
+ break if val == 0
9990
10384
  end
9991
10385
 
9992
10386
  unknown_bytes << buff.byteslice(index, value)
@@ -10466,10 +10860,10 @@ module Api
10466
10860
  end
10467
10861
  def _encode(buff)
10468
10862
  val = @ability_id
10469
- if val != 0
10863
+ if has_ability_id?
10470
10864
  buff << 0x08
10471
10865
 
10472
- while val != 0
10866
+ loop do
10473
10867
  byte = val & 0x7F
10474
10868
 
10475
10869
  val >>= 7
@@ -10480,6 +10874,7 @@ module Api
10480
10874
 
10481
10875
  byte |= 0x80 if val != 0
10482
10876
  buff << byte
10877
+ break if val == 0
10483
10878
  end
10484
10879
  end
10485
10880
 
@@ -10579,15 +10974,15 @@ module Api
10579
10974
  buff
10580
10975
  end
10581
10976
 
10582
- val = @queue_command
10583
- if val == true
10977
+ if has_queue_command?
10978
+ val = @queue_command
10584
10979
  buff << 0x20
10585
10980
 
10586
- buff << 1
10587
- elsif val == false
10588
- # Default value, encode nothing
10589
- else
10590
- raise "bool values should be true or false"
10981
+ if val == true
10982
+ buff << 1
10983
+ elsif val == false
10984
+ buff << 0
10985
+ end
10591
10986
  end
10592
10987
  buff << @_unknown_fields if @_unknown_fields
10593
10988
  buff
@@ -10595,11 +10990,52 @@ module Api
10595
10990
 
10596
10991
  def to_h
10597
10992
  result = {}
10598
- send("target").tap { |f| result[f.to_sym] = send(f) if f }
10599
- result["ability_id".to_sym] = @ability_id
10600
- result["queue_command".to_sym] = @queue_command
10993
+
10994
+ resolved_target = self.target
10995
+
10996
+ result[:"ability_id"] = @ability_id
10997
+ result[
10998
+ :"target_screen_coord"
10999
+ ] = @target_screen_coord.to_h if resolved_target == :"target_screen_coord"
11000
+ result[
11001
+ :"target_minimap_coord"
11002
+ ] = @target_minimap_coord.to_h if resolved_target ==
11003
+ :"target_minimap_coord"
11004
+ result[:"queue_command"] = @queue_command
11005
+
10601
11006
  result
10602
11007
  end
11008
+
11009
+ def as_json(options = {})
11010
+ result = {}
11011
+
11012
+ resolved_target = self.target
11013
+
11014
+ result["abilityId"] = @ability_id if !options[:compact] || has_ability_id?
11015
+ result["targetScreenCoord"] = (
11016
+ if @target_screen_coord.nil?
11017
+ {}
11018
+ else
11019
+ @target_screen_coord.as_json(options)
11020
+ end
11021
+ ) if resolved_target == :"target_screen_coord"
11022
+ result["targetMinimapCoord"] = (
11023
+ if @target_minimap_coord.nil?
11024
+ {}
11025
+ else
11026
+ @target_minimap_coord.as_json(options)
11027
+ end
11028
+ ) if resolved_target == :"target_minimap_coord"
11029
+ result["queueCommand"] = @queue_command if !options[:compact] ||
11030
+ has_queue_command?
11031
+
11032
+ result
11033
+ end
11034
+
11035
+ def to_json(as_json_options = {})
11036
+ require "json"
11037
+ JSON.dump(as_json(as_json_options))
11038
+ end
10603
11039
  end
10604
11040
  class ActionSpatialCameraMove
10605
11041
  def self.decode(buff)
@@ -10709,7 +11145,7 @@ module Api
10709
11145
 
10710
11146
  unknown_bytes = +"".b
10711
11147
  val = tag
10712
- while val != 0
11148
+ loop do
10713
11149
  byte = val & 0x7F
10714
11150
 
10715
11151
  val >>= 7
@@ -10720,6 +11156,7 @@ module Api
10720
11156
 
10721
11157
  byte |= 0x80 if val != 0
10722
11158
  unknown_bytes << byte
11159
+ break if val == 0
10723
11160
  end
10724
11161
 
10725
11162
  case wire_type
@@ -10794,7 +11231,7 @@ module Api
10794
11231
  end
10795
11232
 
10796
11233
  val = value
10797
- while val != 0
11234
+ loop do
10798
11235
  byte = val & 0x7F
10799
11236
 
10800
11237
  val >>= 7
@@ -10805,6 +11242,7 @@ module Api
10805
11242
 
10806
11243
  byte |= 0x80 if val != 0
10807
11244
  unknown_bytes << byte
11245
+ break if val == 0
10808
11246
  end
10809
11247
 
10810
11248
  unknown_bytes << buff.byteslice(index, value)
@@ -11042,9 +11480,30 @@ module Api
11042
11480
 
11043
11481
  def to_h
11044
11482
  result = {}
11045
- result["center_minimap".to_sym] = @center_minimap.to_h
11483
+
11484
+ result[:"center_minimap"] = @center_minimap.to_h
11485
+
11486
+ result
11487
+ end
11488
+
11489
+ def as_json(options = {})
11490
+ result = {}
11491
+
11492
+ result["centerMinimap"] = (
11493
+ if @center_minimap.nil?
11494
+ {}
11495
+ else
11496
+ @center_minimap.as_json(options)
11497
+ end
11498
+ ) if !options[:compact] || has_center_minimap?
11499
+
11046
11500
  result
11047
11501
  end
11502
+
11503
+ def to_json(as_json_options = {})
11504
+ require "json"
11505
+ JSON.dump(as_json(as_json_options))
11506
+ end
11048
11507
  end
11049
11508
  class ActionSpatialUnitSelectionPoint
11050
11509
  def self.decode(buff)
@@ -11062,31 +11521,19 @@ module Api
11062
11521
  ADD_ALL_TYPE = 4
11063
11522
 
11064
11523
  def self.lookup(val)
11065
- if val == 0
11066
- :ENUM_ACTION_SPATIAL_UNIT_SELECTION_POINT_TYPE_UNSET
11067
- elsif val == 1
11068
- :SELECT
11069
- elsif val == 2
11070
- :TOGGLE
11071
- elsif val == 3
11072
- :ALL_TYPE
11073
- elsif val == 4
11074
- :ADD_ALL_TYPE
11075
- end
11524
+ return :ENUM_ACTION_SPATIAL_UNIT_SELECTION_POINT_TYPE_UNSET if val == 0
11525
+ return :SELECT if val == 1
11526
+ return :TOGGLE if val == 2
11527
+ return :ALL_TYPE if val == 3
11528
+ return :ADD_ALL_TYPE if val == 4
11076
11529
  end
11077
11530
 
11078
11531
  def self.resolve(val)
11079
- if val == :ENUM_ACTION_SPATIAL_UNIT_SELECTION_POINT_TYPE_UNSET
11080
- 0
11081
- elsif val == :SELECT
11082
- 1
11083
- elsif val == :TOGGLE
11084
- 2
11085
- elsif val == :ALL_TYPE
11086
- 3
11087
- elsif val == :ADD_ALL_TYPE
11088
- 4
11089
- end
11532
+ return 0 if val == :ENUM_ACTION_SPATIAL_UNIT_SELECTION_POINT_TYPE_UNSET
11533
+ return 1 if val == :SELECT
11534
+ return 2 if val == :TOGGLE
11535
+ return 3 if val == :ALL_TYPE
11536
+ return 4 if val == :ADD_ALL_TYPE
11090
11537
  end
11091
11538
  end
11092
11539
  # required field readers
@@ -11102,6 +11549,7 @@ module Api
11102
11549
  # enum writers
11103
11550
  def type=(v)
11104
11551
  @type = Api::ActionSpatialUnitSelectionPoint::Type.resolve(v) || v
11552
+ @_bitmask |= 0x0000000000000002
11105
11553
  end
11106
11554
 
11107
11555
  # BEGIN writers for optional fields
@@ -11138,6 +11586,10 @@ module Api
11138
11586
  (@_bitmask & 0x0000000000000001) == 0x0000000000000001
11139
11587
  end
11140
11588
 
11589
+ def has_type?
11590
+ (@_bitmask & 0x0000000000000002) == 0x0000000000000002
11591
+ end
11592
+
11141
11593
  def decode_from(buff, index, len)
11142
11594
  @_bitmask = 0
11143
11595
 
@@ -11206,7 +11658,7 @@ module Api
11206
11658
 
11207
11659
  unknown_bytes = +"".b
11208
11660
  val = tag
11209
- while val != 0
11661
+ loop do
11210
11662
  byte = val & 0x7F
11211
11663
 
11212
11664
  val >>= 7
@@ -11217,6 +11669,7 @@ module Api
11217
11669
 
11218
11670
  byte |= 0x80 if val != 0
11219
11671
  unknown_bytes << byte
11672
+ break if val == 0
11220
11673
  end
11221
11674
 
11222
11675
  case wire_type
@@ -11291,7 +11744,7 @@ module Api
11291
11744
  end
11292
11745
 
11293
11746
  val = value
11294
- while val != 0
11747
+ loop do
11295
11748
  byte = val & 0x7F
11296
11749
 
11297
11750
  val >>= 7
@@ -11302,6 +11755,7 @@ module Api
11302
11755
 
11303
11756
  byte |= 0x80 if val != 0
11304
11757
  unknown_bytes << byte
11758
+ break if val == 0
11305
11759
  end
11306
11760
 
11307
11761
  unknown_bytes << buff.byteslice(index, value)
@@ -11655,10 +12109,10 @@ module Api
11655
12109
  end
11656
12110
 
11657
12111
  val = @type
11658
- if val != 0
12112
+ if has_type?
11659
12113
  buff << 0x10
11660
12114
 
11661
- while val != 0
12115
+ loop do
11662
12116
  byte = val & 0x7F
11663
12117
 
11664
12118
  val >>= 7
@@ -11669,6 +12123,7 @@ module Api
11669
12123
 
11670
12124
  byte |= 0x80 if val != 0
11671
12125
  buff << byte
12126
+ break if val == 0
11672
12127
  end
11673
12128
  end
11674
12129
  buff << @_unknown_fields if @_unknown_fields
@@ -11677,10 +12132,32 @@ module Api
11677
12132
 
11678
12133
  def to_h
11679
12134
  result = {}
11680
- result["selection_screen_coord".to_sym] = @selection_screen_coord.to_h
11681
- result["type".to_sym] = @type
12135
+
12136
+ result[:"selection_screen_coord"] = @selection_screen_coord.to_h
12137
+ result[:"type"] = @type
12138
+
11682
12139
  result
11683
12140
  end
12141
+
12142
+ def as_json(options = {})
12143
+ result = {}
12144
+
12145
+ result["selectionScreenCoord"] = (
12146
+ if @selection_screen_coord.nil?
12147
+ {}
12148
+ else
12149
+ @selection_screen_coord.as_json(options)
12150
+ end
12151
+ ) if !options[:compact] || has_selection_screen_coord?
12152
+ result["type"] = @type if !options[:compact] || has_type?
12153
+
12154
+ result
12155
+ end
12156
+
12157
+ def to_json(as_json_options = {})
12158
+ require "json"
12159
+ JSON.dump(as_json(as_json_options))
12160
+ end
11684
12161
  end
11685
12162
  class ActionSpatialUnitSelectionRect
11686
12163
  def self.decode(buff)
@@ -11799,7 +12276,7 @@ module Api
11799
12276
 
11800
12277
  unknown_bytes = +"".b
11801
12278
  val = tag
11802
- while val != 0
12279
+ loop do
11803
12280
  byte = val & 0x7F
11804
12281
 
11805
12282
  val >>= 7
@@ -11810,6 +12287,7 @@ module Api
11810
12287
 
11811
12288
  byte |= 0x80 if val != 0
11812
12289
  unknown_bytes << byte
12290
+ break if val == 0
11813
12291
  end
11814
12292
 
11815
12293
  case wire_type
@@ -11884,7 +12362,7 @@ module Api
11884
12362
  end
11885
12363
 
11886
12364
  val = value
11887
- while val != 0
12365
+ loop do
11888
12366
  byte = val & 0x7F
11889
12367
 
11890
12368
  val >>= 7
@@ -11895,6 +12373,7 @@ module Api
11895
12373
 
11896
12374
  byte |= 0x80 if val != 0
11897
12375
  unknown_bytes << byte
12376
+ break if val == 0
11898
12377
  end
11899
12378
 
11900
12379
  unknown_bytes << buff.byteslice(index, value)
@@ -12216,15 +12695,15 @@ module Api
12216
12695
  end
12217
12696
  end
12218
12697
 
12219
- val = @selection_add
12220
- if val == true
12698
+ if has_selection_add?
12699
+ val = @selection_add
12221
12700
  buff << 0x10
12222
12701
 
12223
- buff << 1
12224
- elsif val == false
12225
- # Default value, encode nothing
12226
- else
12227
- raise "bool values should be true or false"
12702
+ if val == true
12703
+ buff << 1
12704
+ elsif val == false
12705
+ buff << 0
12706
+ end
12228
12707
  end
12229
12708
  buff << @_unknown_fields if @_unknown_fields
12230
12709
  buff
@@ -12232,9 +12711,32 @@ module Api
12232
12711
 
12233
12712
  def to_h
12234
12713
  result = {}
12235
- result["selection_screen_coord".to_sym] = @selection_screen_coord
12236
- result["selection_add".to_sym] = @selection_add
12714
+
12715
+ result[:"selection_screen_coord"] = @selection_screen_coord.map(&:to_h)
12716
+ result[:"selection_add"] = @selection_add
12717
+
12237
12718
  result
12238
12719
  end
12720
+
12721
+ def as_json(options = {})
12722
+ result = {}
12723
+
12724
+ tmp_selection_screen_coord =
12725
+ @selection_screen_coord.map { |v| v.as_json(options) }
12726
+
12727
+ result["selectionScreenCoord"] = tmp_selection_screen_coord if !options[
12728
+ :compact
12729
+ ] || tmp_selection_screen_coord.any?
12730
+
12731
+ result["selectionAdd"] = @selection_add if !options[:compact] ||
12732
+ has_selection_add?
12733
+
12734
+ result
12735
+ end
12736
+
12737
+ def to_json(as_json_options = {})
12738
+ require "json"
12739
+ JSON.dump(as_json(as_json_options))
12740
+ end
12239
12741
  end
12240
12742
  end