sc2ai 0.4.2 → 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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/data/sc2ai/protocol/data.proto +2 -2
  3. data/data/sc2ai/protocol/debug.proto +1 -1
  4. data/data/sc2ai/protocol/raw.proto +6 -6
  5. data/data/sc2ai/protocol/sc2api.proto +1 -1
  6. data/data/sc2ai/protocol/ui.proto +1 -1
  7. data/{lib/docker_build → docker_build}/Dockerfile.ruby +2 -2
  8. data/lib/sc2ai/cli/ladderzip.rb +1 -1
  9. data/lib/sc2ai/local_play/client.rb +1 -1
  10. data/lib/sc2ai/local_play/match.rb +1 -0
  11. data/lib/sc2ai/overrides/async/process/child.rb +2 -1
  12. data/lib/sc2ai/paths.rb +0 -1
  13. data/lib/sc2ai/player/debug.rb +3 -3
  14. data/lib/sc2ai/player.rb +9 -0
  15. data/lib/sc2ai/protocol/common_pb.rb +460 -105
  16. data/lib/sc2ai/protocol/data_pb.rb +833 -482
  17. data/lib/sc2ai/protocol/debug_pb.rb +1112 -401
  18. data/lib/sc2ai/protocol/error_pb.rb +430 -862
  19. data/lib/sc2ai/protocol/extensions/action.rb +1 -1
  20. data/lib/sc2ai/protocol/extensions/color.rb +1 -1
  21. data/lib/sc2ai/protocol/extensions/point.rb +1 -1
  22. data/lib/sc2ai/protocol/extensions/point_2_d.rb +1 -1
  23. data/lib/sc2ai/protocol/extensions/point_distance.rb +4 -4
  24. data/lib/sc2ai/protocol/extensions/position.rb +20 -0
  25. data/lib/sc2ai/protocol/extensions/power_source.rb +1 -1
  26. data/lib/sc2ai/protocol/extensions/unit.rb +1 -1
  27. data/lib/sc2ai/protocol/extensions/unit_type_data.rb +1 -1
  28. data/lib/sc2ai/protocol/query_pb.rb +558 -88
  29. data/lib/sc2ai/protocol/raw_pb.rb +1829 -1156
  30. data/lib/sc2ai/protocol/sc2api_pb.rb +5233 -1463
  31. data/lib/sc2ai/protocol/score_pb.rb +444 -103
  32. data/lib/sc2ai/protocol/spatial_pb.rb +935 -145
  33. data/lib/sc2ai/protocol/ui_pb.rb +1432 -435
  34. data/lib/sc2ai/version.rb +1 -1
  35. data/lib/templates/new/api/data.proto +2 -2
  36. data/lib/templates/new/api/debug.proto +1 -1
  37. data/lib/templates/new/api/raw.proto +6 -6
  38. data/lib/templates/new/api/sc2api.proto +1 -1
  39. data/lib/templates/new/api/ui.proto +1 -1
  40. data/lib/templates/new/run_example_match.rb.tt +1 -1
  41. data/sig/sc2ai.rbs +1361 -23
  42. metadata +7 -7
  43. /data/{lib/docker_build → docker_build}/docker-compose-base-image.yml +0 -0
  44. /data/{lib/docker_build → docker_build}/docker-compose-ladderzip.yml +0 -0
@@ -140,20 +140,39 @@ module Api
140
140
  # unexpected, so discard it and continue.
141
141
  if !found
142
142
  wire_type = tag & 0x7
143
+
144
+ unknown_bytes = +"".b
145
+ val = tag
146
+ loop do
147
+ byte = val & 0x7F
148
+
149
+ val >>= 7
150
+ # This drops the top bits,
151
+ # Otherwise, with a signed right shift,
152
+ # we get infinity one bits at the top
153
+ val &= (1 << 57) - 1
154
+
155
+ byte |= 0x80 if val != 0
156
+ unknown_bytes << byte
157
+ break if val == 0
158
+ end
159
+
143
160
  case wire_type
144
161
  when 0
145
162
  i = 0
146
163
  while true
147
164
  newbyte = buff.getbyte(index)
148
165
  index += 1
149
- break if newbyte.nil? || newbyte < 0x80
166
+ break if newbyte.nil?
167
+ unknown_bytes << newbyte
168
+ break if newbyte < 0x80
150
169
  i += 1
151
170
  break if i > 9
152
171
  end
153
172
  when 1
173
+ unknown_bytes << buff.byteslice(index, 8)
154
174
  index += 8
155
175
  when 2
156
- ## PULL_BYTES
157
176
  value =
158
177
  if (byte0 = buff.getbyte(index)) < 0x80
159
178
  index += 1
@@ -209,15 +228,30 @@ module Api
209
228
  raise "integer decoding error"
210
229
  end
211
230
 
212
- buff.byteslice(index, value)
213
- index += value
231
+ val = value
232
+ loop do
233
+ byte = val & 0x7F
234
+
235
+ val >>= 7
236
+ # This drops the top bits,
237
+ # Otherwise, with a signed right shift,
238
+ # we get infinity one bits at the top
239
+ val &= (1 << 57) - 1
214
240
 
