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.
- checksums.yaml +4 -4
- data/data/sc2ai/protocol/data.proto +2 -2
- data/data/sc2ai/protocol/debug.proto +1 -1
- data/data/sc2ai/protocol/raw.proto +6 -6
- data/data/sc2ai/protocol/sc2api.proto +1 -1
- data/data/sc2ai/protocol/ui.proto +1 -1
- data/{lib/docker_build → docker_build}/Dockerfile.ruby +2 -2
- data/lib/sc2ai/cli/ladderzip.rb +1 -1
- data/lib/sc2ai/local_play/client.rb +1 -1
- data/lib/sc2ai/local_play/match.rb +1 -0
- data/lib/sc2ai/overrides/async/process/child.rb +2 -1
- data/lib/sc2ai/paths.rb +0 -1
- data/lib/sc2ai/player/debug.rb +3 -3
- data/lib/sc2ai/player.rb +9 -0
- data/lib/sc2ai/protocol/common_pb.rb +460 -105
- data/lib/sc2ai/protocol/data_pb.rb +833 -482
- data/lib/sc2ai/protocol/debug_pb.rb +1112 -401
- data/lib/sc2ai/protocol/error_pb.rb +430 -862
- data/lib/sc2ai/protocol/extensions/action.rb +1 -1
- data/lib/sc2ai/protocol/extensions/color.rb +1 -1
- data/lib/sc2ai/protocol/extensions/point.rb +1 -1
- data/lib/sc2ai/protocol/extensions/point_2_d.rb +1 -1
- data/lib/sc2ai/protocol/extensions/point_distance.rb +4 -4
- data/lib/sc2ai/protocol/extensions/position.rb +20 -0
- data/lib/sc2ai/protocol/extensions/power_source.rb +1 -1
- data/lib/sc2ai/protocol/extensions/unit.rb +1 -1
- data/lib/sc2ai/protocol/extensions/unit_type_data.rb +1 -1
- data/lib/sc2ai/protocol/query_pb.rb +558 -88
- data/lib/sc2ai/protocol/raw_pb.rb +1829 -1156
- data/lib/sc2ai/protocol/sc2api_pb.rb +5233 -1463
- data/lib/sc2ai/protocol/score_pb.rb +444 -103
- data/lib/sc2ai/protocol/spatial_pb.rb +935 -145
- data/lib/sc2ai/protocol/ui_pb.rb +1432 -435
- data/lib/sc2ai/version.rb +1 -1
- data/lib/templates/new/api/data.proto +2 -2
- data/lib/templates/new/api/debug.proto +1 -1
- data/lib/templates/new/api/raw.proto +6 -6
- data/lib/templates/new/api/sc2api.proto +1 -1
- data/lib/templates/new/api/ui.proto +1 -1
- data/lib/templates/new/run_example_match.rb.tt +1 -1
- data/sig/sc2ai.rbs +1361 -23
- metadata +7 -7
- /data/{lib/docker_build → docker_build}/docker-compose-base-image.yml +0 -0
- /data/{lib/docker_build → docker_build}/docker-compose-ladderzip.yml +0 -0
@@ -17,23 +17,15 @@ module Api
|
|
17
17
|
MELEE = 2
|
18
18
|
|
19
19
|
def self.lookup(val)
|
20
|
-
if val == 0
|
21
|
-
|
22
|
-
|
23
|
-
:CURRICULUM
|
24
|
-
elsif val == 2
|
25
|
-
:MELEE
|
26
|
-
end
|
20
|
+
return :ENUM_SCORE_TYPE_UNSET if val == 0
|
21
|
+
return :CURRICULUM if val == 1
|
22
|
+
return :MELEE if val == 2
|
27
23
|
end
|
28
24
|
|
29
25
|
def self.resolve(val)
|
30
|
-
if val == :ENUM_SCORE_TYPE_UNSET
|
31
|
-
|
32
|
-
|
33
|
-
1
|
34
|
-
elsif val == :MELEE
|
35
|
-
2
|
36
|
-
end
|
26
|
+
return 0 if val == :ENUM_SCORE_TYPE_UNSET
|
27
|
+
return 1 if val == :CURRICULUM
|
28
|
+
return 2 if val == :MELEE
|
37
29
|
end
|
38
30
|
end
|
39
31
|
# required field readers
|
@@ -51,6 +43,7 @@ module Api
|
|
51
43
|
# enum writers
|
52
44
|
def score_type=(v)
|
53
45
|
@score_type = Api::Score::ScoreType.resolve(v) || v
|
46
|
+
@_bitmask |= 0x0000000000000001
|
54
47
|
end
|
55
48
|
|
56
49
|
# BEGIN writers for optional fields
|
@@ -104,6 +97,10 @@ module Api
|
|
104
97
|
self.class.encode(self)
|
105
98
|
end
|
106
99
|
|
100
|
+
def has_score_type?
|
101
|
+
(@_bitmask & 0x0000000000000001) == 0x0000000000000001
|
102
|
+
end
|
103
|
+
|
107
104
|
def has_score?
|
108
105
|
(@_bitmask & 0x0000000000000002) == 0x0000000000000002
|
109
106
|
end
|
@@ -178,20 +175,39 @@ module Api
|
|
178
175
|
# unexpected, so discard it and continue.
|
179
176
|
if !found
|
180
177
|
wire_type = tag & 0x7
|
178
|
+
|
179
|
+
unknown_bytes = +"".b
|
180
|
+
val = tag
|
181
|
+
loop do
|
182
|
+
byte = val & 0x7F
|
183
|
+
|
184
|
+
val >>= 7
|
185
|
+
# This drops the top bits,
|
186
|
+
# Otherwise, with a signed right shift,
|
187
|
+
# we get infinity one bits at the top
|
188
|
+
val &= (1 << 57) - 1
|
189
|
+
|
190
|
+
byte |= 0x80 if val != 0
|
191
|
+
unknown_bytes << byte
|
192
|
+
break if val == 0
|
193
|
+
end
|
194
|
+
|
181
195
|
case wire_type
|
182
196
|
when 0
|
183
197
|
i = 0
|
184
198
|
while true
|
185
199
|
newbyte = buff.getbyte(index)
|
186
200
|
index += 1
|
187
|
-
break if newbyte.nil?
|
201
|
+
break if newbyte.nil?
|
202
|
+
unknown_bytes << newbyte
|
203
|
+
break if newbyte < 0x80
|
188
204
|
i += 1
|
189
205
|
break if i > 9
|
190
206
|
end
|
191
207
|
when 1
|
208
|
+
unknown_bytes << buff.byteslice(index, 8)
|
192
209
|
index += 8
|
193
210
|
when 2
|
194
|
-
## PULL_BYTES
|
195
211
|
value =
|
196
212
|
if (byte0 = buff.getbyte(index)) < 0x80
|
197
213
|
index += 1
|
@@ -247,15 +263,30 @@ module Api
|
|
247
263
|
raise "integer decoding error"
|
248
264
|
end
|
249
265
|
|
250
|
-
|
251
|
-
|
266
|
+
val = value
|
267
|
+
loop do
|
268
|
+
byte = val & 0x7F
|
269
|
+
|
270
|
+
val >>= 7
|
271
|
+
# This drops the top bits,
|
272
|
+
# Otherwise, with a signed right shift,
|
273
|
+
# we get infinity one bits at the top
|
274
|
+
val &= (1 << 57) - 1
|
275
|
+
|
276
|
+
byte |= 0x80 if val != 0
|
277
|
+
unknown_bytes << byte
|
278
|
+
break if val == 0
|
279
|
+
end
|
252
280
|
|
253
|
-
|
281
|
+
unknown_bytes << buff.byteslice(index, value)
|
282
|
+
index += value
|
254
283
|
when 5
|
284
|
+
unknown_bytes << buff.byteslice(index, 4)
|
255
285
|
index += 4
|
256
286
|
else
|
257
287
|
raise "unknown wire type #{wire_type}"
|
258
288
|
end
|
289
|
+
(@_unknown_fields ||= +"".b) << unknown_bytes
|
259
290
|
return self if index >= len
|
260
291
|
## PULL_UINT64
|
261
292
|
tag =
|
@@ -674,10 +705,10 @@ module Api
|
|
674
705
|
end
|
675
706
|
def _encode(buff)
|
676
707
|
val = @score_type
|
677
|
-
if
|
708
|
+
if has_score_type?
|
678
709
|
buff << 0x30
|
679
710
|
|
680
|
-
|
711
|
+
loop do
|
681
712
|
byte = val & 0x7F
|
682
713
|
|
683
714
|
val >>= 7
|
@@ -688,14 +719,15 @@ module Api
|
|
688
719
|
|
689
720
|
byte |= 0x80 if val != 0
|
690
721
|
buff << byte
|
722
|
+
break if val == 0
|
691
723
|
end
|
692
724
|
end
|
693
725
|
|
694
726
|
val = @score
|
695
|
-
if
|
727
|
+
if has_score?
|
696
728
|
buff << 0x38
|
697
729
|
|
698
|
-
|
730
|
+
loop do
|
699
731
|
byte = val & 0x7F
|
700
732
|
|
701
733
|
val >>= 7
|
@@ -706,6 +738,7 @@ module Api
|
|
706
738
|
|
707
739
|
byte |= 0x80 if val != 0
|
708
740
|
buff << byte
|
741
|
+
break if val == 0
|
709
742
|
end
|
710
743
|
end
|
711
744
|
|
@@ -756,17 +789,40 @@ module Api
|
|
756
789
|
|
757
790
|
buff
|
758
791
|
end
|
759
|
-
|
792
|
+
buff << @_unknown_fields if @_unknown_fields
|
760
793
|
buff
|
761
794
|
end
|
762
795
|
|
763
796
|
def to_h
|
764
797
|
result = {}
|
765
|
-
|
766
|
-
result["
|
767
|
-
result["
|
798
|
+
|
799
|
+
result[:"score_type"] = @score_type
|
800
|
+
result[:"score"] = @score
|
801
|
+
result[:"score_details"] = @score_details.to_h
|
802
|
+
|
768
803
|
result
|
769
804
|
end
|
805
|
+
|
806
|
+
def as_json(options = {})
|
807
|
+
result = {}
|
808
|
+
|
809
|
+
result["scoreType"] = @score_type if !options[:compact] || has_score_type?
|
810
|
+
result["score"] = @score if !options[:compact] || has_score?
|
811
|
+
result["scoreDetails"] = (
|
812
|
+
if @score_details.nil?
|
813
|
+
{}
|
814
|
+
else
|
815
|
+
@score_details.as_json(options)
|
816
|
+
end
|
817
|
+
) if !options[:compact] || has_score_details?
|
818
|
+
|
819
|
+
result
|
820
|
+
end
|
821
|
+
|
822
|
+
def to_json(as_json_options = {})
|
823
|
+
require "json"
|
824
|
+
JSON.dump(as_json(as_json_options))
|
825
|
+
end
|
770
826
|
end
|
771
827
|
class CategoryScoreDetails
|
772
828
|
def self.decode(buff)
|
@@ -955,20 +1011,39 @@ module Api
|
|
955
1011
|
# unexpected, so discard it and continue.
|
956
1012
|
if !found
|
957
1013
|
wire_type = tag & 0x7
|
1014
|
+
|
1015
|
+
unknown_bytes = +"".b
|
1016
|
+
val = tag
|
1017
|
+
loop do
|
1018
|
+
byte = val & 0x7F
|
1019
|
+
|
1020
|
+
val >>= 7
|
1021
|
+
# This drops the top bits,
|
1022
|
+
# Otherwise, with a signed right shift,
|
1023
|
+
# we get infinity one bits at the top
|
1024
|
+
val &= (1 << 57) - 1
|
1025
|
+
|
1026
|
+
byte |= 0x80 if val != 0
|
1027
|
+
unknown_bytes << byte
|
1028
|
+
break if val == 0
|
1029
|
+
end
|
1030
|
+
|
958
1031
|
case wire_type
|
959
1032
|
when 0
|
960
1033
|
i = 0
|
961
1034
|
while true
|
962
1035
|
newbyte = buff.getbyte(index)
|
963
1036
|
index += 1
|
964
|
-
break if newbyte.nil?
|
1037
|
+
break if newbyte.nil?
|
1038
|
+
unknown_bytes << newbyte
|
1039
|
+
break if newbyte < 0x80
|
965
1040
|
i += 1
|
966
1041
|
break if i > 9
|
967
1042
|
end
|
968
1043
|
when 1
|
1044
|
+
unknown_bytes << buff.byteslice(index, 8)
|
969
1045
|
index += 8
|
970
1046
|
when 2
|
971
|
-
## PULL_BYTES
|
972
1047
|
value =
|
973
1048
|
if (byte0 = buff.getbyte(index)) < 0x80
|
974
1049
|
index += 1
|
@@ -1024,15 +1099,30 @@ module Api
|
|
1024
1099
|
raise "integer decoding error"
|
1025
1100
|
end
|
1026
1101
|
|
1027
|
-
|
1028
|
-
|
1102
|
+
val = value
|
1103
|
+
loop do
|
1104
|
+
byte = val & 0x7F
|
1105
|
+
|
1106
|
+
val >>= 7
|
1107
|
+
# This drops the top bits,
|
1108
|
+
# Otherwise, with a signed right shift,
|
1109
|
+
# we get infinity one bits at the top
|
1110
|
+
val &= (1 << 57) - 1
|
1111
|
+
|
1112
|
+
byte |= 0x80 if val != 0
|
1113
|
+
unknown_bytes << byte
|
1114
|
+
break if val == 0
|
1115
|
+
end
|
1029
1116
|
|
1030
|
-
|
1117
|
+
unknown_bytes << buff.byteslice(index, value)
|
1118
|
+
index += value
|
1031
1119
|
when 5
|
1120
|
+
unknown_bytes << buff.byteslice(index, 4)
|
1032
1121
|
index += 4
|
1033
1122
|
else
|
1034
1123
|
raise "unknown wire type #{wire_type}"
|
1035
1124
|
end
|
1125
|
+
(@_unknown_fields ||= +"".b) << unknown_bytes
|
1036
1126
|
return self if index >= len
|
1037
1127
|
## PULL_UINT64
|
1038
1128
|
tag =
|
@@ -1384,52 +1474,72 @@ module Api
|
|
1384
1474
|
end
|
1385
1475
|
def _encode(buff)
|
1386
1476
|
val = @none
|
1387
|
-
if
|
1477
|
+
if has_none?
|
1388
1478
|
buff << 0x0d
|
1389
1479
|
|
1390
1480
|
[val].pack("e", buffer: buff)
|
1391
1481
|
end
|
1392
1482
|
|
1393
1483
|
val = @army
|
1394
|
-
if
|
1484
|
+
if has_army?
|
1395
1485
|
buff << 0x15
|
1396
1486
|
|
1397
1487
|
[val].pack("e", buffer: buff)
|
1398
1488
|
end
|
1399
1489
|
|
1400
1490
|
val = @economy
|
1401
|
-
if
|
1491
|
+
if has_economy?
|
1402
1492
|
buff << 0x1d
|
1403
1493
|
|
1404
1494
|
[val].pack("e", buffer: buff)
|
1405
1495
|
end
|
1406
1496
|
|
1407
1497
|
val = @technology
|
1408
|
-
if
|
1498
|
+
if has_technology?
|
1409
1499
|
buff << 0x25
|
1410
1500
|
|
1411
1501
|
[val].pack("e", buffer: buff)
|
1412
1502
|
end
|
1413
1503
|
|
1414
1504
|
val = @upgrade
|
1415
|
-
if
|
1505
|
+
if has_upgrade?
|
1416
1506
|
buff << 0x2d
|
1417
1507
|
|
1418
1508
|
[val].pack("e", buffer: buff)
|
1419
1509
|
end
|
1420
|
-
|
1510
|
+
buff << @_unknown_fields if @_unknown_fields
|
1421
1511
|
buff
|
1422
1512
|
end
|
1423
1513
|
|
1424
1514
|
def to_h
|
1425
1515
|
result = {}
|
1426
|
-
|
1427
|
-
result["
|
1428
|
-
result["
|
1429
|
-
result["
|
1430
|
-
result["
|
1516
|
+
|
1517
|
+
result[:"none"] = @none
|
1518
|
+
result[:"army"] = @army
|
1519
|
+
result[:"economy"] = @economy
|
1520
|
+
result[:"technology"] = @technology
|
1521
|
+
result[:"upgrade"] = @upgrade
|
1522
|
+
|
1523
|
+
result
|
1524
|
+
end
|
1525
|
+
|
1526
|
+
def as_json(options = {})
|
1527
|
+
result = {}
|
1528
|
+
|
1529
|
+
result["none"] = @none if !options[:compact] || has_none?
|
1530
|
+
result["army"] = @army if !options[:compact] || has_army?
|
1531
|
+
result["economy"] = @economy if !options[:compact] || has_economy?
|
1532
|
+
result["technology"] = @technology if !options[:compact] ||
|
1533
|
+
has_technology?
|
1534
|
+
result["upgrade"] = @upgrade if !options[:compact] || has_upgrade?
|
1535
|
+
|
1431
1536
|
result
|
1432
1537
|
end
|
1538
|
+
|
1539
|
+
def to_json(as_json_options = {})
|
1540
|
+
require "json"
|
1541
|
+
JSON.dump(as_json(as_json_options))
|
1542
|
+
end
|
1433
1543
|
end
|
1434
1544
|
class VitalScoreDetails
|
1435
1545
|
def self.decode(buff)
|
@@ -1574,20 +1684,39 @@ module Api
|
|
1574
1684
|
# unexpected, so discard it and continue.
|
1575
1685
|
if !found
|
1576
1686
|
wire_type = tag & 0x7
|
1687
|
+
|
1688
|
+
unknown_bytes = +"".b
|
1689
|
+
val = tag
|
1690
|
+
loop do
|
1691
|
+
byte = val & 0x7F
|
1692
|
+
|
1693
|
+
val >>= 7
|
1694
|
+
# This drops the top bits,
|
1695
|
+
# Otherwise, with a signed right shift,
|
1696
|
+
# we get infinity one bits at the top
|
1697
|
+
val &= (1 << 57) - 1
|
1698
|
+
|
1699
|
+
byte |= 0x80 if val != 0
|
1700
|
+
unknown_bytes << byte
|
1701
|
+
break if val == 0
|
1702
|
+
end
|
1703
|
+
|
1577
1704
|
case wire_type
|
1578
1705
|
when 0
|
1579
1706
|
i = 0
|
1580
1707
|
while true
|
1581
1708
|
newbyte = buff.getbyte(index)
|
1582
1709
|
index += 1
|
1583
|
-
break if newbyte.nil?
|
1710
|
+
break if newbyte.nil?
|
1711
|
+
unknown_bytes << newbyte
|
1712
|
+
break if newbyte < 0x80
|
1584
1713
|
i += 1
|
1585
1714
|
break if i > 9
|
1586
1715
|
end
|
1587
1716
|
when 1
|
1717
|
+
unknown_bytes << buff.byteslice(index, 8)
|
1588
1718
|
index += 8
|
1589
1719
|
when 2
|
1590
|
-
## PULL_BYTES
|
1591
1720
|
value =
|
1592
1721
|
if (byte0 = buff.getbyte(index)) < 0x80
|
1593
1722
|
index += 1
|
@@ -1643,15 +1772,30 @@ module Api
|
|
1643
1772
|
raise "integer decoding error"
|
1644
1773
|
end
|
1645
1774
|
|
1646
|
-
|
1647
|
-
|
1775
|
+
val = value
|
1776
|
+
loop do
|
1777
|
+
byte = val & 0x7F
|
1778
|
+
|
1779
|
+
val >>= 7
|
1780
|
+
# This drops the top bits,
|
1781
|
+
# Otherwise, with a signed right shift,
|
1782
|
+
# we get infinity one bits at the top
|
1783
|
+
val &= (1 << 57) - 1
|
1648
1784
|
|
1649
|
-
|
1785
|
+
byte |= 0x80 if val != 0
|
1786
|
+
unknown_bytes << byte
|
1787
|
+
break if val == 0
|
1788
|
+
end
|
1789
|
+
|
1790
|
+
unknown_bytes << buff.byteslice(index, value)
|
1791
|
+
index += value
|
1650
1792
|
when 5
|
1793
|
+
unknown_bytes << buff.byteslice(index, 4)
|
1651
1794
|
index += 4
|
1652
1795
|
else
|
1653
1796
|
raise "unknown wire type #{wire_type}"
|
1654
1797
|
end
|
1798
|
+
(@_unknown_fields ||= +"".b) << unknown_bytes
|
1655
1799
|
return self if index >= len
|
1656
1800
|
## PULL_UINT64
|
1657
1801
|
tag =
|
@@ -1887,36 +2031,53 @@ module Api
|
|
1887
2031
|
end
|
1888
2032
|
def _encode(buff)
|
1889
2033
|
val = @life
|
1890
|
-
if
|
2034
|
+
if has_life?
|
1891
2035
|
buff << 0x0d
|
1892
2036
|
|
1893
2037
|
[val].pack("e", buffer: buff)
|
1894
2038
|
end
|
1895
2039
|
|
1896
2040
|
val = @shields
|
1897
|
-
if
|
2041
|
+
if has_shields?
|
1898
2042
|
buff << 0x15
|
1899
2043
|
|
1900
2044
|
[val].pack("e", buffer: buff)
|
1901
2045
|
end
|
1902
2046
|
|
1903
2047
|
val = @energy
|
1904
|
-
if
|
2048
|
+
if has_energy?
|
1905
2049
|
buff << 0x1d
|
1906
2050
|
|
1907
2051
|
[val].pack("e", buffer: buff)
|
1908
2052
|
end
|
1909
|
-
|
2053
|
+
buff << @_unknown_fields if @_unknown_fields
|
1910
2054
|
buff
|
1911
2055
|
end
|
1912
2056
|
|
1913
2057
|
def to_h
|
1914
2058
|
result = {}
|
1915
|
-
|
1916
|
-
result["
|
1917
|
-
result["
|
2059
|
+
|
2060
|
+
result[:"life"] = @life
|
2061
|
+
result[:"shields"] = @shields
|
2062
|
+
result[:"energy"] = @energy
|
2063
|
+
|
1918
2064
|
result
|
1919
2065
|
end
|
2066
|
+
|
2067
|
+
def as_json(options = {})
|
2068
|
+
result = {}
|
2069
|
+
|
2070
|
+
result["life"] = @life if !options[:compact] || has_life?
|
2071
|
+
result["shields"] = @shields if !options[:compact] || has_shields?
|
2072
|
+
result["energy"] = @energy if !options[:compact] || has_energy?
|
2073
|
+
|
2074
|
+
result
|
2075
|
+
end
|
2076
|
+
|
2077
|
+
def to_json(as_json_options = {})
|
2078
|
+
require "json"
|
2079
|
+
JSON.dump(as_json(as_json_options))
|
2080
|
+
end
|
1920
2081
|
end
|
1921
2082
|
class ScoreDetails
|
1922
2083
|
def self.decode(buff)
|
@@ -2565,20 +2726,39 @@ module Api
|
|
2565
2726
|
# unexpected, so discard it and continue.
|
2566
2727
|
if !found
|
2567
2728
|
wire_type = tag & 0x7
|
2729
|
+
|
2730
|
+
unknown_bytes = +"".b
|
2731
|
+
val = tag
|
2732
|
+
loop do
|
2733
|
+
byte = val & 0x7F
|
2734
|
+
|
2735
|
+
val >>= 7
|
2736
|
+
# This drops the top bits,
|
2737
|
+
# Otherwise, with a signed right shift,
|
2738
|
+
# we get infinity one bits at the top
|
2739
|
+
val &= (1 << 57) - 1
|
2740
|
+
|
2741
|
+
byte |= 0x80 if val != 0
|
2742
|
+
unknown_bytes << byte
|
2743
|
+
break if val == 0
|
2744
|
+
end
|
2745
|
+
|
2568
2746
|
case wire_type
|
2569
2747
|
when 0
|
2570
2748
|
i = 0
|
2571
2749
|
while true
|
2572
2750
|
newbyte = buff.getbyte(index)
|
2573
2751
|
index += 1
|
2574
|
-
break if newbyte.nil?
|
2752
|
+
break if newbyte.nil?
|
2753
|
+
unknown_bytes << newbyte
|
2754
|
+
break if newbyte < 0x80
|
2575
2755
|
i += 1
|
2576
2756
|
break if i > 9
|
2577
2757
|
end
|
2578
2758
|
when 1
|
2759
|
+
unknown_bytes << buff.byteslice(index, 8)
|
2579
2760
|
index += 8
|
2580
2761
|
when 2
|
2581
|
-
## PULL_BYTES
|
2582
2762
|
value =
|
2583
2763
|
if (byte0 = buff.getbyte(index)) < 0x80
|
2584
2764
|
index += 1
|
@@ -2634,15 +2814,30 @@ module Api
|
|
2634
2814
|
raise "integer decoding error"
|
2635
2815
|
end
|
2636
2816
|
|
2637
|
-
|
2638
|
-
|
2817
|
+
val = value
|
2818
|
+
loop do
|
2819
|
+
byte = val & 0x7F
|
2820
|
+
|
2821
|
+
val >>= 7
|
2822
|
+
# This drops the top bits,
|
2823
|
+
# Otherwise, with a signed right shift,
|
2824
|
+
# we get infinity one bits at the top
|
2825
|
+
val &= (1 << 57) - 1
|
2826
|
+
|
2827
|
+
byte |= 0x80 if val != 0
|
2828
|
+
unknown_bytes << byte
|
2829
|
+
break if val == 0
|
2830
|
+
end
|
2639
2831
|
|
2640
|
-
|
2832
|
+
unknown_bytes << buff.byteslice(index, value)
|
2833
|
+
index += value
|
2641
2834
|
when 5
|
2835
|
+
unknown_bytes << buff.byteslice(index, 4)
|
2642
2836
|
index += 4
|
2643
2837
|
else
|
2644
2838
|
raise "unknown wire type #{wire_type}"
|
2645
2839
|
end
|
2840
|
+
(@_unknown_fields ||= +"".b) << unknown_bytes
|
2646
2841
|
return self if index >= len
|
2647
2842
|
## PULL_UINT64
|
2648
2843
|
tag =
|
@@ -5154,84 +5349,84 @@ module Api
|
|
5154
5349
|
end
|
5155
5350
|
def _encode(buff)
|
5156
5351
|
val = @idle_production_time
|
5157
|
-
if
|
5352
|
+
if has_idle_production_time?
|
5158
5353
|
buff << 0x0d
|
5159
5354
|
|
5160
5355
|
[val].pack("e", buffer: buff)
|
5161
5356
|
end
|
5162
5357
|
|
5163
5358
|
val = @idle_worker_time
|
5164
|
-
if
|
5359
|
+
if has_idle_worker_time?
|
5165
5360
|
buff << 0x15
|
5166
5361
|
|
5167
5362
|
[val].pack("e", buffer: buff)
|
5168
5363
|
end
|
5169
5364
|
|
5170
5365
|
val = @total_value_units
|
5171
|
-
if
|
5366
|
+
if has_total_value_units?
|
5172
5367
|
buff << 0x1d
|
5173
5368
|
|
5174
5369
|
[val].pack("e", buffer: buff)
|
5175
5370
|
end
|
5176
5371
|
|
5177
5372
|
val = @total_value_structures
|
5178
|
-
if
|
5373
|
+
if has_total_value_structures?
|
5179
5374
|
buff << 0x25
|
5180
5375
|
|
5181
5376
|
[val].pack("e", buffer: buff)
|
5182
5377
|
end
|
5183
5378
|
|
5184
5379
|
val = @killed_value_units
|
5185
|
-
if
|
5380
|
+
if has_killed_value_units?
|
5186
5381
|
buff << 0x2d
|
5187
5382
|
|
5188
5383
|
[val].pack("e", buffer: buff)
|
5189
5384
|
end
|
5190
5385
|
|
5191
5386
|
val = @killed_value_structures
|
5192
|
-
if
|
5387
|
+
if has_killed_value_structures?
|
5193
5388
|
buff << 0x35
|
5194
5389
|
|
5195
5390
|
[val].pack("e", buffer: buff)
|
5196
5391
|
end
|
5197
5392
|
|
5198
5393
|
val = @collected_minerals
|
5199
|
-
if
|
5394
|
+
if has_collected_minerals?
|
5200
5395
|
buff << 0x3d
|
5201
5396
|
|
5202
5397
|
[val].pack("e", buffer: buff)
|
5203
5398
|
end
|
5204
5399
|
|
5205
5400
|
val = @collected_vespene
|
5206
|
-
if
|
5401
|
+
if has_collected_vespene?
|
5207
5402
|
buff << 0x45
|
5208
5403
|
|
5209
5404
|
[val].pack("e", buffer: buff)
|
5210
5405
|
end
|
5211
5406
|
|
5212
5407
|
val = @collection_rate_minerals
|
5213
|
-
if
|
5408
|
+
if has_collection_rate_minerals?
|
5214
5409
|
buff << 0x4d
|
5215
5410
|
|
5216
5411
|
[val].pack("e", buffer: buff)
|
5217
5412
|
end
|
5218
5413
|
|
5219
5414
|
val = @collection_rate_vespene
|
5220
|
-
if
|
5415
|
+
if has_collection_rate_vespene?
|
5221
5416
|
buff << 0x55
|
5222
5417
|
|
5223
5418
|
[val].pack("e", buffer: buff)
|
5224
5419
|
end
|
5225
5420
|
|
5226
5421
|
val = @spent_minerals
|
5227
|
-
if
|
5422
|
+
if has_spent_minerals?
|
5228
5423
|
buff << 0x5d
|
5229
5424
|
|
5230
5425
|
[val].pack("e", buffer: buff)
|
5231
5426
|
end
|
5232
5427
|
|
5233
5428
|
val = @spent_vespene
|
5234
|
-
if
|
5429
|
+
if has_spent_vespene?
|
5235
5430
|
buff << 0x65
|
5236
5431
|
|
5237
5432
|
[val].pack("e", buffer: buff)
|
@@ -5921,7 +6116,7 @@ module Api
|
|
5921
6116
|
end
|
5922
6117
|
|
5923
6118
|
val = @current_apm
|
5924
|
-
if
|
6119
|
+
if has_current_apm?
|
5925
6120
|
buff << 0xdd
|
5926
6121
|
buff << 0x01
|
5927
6122
|
|
@@ -5929,47 +6124,193 @@ module Api
|
|
5929
6124
|
end
|
5930
6125
|
|
5931
6126
|
val = @current_effective_apm
|
5932
|
-
if
|
6127
|
+
if has_current_effective_apm?
|
5933
6128
|
buff << 0xe5
|
5934
6129
|
buff << 0x01
|
5935
6130
|
|
5936
6131
|
[val].pack("e", buffer: buff)
|
5937
6132
|
end
|
5938
|
-
|
6133
|
+
buff << @_unknown_fields if @_unknown_fields
|
5939
6134
|
buff
|
5940
6135
|
end
|
5941
6136
|
|
5942
6137
|
def to_h
|
5943
6138
|
result = {}
|
5944
|
-
|
5945
|
-
result["
|
5946
|
-
result["
|
5947
|
-
result["
|
5948
|
-
result["
|
5949
|
-
result["
|
5950
|
-
result["
|
5951
|
-
result["
|
5952
|
-
result["
|
5953
|
-
result["
|
5954
|
-
result["
|
5955
|
-
result["
|
5956
|
-
result["
|
5957
|
-
result["
|
5958
|
-
result["
|
5959
|
-
result["
|
5960
|
-
result["
|
5961
|
-
result["
|
5962
|
-
result["
|
5963
|
-
result["
|
5964
|
-
result["
|
5965
|
-
result["
|
5966
|
-
result["
|
5967
|
-
result["
|
5968
|
-
result["
|
5969
|
-
result["
|
5970
|
-
result["
|
5971
|
-
result["
|
6139
|
+
|
6140
|
+
result[:"idle_production_time"] = @idle_production_time
|
6141
|
+
result[:"idle_worker_time"] = @idle_worker_time
|
6142
|
+
result[:"total_value_units"] = @total_value_units
|
6143
|
+
result[:"total_value_structures"] = @total_value_structures
|
6144
|
+
result[:"killed_value_units"] = @killed_value_units
|
6145
|
+
result[:"killed_value_structures"] = @killed_value_structures
|
6146
|
+
result[:"collected_minerals"] = @collected_minerals
|
6147
|
+
result[:"collected_vespene"] = @collected_vespene
|
6148
|
+
result[:"collection_rate_minerals"] = @collection_rate_minerals
|
6149
|
+
result[:"collection_rate_vespene"] = @collection_rate_vespene
|
6150
|
+
result[:"spent_minerals"] = @spent_minerals
|
6151
|
+
result[:"spent_vespene"] = @spent_vespene
|
6152
|
+
result[:"food_used"] = @food_used.to_h
|
6153
|
+
result[:"killed_minerals"] = @killed_minerals.to_h
|
6154
|
+
result[:"killed_vespene"] = @killed_vespene.to_h
|
6155
|
+
result[:"lost_minerals"] = @lost_minerals.to_h
|
6156
|
+
result[:"lost_vespene"] = @lost_vespene.to_h
|
6157
|
+
result[:"friendly_fire_minerals"] = @friendly_fire_minerals.to_h
|
6158
|
+
result[:"friendly_fire_vespene"] = @friendly_fire_vespene.to_h
|
6159
|
+
result[:"used_minerals"] = @used_minerals.to_h
|
6160
|
+
result[:"used_vespene"] = @used_vespene.to_h
|
6161
|
+
result[:"total_used_minerals"] = @total_used_minerals.to_h
|
6162
|
+
result[:"total_used_vespene"] = @total_used_vespene.to_h
|
6163
|
+
result[:"total_damage_dealt"] = @total_damage_dealt.to_h
|
6164
|
+
result[:"total_damage_taken"] = @total_damage_taken.to_h
|
6165
|
+
result[:"total_healed"] = @total_healed.to_h
|
6166
|
+
result[:"current_apm"] = @current_apm
|
6167
|
+
result[:"current_effective_apm"] = @current_effective_apm
|
6168
|
+
|
6169
|
+
result
|
6170
|
+
end
|
6171
|
+
|
6172
|
+
def as_json(options = {})
|
6173
|
+
result = {}
|
6174
|
+
|
6175
|
+
result["idleProductionTime"] = @idle_production_time if !options[
|
6176
|
+
:compact
|
6177
|
+
] || has_idle_production_time?
|
6178
|
+
result["idleWorkerTime"] = @idle_worker_time if !options[:compact] ||
|
6179
|
+
has_idle_worker_time?
|
6180
|
+
result["totalValueUnits"] = @total_value_units if !options[:compact] ||
|
6181
|
+
has_total_value_units?
|
6182
|
+
result["totalValueStructures"] = @total_value_structures if !options[
|
6183
|
+
:compact
|
6184
|
+
] || has_total_value_structures?
|
6185
|
+
result["killedValueUnits"] = @killed_value_units if !options[:compact] ||
|
6186
|
+
has_killed_value_units?
|
6187
|
+
result["killedValueStructures"] = @killed_value_structures if !options[
|
6188
|
+
:compact
|
6189
|
+
] || has_killed_value_structures?
|
6190
|
+
result["collectedMinerals"] = @collected_minerals if !options[:compact] ||
|
6191
|
+
has_collected_minerals?
|
6192
|
+
result["collectedVespene"] = @collected_vespene if !options[:compact] ||
|
6193
|
+
has_collected_vespene?
|
6194
|
+
result["collectionRateMinerals"] = @collection_rate_minerals if !options[
|
6195
|
+
:compact
|
6196
|
+
] || has_collection_rate_minerals?
|
6197
|
+
result["collectionRateVespene"] = @collection_rate_vespene if !options[
|
6198
|
+
:compact
|
6199
|
+
] || has_collection_rate_vespene?
|
6200
|
+
result["spentMinerals"] = @spent_minerals if !options[:compact] ||
|
6201
|
+
has_spent_minerals?
|
6202
|
+
result["spentVespene"] = @spent_vespene if !options[:compact] ||
|
6203
|
+
has_spent_vespene?
|
6204
|
+
result["foodUsed"] = (
|
6205
|
+
if @food_used.nil?
|
6206
|
+
{}
|
6207
|
+
else
|
6208
|
+
@food_used.as_json(options)
|
6209
|
+
end
|
6210
|
+
) if !options[:compact] || has_food_used?
|
6211
|
+
result["killedMinerals"] = (
|
6212
|
+
if @killed_minerals.nil?
|
6213
|
+
{}
|
6214
|
+
else
|
6215
|
+
@killed_minerals.as_json(options)
|
6216
|
+
end
|
6217
|
+
) if !options[:compact] || has_killed_minerals?
|
6218
|
+
result["killedVespene"] = (
|
6219
|
+
if @killed_vespene.nil?
|
6220
|
+
{}
|
6221
|
+
else
|
6222
|
+
@killed_vespene.as_json(options)
|
6223
|
+
end
|
6224
|
+
) if !options[:compact] || has_killed_vespene?
|
6225
|
+
result["lostMinerals"] = (
|
6226
|
+
if @lost_minerals.nil?
|
6227
|
+
{}
|
6228
|
+
else
|
6229
|
+
@lost_minerals.as_json(options)
|
6230
|
+
end
|
6231
|
+
) if !options[:compact] || has_lost_minerals?
|
6232
|
+
result["lostVespene"] = (
|
6233
|
+
if @lost_vespene.nil?
|
6234
|
+
{}
|
6235
|
+
else
|
6236
|
+
@lost_vespene.as_json(options)
|
6237
|
+
end
|
6238
|
+
) if !options[:compact] || has_lost_vespene?
|
6239
|
+
result["friendlyFireMinerals"] = (
|
6240
|
+
if @friendly_fire_minerals.nil?
|
6241
|
+
{}
|
6242
|
+
else
|
6243
|
+
@friendly_fire_minerals.as_json(options)
|
6244
|
+
end
|
6245
|
+
) if !options[:compact] || has_friendly_fire_minerals?
|
6246
|
+
result["friendlyFireVespene"] = (
|
6247
|
+
if @friendly_fire_vespene.nil?
|
6248
|
+
{}
|
6249
|
+
else
|
6250
|
+
@friendly_fire_vespene.as_json(options)
|
6251
|
+
end
|
6252
|
+
) if !options[:compact] || has_friendly_fire_vespene?
|
6253
|
+
result["usedMinerals"] = (
|
6254
|
+
if @used_minerals.nil?
|
6255
|
+
{}
|
6256
|
+
else
|
6257
|
+
@used_minerals.as_json(options)
|
6258
|
+
end
|
6259
|
+
) if !options[:compact] || has_used_minerals?
|
6260
|
+
result["usedVespene"] = (
|
6261
|
+
if @used_vespene.nil?
|
6262
|
+
{}
|
6263
|
+
else
|
6264
|
+
@used_vespene.as_json(options)
|
6265
|
+
end
|
6266
|
+
) if !options[:compact] || has_used_vespene?
|
6267
|
+
result["totalUsedMinerals"] = (
|
6268
|
+
if @total_used_minerals.nil?
|
6269
|
+
{}
|
6270
|
+
else
|
6271
|
+
@total_used_minerals.as_json(options)
|
6272
|
+
end
|
6273
|
+
) if !options[:compact] || has_total_used_minerals?
|
6274
|
+
result["totalUsedVespene"] = (
|
6275
|
+
if @total_used_vespene.nil?
|
6276
|
+
{}
|
6277
|
+
else
|
6278
|
+
@total_used_vespene.as_json(options)
|
6279
|
+
end
|
6280
|
+
) if !options[:compact] || has_total_used_vespene?
|
6281
|
+
result["totalDamageDealt"] = (
|
6282
|
+
if @total_damage_dealt.nil?
|
6283
|
+
{}
|
6284
|
+
else
|
6285
|
+
@total_damage_dealt.as_json(options)
|
6286
|
+
end
|
6287
|
+
) if !options[:compact] || has_total_damage_dealt?
|
6288
|
+
result["totalDamageTaken"] = (
|
6289
|
+
if @total_damage_taken.nil?
|
6290
|
+
{}
|
6291
|
+
else
|
6292
|
+
@total_damage_taken.as_json(options)
|
6293
|
+
end
|
6294
|
+
) if !options[:compact] || has_total_damage_taken?
|
6295
|
+
result["totalHealed"] = (
|
6296
|
+
if @total_healed.nil?
|
6297
|
+
{}
|
6298
|
+
else
|
6299
|
+
@total_healed.as_json(options)
|
6300
|
+
end
|
6301
|
+
) if !options[:compact] || has_total_healed?
|
6302
|
+
result["currentApm"] = @current_apm if !options[:compact] ||
|
6303
|
+
has_current_apm?
|
6304
|
+
result["currentEffectiveApm"] = @current_effective_apm if !options[
|
6305
|
+
:compact
|
6306
|
+
] || has_current_effective_apm?
|
6307
|
+
|
5972
6308
|
result
|
5973
6309
|
end
|
6310
|
+
|
6311
|
+
def to_json(as_json_options = {})
|
6312
|
+
require "json"
|
6313
|
+
JSON.dump(as_json(as_json_options))
|
6314
|
+
end
|
5974
6315
|
end
|
5975
6316
|
end
|