215
- ## END PULL_BYTES
241
+ byte |= 0x80 if val != 0
242
+ unknown_bytes << byte
243
+ break if val == 0
244
+ end
245
+
246
+ unknown_bytes << buff.byteslice(index, value)
247
+ index += value
216
248
  when 5
249
+ unknown_bytes << buff.byteslice(index, 4)
217
250
  index += 4
218
251
  else
219
252
  raise "unknown wire type #{wire_type}"
220
253
  end
254
+ (@_unknown_fields ||= +"".b) << unknown_bytes
221
255
  return self if index >= len
222
256
  ## PULL_UINT64
223
257
  tag =
@@ -906,30 +940,60 @@ module Api
906
940
  end
907
941
  end
908
942
 
909
- val = @ignore_resource_requirements
910
- if val == true
943
+ if has_ignore_resource_requirements?
944
+ val = @ignore_resource_requirements
911
945
  buff << 0x20
912
946
 
913
- buff << 1
914
- elsif val == false
915
- # Default value, encode nothing
916
- else
917
- raise "bool values should be true or false"
947
+ if val == true
948
+ buff << 1
949
+ elsif val == false
950
+ buff << 0
951
+ end
918
952
  end
919
-
953
+ buff << @_unknown_fields if @_unknown_fields
920
954
  buff
921
955
  end
922
956
 
923
957
  def to_h
924
958
  result = {}
925
- result["pathing".to_sym] = @pathing
926
- result["abilities".to_sym] = @abilities
927
- result["placements".to_sym] = @placements
959
+
960
+ result[:"pathing"] = @pathing.map(&:to_h)
961
+ result[:"abilities"] = @abilities.map(&:to_h)
962
+ result[:"placements"] = @placements.map(&:to_h)
963
+ result[:"ignore_resource_requirements"] = @ignore_resource_requirements
964
+
965
+ result
966
+ end
967
+
968
+ def as_json(options = {})
969
+ result = {}
970
+
971
+ tmp_pathing = @pathing.map { |v| v.as_json(options) }
972
+
973
+ result["pathing"] = tmp_pathing if !options[:compact] || tmp_pathing.any?
974
+
975
+ tmp_abilities = @abilities.map { |v| v.as_json(options) }
976
+
977
+ result["abilities"] = tmp_abilities if !options[:compact] ||
978
+ tmp_abilities.any?
979
+
980
+ tmp_placements = @placements.map { |v| v.as_json(options) }
981
+
982
+ result["placements"] = tmp_placements if !options[:compact] ||
983
+ tmp_placements.any?
984
+
928
985
  result[
929
- "ignore_resource_requirements".to_sym
930
- ] = @ignore_resource_requirements
986
+ "ignoreResourceRequirements"
987
+ ] = @ignore_resource_requirements if !options[:compact] ||
988
+ has_ignore_resource_requirements?
989
+
931
990
  result
932
991
  end
992
+
993
+ def to_json(as_json_options = {})
994
+ require "json"
995
+ JSON.dump(as_json(as_json_options))
996
+ end
933
997
  end
934
998
  class ResponseQuery
935
999
  def self.decode(buff)
@@ -1035,20 +1099,39 @@ module Api
1035
1099
  # unexpected, so discard it and continue.
1036
1100
  if !found
1037
1101
  wire_type = tag & 0x7
1102
+
1103
+ unknown_bytes = +"".b
1104
+ val = tag
1105
+ loop do
1106
+ byte = val & 0x7F
1107
+
1108
+ val >>= 7
1109
+ # This drops the top bits,
1110
+ # Otherwise, with a signed right shift,
1111
+ # we get infinity one bits at the top
1112
+ val &= (1 << 57) - 1
1113
+
1114
+ byte |= 0x80 if val != 0
1115
+ unknown_bytes << byte
1116
+ break if val == 0
1117
+ end
1118
+
1038
1119
  case wire_type
1039
1120
  when 0
1040
1121
  i = 0
1041
1122
  while true
1042
1123
  newbyte = buff.getbyte(index)
1043
1124
  index += 1
1044
- break if newbyte.nil? || newbyte < 0x80
1125
+ break if newbyte.nil?
1126
+ unknown_bytes << newbyte
1127
+ break if newbyte < 0x80
1045
1128
  i += 1
1046
1129
  break if i > 9
1047
1130
  end
1048
1131
  when 1
1132
+ unknown_bytes << buff.byteslice(index, 8)
1049
1133
  index += 8
1050
1134
  when 2
1051
- ## PULL_BYTES
1052
1135
  value =
1053
1136
  if (byte0 = buff.getbyte(index)) < 0x80
1054
1137
  index += 1
@@ -1104,15 +1187,30 @@ module Api
1104
1187
  raise "integer decoding error"
1105
1188
  end
1106
1189
 
1107
- buff.byteslice(index, value)
1108
- index += value
1190
+ val = value
1191
+ loop do
1192
+ byte = val & 0x7F
1193
+
1194
+ val >>= 7
1195
+ # This drops the top bits,
1196
+ # Otherwise, with a signed right shift,
1197
+ # we get infinity one bits at the top
1198
+ val &= (1 << 57) - 1
1109
1199
 
1110
- ## END PULL_BYTES
1200
+ byte |= 0x80 if val != 0
1201
+ unknown_bytes << byte
1202
+ break if val == 0
1203
+ end
1204
+
1205
+ unknown_bytes << buff.byteslice(index, value)
1206
+ index += value
1111
1207
  when 5
1208
+ unknown_bytes << buff.byteslice(index, 4)
1112
1209
  index += 4
1113
1210
  else
1114
1211
  raise "unknown wire type #{wire_type}"
1115
1212
  end
1213
+ (@_unknown_fields ||= +"".b) << unknown_bytes
1116
1214
  return self if index >= len
1117
1215
  ## PULL_UINT64
1118
1216
  tag =
@@ -1739,17 +1837,44 @@ module Api
1739
1837
  end
1740
1838
  end
1741
1839
  end
1742
-
1840
+ buff << @_unknown_fields if @_unknown_fields
1743
1841
  buff
1744
1842
  end
1745
1843
 
1746
1844
  def to_h
1747
1845
  result = {}
1748
- result["pathing".to_sym] = @pathing
1749
- result["abilities".to_sym] = @abilities
1750
- result["placements".to_sym] = @placements
1846
+
1847
+ result[:"pathing"] = @pathing.map(&:to_h)
1848
+ result[:"abilities"] = @abilities.map(&:to_h)
1849
+ result[:"placements"] = @placements.map(&:to_h)
1850
+
1751
1851
  result
1752
1852
  end
1853
+
1854
+ def as_json(options = {})
1855
+ result = {}
1856
+
1857
+ tmp_pathing = @pathing.map { |v| v.as_json(options) }
1858
+
1859
+ result["pathing"] = tmp_pathing if !options[:compact] || tmp_pathing.any?
1860
+
1861
+ tmp_abilities = @abilities.map { |v| v.as_json(options) }
1862
+
1863
+ result["abilities"] = tmp_abilities if !options[:compact] ||
1864
+ tmp_abilities.any?
1865
+
1866
+ tmp_placements = @placements.map { |v| v.as_json(options) }
1867
+
1868
+ result["placements"] = tmp_placements if !options[:compact] ||
1869
+ tmp_placements.any?
1870
+
1871
+ result
1872
+ end
1873
+
1874
+ def to_json(as_json_options = {})
1875
+ require "json"
1876
+ JSON.dump(as_json(as_json_options))
1877
+ end
1753
1878
  end
1754
1879
  class RequestQueryPathing
1755
1880
  def self.decode(buff)
@@ -1904,20 +2029,39 @@ module Api
1904
2029
  # unexpected, so discard it and continue.
1905
2030
  if !found
1906
2031
  wire_type = tag & 0x7
2032
+
2033
+ unknown_bytes = +"".b
2034
+ val = tag
2035
+ loop do
2036
+ byte = val & 0x7F
2037
+
2038
+ val >>= 7
2039
+ # This drops the top bits,
2040
+ # Otherwise, with a signed right shift,
2041
+ # we get infinity one bits at the top
2042
+ val &= (1 << 57) - 1
2043
+
2044
+ byte |= 0x80 if val != 0
2045
+ unknown_bytes << byte
2046
+ break if val == 0
2047
+ end
2048
+
1907
2049
  case wire_type
1908
2050
  when 0
1909
2051
  i = 0
1910
2052
  while true
1911
2053
  newbyte = buff.getbyte(index)
1912
2054
  index += 1
1913
- break if newbyte.nil? || newbyte < 0x80
2055
+ break if newbyte.nil?
2056
+ unknown_bytes << newbyte
2057
+ break if newbyte < 0x80
1914
2058
  i += 1
1915
2059
  break if i > 9
1916
2060
  end
1917
2061
  when 1
2062
+ unknown_bytes << buff.byteslice(index, 8)
1918
2063
  index += 8
1919
2064
  when 2
1920
- ## PULL_BYTES
1921
2065
  value =
1922
2066
  if (byte0 = buff.getbyte(index)) < 0x80
1923
2067
  index += 1
@@ -1973,15 +2117,30 @@ module Api
1973
2117
  raise "integer decoding error"
1974
2118
  end
1975
2119
 
1976
- buff.byteslice(index, value)
1977
- index += value
2120
+ val = value
2121
+ loop do
2122
+ byte = val & 0x7F
2123
+
2124
+ val >>= 7
2125
+ # This drops the top bits,
2126
+ # Otherwise, with a signed right shift,
2127
+ # we get infinity one bits at the top
2128
+ val &= (1 << 57) - 1
1978
2129
 
1979
- ## END PULL_BYTES
2130
+ byte |= 0x80 if val != 0
2131
+ unknown_bytes << byte
2132
+ break if val == 0
2133
+ end
2134
+
2135
+ unknown_bytes << buff.byteslice(index, value)
2136
+ index += value
1980
2137
  when 5
2138
+ unknown_bytes << buff.byteslice(index, 4)
1981
2139
  index += 4
1982
2140
  else
1983
2141
  raise "unknown wire type #{wire_type}"
1984
2142
  end
2143
+ (@_unknown_fields ||= +"".b) << unknown_bytes
1985
2144
  return self if index >= len
1986
2145
  ## PULL_UINT64
1987
2146
  tag =
@@ -2428,11 +2587,12 @@ module Api
2428
2587
  if val != 0
2429
2588
  buff << 0x10
2430
2589
 
2431
- while val != 0
2590
+ loop do
2432
2591
  byte = val & 0x7F
2433
2592
  val >>= 7
2434
2593
  byte |= 0x80 if val > 0
2435
2594
  buff << byte
2595
+ break if val == 0
2436
2596
  end
2437
2597
  end
2438
2598
 
@@ -2483,16 +2643,50 @@ module Api
2483
2643
 
2484
2644
  buff
2485
2645
  end
2486
-
2646
+ buff << @_unknown_fields if @_unknown_fields
2487
2647
  buff
2488
2648
  end
2489
2649
 
2490
2650
  def to_h
2491
2651
  result = {}
2492
- send("start").tap { |f| result[f.to_sym] = send(f) if f }
2493
- result["end_pos".to_sym] = @end_pos.to_h
2652
+
2653
+ resolved_start = self.start
2654
+
2655
+ result[:"start_pos"] = @start_pos.to_h if resolved_start == :"start_pos"
2656
+ result[:"unit_tag"] = @unit_tag if resolved_start == :"unit_tag"
2657
+ result[:"end_pos"] = @end_pos.to_h
2658
+
2494
2659
  result
2495
2660
  end
2661
+
2662
+ def as_json(options = {})
2663
+ result = {}
2664
+
2665
+ resolved_start = self.start
2666
+
2667
+ result["startPos"] = (
2668
+ if @start_pos.nil?
2669
+ {}
2670
+ else
2671
+ @start_pos.as_json(options)
2672
+ end
2673
+ ) if resolved_start == :"start_pos"
2674
+ result["unitTag"] = @unit_tag if resolved_start == :"unit_tag"
2675
+ result["endPos"] = (
2676
+ if @end_pos.nil?
2677
+ {}
2678
+ else
2679
+ @end_pos.as_json(options)
2680
+ end
2681
+ ) if !options[:compact] || has_end_pos?
2682
+
2683
+ result
2684
+ end
2685
+
2686
+ def to_json(as_json_options = {})
2687
+ require "json"
2688
+ JSON.dump(as_json(as_json_options))
2689
+ end
2496
2690
  end
2497
2691
  class ResponseQueryPathing
2498
2692
  def self.decode(buff)
@@ -2599,20 +2793,39 @@ module Api
2599
2793
  # unexpected, so discard it and continue.
2600
2794
  if !found
2601
2795
  wire_type = tag & 0x7
2796
+
2797
+ unknown_bytes = +"".b
2798
+ val = tag
2799
+ loop do
2800
+ byte = val & 0x7F
2801
+
2802
+ val >>= 7
2803
+ # This drops the top bits,
2804
+ # Otherwise, with a signed right shift,
2805
+ # we get infinity one bits at the top
2806
+ val &= (1 << 57) - 1
2807
+
2808
+ byte |= 0x80 if val != 0
2809
+ unknown_bytes << byte
2810
+ break if val == 0
2811
+ end
2812
+
2602
2813
  case wire_type
2603
2814
  when 0
2604
2815
  i = 0
2605
2816
  while true
2606
2817
  newbyte = buff.getbyte(index)
2607
2818
  index += 1
2608
- break if newbyte.nil? || newbyte < 0x80
2819
+ break if newbyte.nil?
2820
+ unknown_bytes << newbyte
2821
+ break if newbyte < 0x80
2609
2822
  i += 1
2610
2823
  break if i > 9
2611
2824
  end
2612
2825
  when 1
2826
+ unknown_bytes << buff.byteslice(index, 8)
2613
2827
  index += 8
2614
2828
  when 2
2615
- ## PULL_BYTES
2616
2829
  value =
2617
2830
  if (byte0 = buff.getbyte(index)) < 0x80
2618
2831
  index += 1
@@ -2668,15 +2881,30 @@ module Api
2668
2881
  raise "integer decoding error"
2669
2882
  end
2670
2883
 
2671
- buff.byteslice(index, value)
2672
- index += value
2884
+ val = value
2885
+ loop do
2886
+ byte = val & 0x7F
2887
+
2888
+ val >>= 7
2889
+ # This drops the top bits,
2890
+ # Otherwise, with a signed right shift,
2891
+ # we get infinity one bits at the top
2892
+ val &= (1 << 57) - 1
2893
+
2894
+ byte |= 0x80 if val != 0
2895
+ unknown_bytes << byte
2896
+ break if val == 0
2897
+ end
2673
2898
 
2674
- ## END PULL_BYTES
2899
+ unknown_bytes << buff.byteslice(index, value)
2900
+ index += value
2675
2901
  when 5
2902
+ unknown_bytes << buff.byteslice(index, 4)
2676
2903
  index += 4
2677
2904
  else
2678
2905
  raise "unknown wire type #{wire_type}"
2679
2906
  end
2907
+ (@_unknown_fields ||= +"".b) << unknown_bytes
2680
2908
  return self if index >= len
2681
2909
  ## PULL_UINT64
2682
2910
  tag =
@@ -2796,20 +3024,35 @@ module Api
2796
3024
  end
2797
3025
  def _encode(buff)
2798
3026
  val = @distance
2799
- if val != 0
3027
+ if has_distance?
2800
3028
  buff << 0x0d
2801
3029
 
2802
3030
  [val].pack("e", buffer: buff)
2803
3031
  end
2804
-
3032
+ buff << @_unknown_fields if @_unknown_fields
2805
3033
  buff
2806
3034
  end
2807
3035
 
2808
3036
  def to_h
2809
3037
  result = {}
2810
- result["distance".to_sym] = @distance
3038
+
3039
+ result[:"distance"] = @distance
3040
+
3041
+ result
3042
+ end
3043
+
3044
+ def as_json(options = {})
3045
+ result = {}
3046
+
3047
+ result["distance"] = @distance if !options[:compact] || has_distance?
3048
+
2811
3049
  result
2812
3050
  end
3051
+
3052
+ def to_json(as_json_options = {})
3053
+ require "json"
3054
+ JSON.dump(as_json(as_json_options))
3055
+ end
2813
3056
  end
2814
3057
  class RequestQueryAvailableAbilities
2815
3058
  def self.decode(buff)
@@ -2925,20 +3168,39 @@ module Api
2925
3168
  # unexpected, so discard it and continue.
2926
3169
  if !found
2927
3170
  wire_type = tag & 0x7
3171
+
3172
+ unknown_bytes = +"".b
3173
+ val = tag
3174
+ loop do
3175
+ byte = val & 0x7F
3176
+
3177
+ val >>= 7
3178
+ # This drops the top bits,
3179
+ # Otherwise, with a signed right shift,
3180
+ # we get infinity one bits at the top
3181
+ val &= (1 << 57) - 1
3182
+
3183
+ byte |= 0x80 if val != 0
3184
+ unknown_bytes << byte
3185
+ break if val == 0
3186
+ end
3187
+
2928
3188
  case wire_type
2929
3189
  when 0
2930
3190
  i = 0
2931
3191
  while true
2932
3192
  newbyte = buff.getbyte(index)
2933
3193
  index += 1
2934
- break if newbyte.nil? || newbyte < 0x80
3194
+ break if newbyte.nil?
3195
+ unknown_bytes << newbyte
3196
+ break if newbyte < 0x80
2935
3197
  i += 1
2936
3198
  break if i > 9
2937
3199
  end
2938
3200
  when 1
3201
+ unknown_bytes << buff.byteslice(index, 8)
2939
3202
  index += 8
2940
3203
  when 2
2941
- ## PULL_BYTES
2942
3204
  value =
2943
3205
  if (byte0 = buff.getbyte(index)) < 0x80
2944
3206
  index += 1
@@ -2994,15 +3256,30 @@ module Api
2994
3256
  raise "integer decoding error"
2995
3257
  end
2996
3258
 
2997
- buff.byteslice(index, value)
2998
- index += value
3259
+ val = value
3260
+ loop do
3261
+ byte = val & 0x7F
2999
3262
 
3000
- ## END PULL_BYTES
3263
+ val >>= 7
3264
+ # This drops the top bits,
3265
+ # Otherwise, with a signed right shift,
3266
+ # we get infinity one bits at the top
3267
+ val &= (1 << 57) - 1
3268
+
3269
+ byte |= 0x80 if val != 0
3270
+ unknown_bytes << byte
3271
+ break if val == 0
3272
+ end
3273
+
3274
+ unknown_bytes << buff.byteslice(index, value)
3275
+ index += value
3001
3276
  when 5
3277
+ unknown_bytes << buff.byteslice(index, 4)
3002
3278
  index += 4
3003
3279
  else
3004
3280
  raise "unknown wire type #{wire_type}"
3005
3281
  end
3282
+ (@_unknown_fields ||= +"".b) << unknown_bytes
3006
3283
  return self if index >= len
3007
3284
  ## PULL_UINT64
3008
3285
  tag =
@@ -3172,25 +3449,41 @@ module Api
3172
3449
  end
3173
3450
  def _encode(buff)
3174
3451
  val = @unit_tag
3175
- if val != 0
3452
+ if has_unit_tag?
3176
3453
  buff << 0x08
3177
3454
 
3178
- while val != 0
3455
+ loop do
3179
3456
  byte = val & 0x7F
3180
3457
  val >>= 7
3181
3458
  byte |= 0x80 if val > 0
3182
3459
  buff << byte
3460
+ break if val == 0
3183
3461
  end
3184
3462
  end
3185
-
3463
+ buff << @_unknown_fields if @_unknown_fields
3186
3464
  buff
3187
3465
  end
3188
3466
 
3189
3467
  def to_h
3190
3468
  result = {}
3191
- result["unit_tag".to_sym] = @unit_tag
3469
+
3470
+ result[:"unit_tag"] = @unit_tag
3471
+
3192
3472
  result
3193
3473
  end
3474
+
3475
+ def as_json(options = {})
3476
+ result = {}
3477
+
3478
+ result["unitTag"] = @unit_tag if !options[:compact] || has_unit_tag?
3479
+
3480
+ result
3481
+ end
3482
+
3483
+ def to_json(as_json_options = {})
3484
+ require "json"
3485
+ JSON.dump(as_json(as_json_options))
3486
+ end
3194
3487
  end
3195
3488
  class ResponseQueryAvailableAbilities
3196
3489
  def self.decode(buff)
@@ -3343,20 +3636,39 @@ module Api
3343
3636
  # unexpected, so discard it and continue.
3344
3637
  if !found
3345
3638
  wire_type = tag & 0x7
3639
+
3640
+ unknown_bytes = +"".b
3641
+ val = tag
3642
+ loop do
3643
+ byte = val & 0x7F
3644
+
3645
+ val >>= 7
3646
+ # This drops the top bits,
3647
+ # Otherwise, with a signed right shift,
3648
+ # we get infinity one bits at the top
3649
+ val &= (1 << 57) - 1
3650
+
3651
+ byte |= 0x80 if val != 0
3652
+ unknown_bytes << byte
3653
+ break if val == 0
3654
+ end
3655
+
3346
3656
  case wire_type
3347
3657
  when 0
3348
3658
  i = 0
3349
3659
  while true
3350
3660
  newbyte = buff.getbyte(index)
3351
3661
  index += 1
3352
- break if newbyte.nil? || newbyte < 0x80
3662
+ break if newbyte.nil?
3663
+ unknown_bytes << newbyte
3664
+ break if newbyte < 0x80
3353
3665
  i += 1
3354
3666
  break if i > 9
3355
3667
  end
3356
3668
  when 1
3669
+ unknown_bytes << buff.byteslice(index, 8)
3357
3670
  index += 8
3358
3671
  when 2
3359
- ## PULL_BYTES
3360
3672
  value =
3361
3673
  if (byte0 = buff.getbyte(index)) < 0x80
3362
3674
  index += 1
@@ -3412,15 +3724,30 @@ module Api
3412
3724
  raise "integer decoding error"
3413
3725
  end
3414
3726
 
3415
- buff.byteslice(index, value)
3416
- index += value
3727
+ val = value
3728
+ loop do
3729
+ byte = val & 0x7F
3730
+
3731
+ val >>= 7
3732
+ # This drops the top bits,
3733
+ # Otherwise, with a signed right shift,
3734
+ # we get infinity one bits at the top
3735
+ val &= (1 << 57) - 1
3417
3736
 
3418
- ## END PULL_BYTES
3737
+ byte |= 0x80 if val != 0
3738
+ unknown_bytes << byte
3739
+ break if val == 0
3740
+ end
3741
+
3742
+ unknown_bytes << buff.byteslice(index, value)
3743
+ index += value
3419
3744
  when 5
3745
+ unknown_bytes << buff.byteslice(index, 4)
3420
3746
  index += 4
3421
3747
  else
3422
3748
  raise "unknown wire type #{wire_type}"
3423
3749
  end
3750
+ (@_unknown_fields ||= +"".b) << unknown_bytes
3424
3751
  return self if index >= len
3425
3752
  ## PULL_UINT64
3426
3753
  tag =
@@ -3887,39 +4214,63 @@ module Api
3887
4214
  end
3888
4215
 
3889
4216
  val = @unit_tag
3890
- if val != 0
4217
+ if has_unit_tag?
3891
4218
  buff << 0x10
3892
4219
 
3893
- while val != 0
4220
+ loop do
3894
4221
  byte = val & 0x7F
3895
4222
  val >>= 7
3896
4223
  byte |= 0x80 if val > 0
3897
4224
  buff << byte
4225
+ break if val == 0
3898
4226
  end
3899
4227
  end
3900
4228
 
3901
4229
  val = @unit_type_id
3902
- if val != 0
4230
+ if has_unit_type_id?
3903
4231
  buff << 0x18
3904
4232
 
3905
- while val != 0
4233
+ loop do
3906
4234
  byte = val & 0x7F
3907
4235
  val >>= 7
3908
4236
  byte |= 0x80 if val > 0
3909
4237
  buff << byte
4238
+ break if val == 0
3910
4239
  end
3911
4240
  end
3912
-
4241
+ buff << @_unknown_fields if @_unknown_fields
3913
4242
  buff
3914
4243
  end
3915
4244
 
3916
4245
  def to_h
3917
4246
  result = {}
3918
- result["abilities".to_sym] = @abilities
3919
- result["unit_tag".to_sym] = @unit_tag
3920
- result["unit_type_id".to_sym] = @unit_type_id
4247
+
4248
+ result[:"abilities"] = @abilities.map(&:to_h)
4249
+ result[:"unit_tag"] = @unit_tag
4250
+ result[:"unit_type_id"] = @unit_type_id
4251
+
4252
+ result
4253
+ end
4254
+
4255
+ def as_json(options = {})
4256
+ result = {}
4257
+
4258
+ tmp_abilities = @abilities.map { |v| v.as_json(options) }
4259
+
4260
+ result["abilities"] = tmp_abilities if !options[:compact] ||
4261
+ tmp_abilities.any?
4262
+
4263
+ result["unitTag"] = @unit_tag if !options[:compact] || has_unit_tag?
4264
+ result["unitTypeId"] = @unit_type_id if !options[:compact] ||
4265
+ has_unit_type_id?
4266
+
3921
4267
  result
3922
4268
  end
4269
+
4270
+ def to_json(as_json_options = {})
4271
+ require "json"
4272
+ JSON.dump(as_json(as_json_options))
4273
+ end
3923
4274
  end
3924
4275
  class RequestQueryBuildingPlacement
3925
4276
  def self.decode(buff)
@@ -4083,20 +4434,39 @@ module Api
4083
4434
  # unexpected, so discard it and continue.
4084
4435
  if !found
4085
4436
  wire_type = tag & 0x7
4437
+
4438
+ unknown_bytes = +"".b
4439
+ val = tag
4440
+ loop do
4441
+ byte = val & 0x7F
4442
+
4443
+ val >>= 7
4444
+ # This drops the top bits,
4445
+ # Otherwise, with a signed right shift,
4446
+ # we get infinity one bits at the top
4447
+ val &= (1 << 57) - 1
4448
+
4449
+ byte |= 0x80 if val != 0
4450
+ unknown_bytes << byte
4451
+ break if val == 0
4452
+ end
4453
+
4086
4454
  case wire_type
4087
4455
  when 0
4088
4456
  i = 0
4089
4457
  while true
4090
4458
  newbyte = buff.getbyte(index)
4091
4459
  index += 1
4092
- break if newbyte.nil? || newbyte < 0x80
4460
+ break if newbyte.nil?
4461
+ unknown_bytes << newbyte
4462
+ break if newbyte < 0x80
4093
4463
  i += 1
4094
4464
  break if i > 9
4095
4465
  end
4096
4466
  when 1
4467
+ unknown_bytes << buff.byteslice(index, 8)
4097
4468
  index += 8
4098
4469
  when 2
4099
- ## PULL_BYTES
4100
4470
  value =
4101
4471
  if (byte0 = buff.getbyte(index)) < 0x80
4102
4472
  index += 1
@@ -4152,15 +4522,30 @@ module Api
4152
4522
  raise "integer decoding error"
4153
4523
  end
4154
4524
 
4155
- buff.byteslice(index, value)
4156
- index += value
4525
+ val = value
4526
+ loop do
4527
+ byte = val & 0x7F
4157
4528
 
4158
- ## END PULL_BYTES
4529
+ val >>= 7
4530
+ # This drops the top bits,
4531
+ # Otherwise, with a signed right shift,
4532
+ # we get infinity one bits at the top
4533
+ val &= (1 << 57) - 1
4534
+
4535
+ byte |= 0x80 if val != 0
4536
+ unknown_bytes << byte
4537
+ break if val == 0
4538
+ end
4539
+
4540
+ unknown_bytes << buff.byteslice(index, value)
4541
+ index += value
4159
4542
  when 5
4543
+ unknown_bytes << buff.byteslice(index, 4)
4160
4544
  index += 4
4161
4545
  else
4162
4546
  raise "unknown wire type #{wire_type}"
4163
4547
  end
4548
+ (@_unknown_fields ||= +"".b) << unknown_bytes
4164
4549
  return self if index >= len
4165
4550
  ## PULL_UINT64
4166
4551
  tag =
@@ -4563,10 +4948,10 @@ module Api
4563
4948
  end
4564
4949
  def _encode(buff)
4565
4950
  val = @ability_id
4566
- if val != 0
4951
+ if has_ability_id?
4567
4952
  buff << 0x08
4568
4953
 
4569
- while val != 0
4954
+ loop do
4570
4955
  byte = val & 0x7F
4571
4956
 
4572
4957
  val >>= 7
@@ -4577,6 +4962,7 @@ module Api
4577
4962
 
4578
4963
  byte |= 0x80 if val != 0
4579
4964
  buff << byte
4965
+ break if val == 0
4580
4966
  end
4581
4967
  end
4582
4968
 
@@ -4629,27 +5015,52 @@ module Api
4629
5015
  end
4630
5016
 
4631
5017
  val = @placing_unit_tag
4632
- if val != 0
5018
+ if has_placing_unit_tag?
4633
5019
  buff << 0x18
4634
5020
 
4635
- while val != 0
5021
+ loop do
4636
5022
  byte = val & 0x7F
4637
5023
  val >>= 7
4638
5024
  byte |= 0x80 if val > 0
4639
5025
  buff << byte
5026
+ break if val == 0
4640
5027
  end
4641
5028
  end
4642
-
5029
+ buff << @_unknown_fields if @_unknown_fields
4643
5030
  buff
4644
5031
  end
4645
5032
 
4646
5033
  def to_h
4647
5034
  result = {}
4648
- result["ability_id".to_sym] = @ability_id
4649
- result["target_pos".to_sym] = @target_pos.to_h
4650
- result["placing_unit_tag".to_sym] = @placing_unit_tag
5035
+
5036
+ result[:"ability_id"] = @ability_id
5037
+ result[:"target_pos"] = @target_pos.to_h
5038
+ result[:"placing_unit_tag"] = @placing_unit_tag
5039
+
5040
+ result
5041
+ end
5042
+
5043
+ def as_json(options = {})
5044
+ result = {}
5045
+
5046
+ result["abilityId"] = @ability_id if !options[:compact] || has_ability_id?
5047
+ result["targetPos"] = (
5048
+ if @target_pos.nil?
5049
+ {}
5050
+ else
5051
+ @target_pos.as_json(options)
5052
+ end
5053
+ ) if !options[:compact] || has_target_pos?
5054
+ result["placingUnitTag"] = @placing_unit_tag if !options[:compact] ||
5055
+ has_placing_unit_tag?
5056
+
4651
5057
  result
4652
5058
  end
5059
+
5060
+ def to_json(as_json_options = {})
5061
+ require "json"
5062
+ JSON.dump(as_json(as_json_options))
5063
+ end
4653
5064
  end
4654
5065
  class ResponseQueryBuildingPlacement
4655
5066
  def self.decode(buff)
@@ -4668,9 +5079,12 @@ module Api
4668
5079
  # enum writers
4669
5080
  def result=(v)
4670
5081
  @result = Api::ActionResult.resolve(v) || v
5082
+ @_bitmask |= 0x0000000000000001
4671
5083
  end
4672
5084
 
4673
5085
  def initialize(result: nil)
5086
+ @_bitmask = 0
5087
+
4674
5088
  if result == nil
4675
5089
  @result = 0
4676
5090
  else
@@ -4683,7 +5097,13 @@ module Api
4683
5097
  self.class.encode(self)
4684
5098
  end
4685
5099
 
5100
+ def has_result?
5101
+ (@_bitmask & 0x0000000000000001) == 0x0000000000000001
5102
+ end
5103
+
4686
5104
  def decode_from(buff, index, len)
5105
+ @_bitmask = 0
5106
+
4687
5107
  @result = 0
4688
5108
 
4689
5109
  return self if index >= len
@@ -4745,20 +5165,39 @@ module Api
4745
5165
  # unexpected, so discard it and continue.
4746
5166
  if !found
4747
5167
  wire_type = tag & 0x7
5168
+
5169
+ unknown_bytes = +"".b
5170
+ val = tag
5171
+ loop do
5172
+ byte = val & 0x7F
5173
+
5174
+ val >>= 7
5175
+ # This drops the top bits,
5176
+ # Otherwise, with a signed right shift,
5177
+ # we get infinity one bits at the top
5178
+ val &= (1 << 57) - 1
5179
+
5180
+ byte |= 0x80 if val != 0
5181
+ unknown_bytes << byte
5182
+ break if val == 0
5183
+ end
5184
+
4748
5185
  case wire_type
4749
5186
  when 0
4750
5187
  i = 0
4751
5188
  while true
4752
5189
  newbyte = buff.getbyte(index)
4753
5190
  index += 1
4754
- break if newbyte.nil? || newbyte < 0x80
5191
+ break if newbyte.nil?
5192
+ unknown_bytes << newbyte
5193
+ break if newbyte < 0x80
4755
5194
  i += 1
4756
5195
  break if i > 9
4757
5196
  end
4758
5197
  when 1
5198
+ unknown_bytes << buff.byteslice(index, 8)
4759
5199
  index += 8
4760
5200
  when 2
4761
- ## PULL_BYTES
4762
5201
  value =
4763
5202
  if (byte0 = buff.getbyte(index)) < 0x80
4764
5203
  index += 1
@@ -4814,15 +5253,30 @@ module Api
4814
5253
  raise "integer decoding error"
4815
5254
  end
4816
5255
 
4817
- buff.byteslice(index, value)
4818
- index += value
5256
+ val = value
5257
+ loop do
5258
+ byte = val & 0x7F
5259
+
5260
+ val >>= 7
5261
+ # This drops the top bits,
5262
+ # Otherwise, with a signed right shift,
5263
+ # we get infinity one bits at the top
5264
+ val &= (1 << 57) - 1
4819
5265
 
4820
- ## END PULL_BYTES
5266
+ byte |= 0x80 if val != 0
5267
+ unknown_bytes << byte
5268
+ break if val == 0
5269
+ end
5270
+
5271
+ unknown_bytes << buff.byteslice(index, value)
5272
+ index += value
4821
5273
  when 5
5274
+ unknown_bytes << buff.byteslice(index, 4)
4822
5275
  index += 4
4823
5276
  else
4824
5277
  raise "unknown wire type #{wire_type}"
4825
5278
  end
5279
+ (@_unknown_fields ||= +"".b) << unknown_bytes
4826
5280
  return self if index >= len
4827
5281
  ## PULL_UINT64
4828
5282
  tag =
@@ -5004,10 +5458,10 @@ module Api
5004
5458
  end
5005
5459
  def _encode(buff)
5006
5460
  val = @result
5007
- if val != 0
5461
+ if has_result?
5008
5462
  buff << 0x08
5009
5463
 
5010
- while val != 0
5464
+ loop do
5011
5465
  byte = val & 0x7F
5012
5466
 
5013
5467
  val >>= 7
@@ -5018,16 +5472,32 @@ module Api
5018
5472
 
5019
5473
  byte |= 0x80 if val != 0
5020
5474
  buff << byte
5475
+ break if val == 0
5021
5476
  end
5022
5477
  end
5023
-
5478
+ buff << @_unknown_fields if @_unknown_fields
5024
5479
  buff
5025
5480
  end
5026
5481
 
5027
5482
  def to_h
5028
5483
  result = {}
5029
- result["result".to_sym] = @result
5484
+
5485
+ result[:"result"] = @result
5486
+
5487
+ result
5488
+ end
5489
+
5490
+ def as_json(options = {})
5491
+ result = {}
5492
+
5493
+ result["result"] = @result if !options[:compact] || has_result?
5494
+
5030
5495
  result
5031
5496
  end
5497
+
5498
+ def to_json(as_json_options = {})
5499
+ require "json"
5500
+ JSON.dump(as_json(as_json_options))
5501
+ end
5032
5502
  end
5033
5503
  end