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.
@@ -19,63 +19,35 @@ module Api
19
19
  FAST_BUILD = 12
20
20
 
21
21
  def self.lookup(val)
22
- if val == 0
23
- :ENUM_DEBUG_GAME_STATE_UNSET
24
- elsif val == 1
25
- :SHOW_MAP
26
- elsif val == 2
27
- :CONTROL_ENEMY
28
- elsif val == 3
29
- :FOOD
30
- elsif val == 4
31
- :FREE
32
- elsif val == 5
33
- :ALL_RESOURCES
34
- elsif val == 6
35
- :GOD
36
- elsif val == 7
37
- :MINERALS
38
- elsif val == 8
39
- :GAS
40
- elsif val == 9
41
- :COOLDOWNS
42
- elsif val == 10
43
- :TECH_TREE
44
- elsif val == 11
45
- :UPGRADE
46
- elsif val == 12
47
- :FAST_BUILD
48
- end
22
+ return :ENUM_DEBUG_GAME_STATE_UNSET if val == 0
23
+ return :SHOW_MAP if val == 1
24
+ return :CONTROL_ENEMY if val == 2
25
+ return :FOOD if val == 3
26
+ return :FREE if val == 4
27
+ return :ALL_RESOURCES if val == 5
28
+ return :GOD if val == 6
29
+ return :MINERALS if val == 7
30
+ return :GAS if val == 8
31
+ return :COOLDOWNS if val == 9
32
+ return :TECH_TREE if val == 10
33
+ return :UPGRADE if val == 11
34
+ return :FAST_BUILD if val == 12
49
35
  end
50
36
 
51
37
  def self.resolve(val)
52
- if val == :ENUM_DEBUG_GAME_STATE_UNSET
53
- 0
54
- elsif val == :SHOW_MAP
55
- 1
56
- elsif val == :CONTROL_ENEMY
57
- 2
58
- elsif val == :FOOD
59
- 3
60
- elsif val == :FREE
61
- 4
62
- elsif val == :ALL_RESOURCES
63
- 5
64
- elsif val == :GOD
65
- 6
66
- elsif val == :MINERALS
67
- 7
68
- elsif val == :GAS
69
- 8
70
- elsif val == :COOLDOWNS
71
- 9
72
- elsif val == :TECH_TREE
73
- 10
74
- elsif val == :UPGRADE
75
- 11
76
- elsif val == :FAST_BUILD
77
- 12
78
- end
38
+ return 0 if val == :ENUM_DEBUG_GAME_STATE_UNSET
39
+ return 1 if val == :SHOW_MAP
40
+ return 2 if val == :CONTROL_ENEMY
41
+ return 3 if val == :FOOD
42
+ return 4 if val == :FREE
43
+ return 5 if val == :ALL_RESOURCES
44
+ return 6 if val == :GOD
45
+ return 7 if val == :MINERALS
46
+ return 8 if val == :GAS
47
+ return 9 if val == :COOLDOWNS
48
+ return 10 if val == :TECH_TREE
49
+ return 11 if val == :UPGRADE
50
+ return 12 if val == :FAST_BUILD
79
51
  end
80
52
  end
81
53
 
@@ -296,7 +268,7 @@ module Api
296
268
 
297
269
  unknown_bytes = +"".b
298
270
  val = tag
299
- while val != 0
271
+ loop do
300
272
  byte = val & 0x7F
301
273
 
302
274
  val >>= 7
@@ -307,6 +279,7 @@ module Api
307
279
 
308
280
  byte |= 0x80 if val != 0
309
281
  unknown_bytes << byte
282
+ break if val == 0
310
283
  end
311
284
 
312
285
  case wire_type
@@ -381,7 +354,7 @@ module Api
381
354
  end
382
355
 
383
356
  val = value
384
- while val != 0
357
+ loop do
385
358
  byte = val & 0x7F
386
359
 
387
360
  val >>= 7
@@ -392,6 +365,7 @@ module Api
392
365
 
393
366
  byte |= 0x80 if val != 0
394
367
  unknown_bytes << byte
368
+ break if val == 0
395
369
  end
396
370
 
397
371
  unknown_bytes << buff.byteslice(index, value)
@@ -1450,7 +1424,7 @@ module Api
1450
1424
  if val != 0
1451
1425
  buff << 0x10
1452
1426
 
1453
- while val != 0
1427
+ loop do
1454
1428
  byte = val & 0x7F
1455
1429
 
1456
1430
  val >>= 7
@@ -1461,6 +1435,7 @@ module Api
1461
1435
 
1462
1436
  byte |= 0x80 if val != 0
1463
1437
  buff << byte
1438
+ break if val == 0
1464
1439
  end
1465
1440
  end
1466
1441
 
@@ -1757,9 +1732,87 @@ module Api
1757
1732
 
1758
1733
  def to_h
1759
1734
  result = {}
1760
- send("command").tap { |f| result[f.to_sym] = send(f) if f }
1735
+
1736
+ resolved_command = self.command
1737
+
1738
+ result[:"draw"] = @draw.to_h if resolved_command == :"draw"
1739
+ result[:"game_state"] = @game_state if resolved_command == :"game_state"
1740
+ result[:"create_unit"] = @create_unit.to_h if resolved_command ==
1741
+ :"create_unit"
1742
+ result[:"kill_unit"] = @kill_unit.to_h if resolved_command == :"kill_unit"
1743
+ result[:"test_process"] = @test_process.to_h if resolved_command ==
1744
+ :"test_process"
1745
+ result[:"score"] = @score.to_h if resolved_command == :"score"
1746
+ result[:"end_game"] = @end_game.to_h if resolved_command == :"end_game"
1747
+ result[:"unit_value"] = @unit_value.to_h if resolved_command ==
1748
+ :"unit_value"
1749
+
1750
+ result
1751
+ end
1752
+
1753
+ def as_json(options = {})
1754
+ result = {}
1755
+
1756
+ resolved_command = self.command
1757
+
1758
+ result["draw"] = (
1759
+ if @draw.nil?
1760
+ {}
1761
+ else
1762
+ @draw.as_json(options)
1763
+ end
1764
+ ) if resolved_command == :"draw"
1765
+ result["gameState"] = @game_state if resolved_command == :"game_state"
1766
+ result["createUnit"] = (
1767
+ if @create_unit.nil?
1768
+ {}
1769
+ else
1770
+ @create_unit.as_json(options)
1771
+ end
1772
+ ) if resolved_command == :"create_unit"
1773
+ result["killUnit"] = (
1774
+ if @kill_unit.nil?
1775
+ {}
1776
+ else
1777
+ @kill_unit.as_json(options)
1778
+ end
1779
+ ) if resolved_command == :"kill_unit"
1780
+ result["testProcess"] = (
1781
+ if @test_process.nil?
1782
+ {}
1783
+ else
1784
+ @test_process.as_json(options)
1785
+ end
1786
+ ) if resolved_command == :"test_process"
1787
+ result["score"] = (
1788
+ if @score.nil?
1789
+ {}
1790
+ else
1791
+ @score.as_json(options)
1792
+ end
1793
+ ) if resolved_command == :"score"
1794
+ result["endGame"] = (
1795
+ if @end_game.nil?
1796
+ {}
1797
+ else
1798
+ @end_game.as_json(options)
1799
+ end
1800
+ ) if resolved_command == :"end_game"
1801
+ result["unitValue"] = (
1802
+ if @unit_value.nil?
1803
+ {}
1804
+ else
1805
+ @unit_value.as_json(options)
1806
+ end
1807
+ ) if resolved_command == :"unit_value"
1808
+
1761
1809
  result
1762
1810
  end
1811
+
1812
+ def to_json(as_json_options = {})
1813
+ require "json"
1814
+ JSON.dump(as_json(as_json_options))
1815
+ end
1763
1816
  end
1764
1817
  class DebugDraw
1765
1818
  def self.decode(buff)
@@ -1877,7 +1930,7 @@ module Api
1877
1930
 
1878
1931
  unknown_bytes = +"".b
1879
1932
  val = tag
1880
- while val != 0
1933
+ loop do
1881
1934
  byte = val & 0x7F
1882
1935
 
1883
1936
  val >>= 7
@@ -1888,6 +1941,7 @@ module Api
1888
1941
 
1889
1942
  byte |= 0x80 if val != 0
1890
1943
  unknown_bytes << byte
1944
+ break if val == 0
1891
1945
  end
1892
1946
 
1893
1947
  case wire_type
@@ -1962,7 +2016,7 @@ module Api
1962
2016
  end
1963
2017
 
1964
2018
  val = value
1965
- while val != 0
2019
+ loop do
1966
2020
  byte = val & 0x7F
1967
2021
 
1968
2022
  val >>= 7
@@ -1973,6 +2027,7 @@ module Api
1973
2027
 
1974
2028
  byte |= 0x80 if val != 0
1975
2029
  unknown_bytes << byte
2030
+ break if val == 0
1976
2031
  end
1977
2032
 
1978
2033
  unknown_bytes << buff.byteslice(index, value)
@@ -2805,12 +2860,41 @@ module Api
2805
2860
 
2806
2861
  def to_h
2807
2862
  result = {}
2808
- result["text".to_sym] = @text
2809
- result["lines".to_sym] = @lines
2810
- result["boxes".to_sym] = @boxes
2811
- result["spheres".to_sym] = @spheres
2863
+
2864
+ result[:"text"] = @text.map(&:to_h)
2865
+ result[:"lines"] = @lines.map(&:to_h)
2866
+ result[:"boxes"] = @boxes.map(&:to_h)
2867
+ result[:"spheres"] = @spheres.map(&:to_h)
2868
+
2869
+ result
2870
+ end
2871
+
2872
+ def as_json(options = {})
2873
+ result = {}
2874
+
2875
+ tmp_text = @text.map { |v| v.as_json(options) }
2876
+
2877
+ result["text"] = tmp_text if !options[:compact] || tmp_text.any?
2878
+
2879
+ tmp_lines = @lines.map { |v| v.as_json(options) }
2880
+
2881
+ result["lines"] = tmp_lines if !options[:compact] || tmp_lines.any?
2882
+
2883
+ tmp_boxes = @boxes.map { |v| v.as_json(options) }
2884
+
2885
+ result["boxes"] = tmp_boxes if !options[:compact] || tmp_boxes.any?
2886
+
2887
+ tmp_spheres = @spheres.map { |v| v.as_json(options) }
2888
+
2889
+ result["spheres"] = tmp_spheres if !options[:compact] || tmp_spheres.any?
2890
+
2812
2891
  result
2813
2892
  end
2893
+
2894
+ def to_json(as_json_options = {})
2895
+ require "json"
2896
+ JSON.dump(as_json(as_json_options))
2897
+ end
2814
2898
  end
2815
2899
  class Line
2816
2900
  def self.decode(buff)
@@ -2939,7 +3023,7 @@ module Api
2939
3023
 
2940
3024
  unknown_bytes = +"".b
2941
3025
  val = tag
2942
- while val != 0
3026
+ loop do
2943
3027
  byte = val & 0x7F
2944
3028
 
2945
3029
  val >>= 7
@@ -2950,6 +3034,7 @@ module Api
2950
3034
 
2951
3035
  byte |= 0x80 if val != 0
2952
3036
  unknown_bytes << byte
3037
+ break if val == 0
2953
3038
  end
2954
3039
 
2955
3040
  case wire_type
@@ -3024,7 +3109,7 @@ module Api
3024
3109
  end
3025
3110
 
3026
3111
  val = value
3027
- while val != 0
3112
+ loop do
3028
3113
  byte = val & 0x7F
3029
3114
 
3030
3115
  val >>= 7
@@ -3035,6 +3120,7 @@ module Api
3035
3120
 
3036
3121
  byte |= 0x80 if val != 0
3037
3122
  unknown_bytes << byte
3123
+ break if val == 0
3038
3124
  end
3039
3125
 
3040
3126
  unknown_bytes << buff.byteslice(index, value)
@@ -3431,10 +3517,30 @@ module Api
3431
3517
 
3432
3518
  def to_h
3433
3519
  result = {}
3434
- result["p0".to_sym] = @p0.to_h
3435
- result["p1".to_sym] = @p1.to_h
3520
+
3521
+ result[:"p0"] = @p0.to_h
3522
+ result[:"p1"] = @p1.to_h
3523
+
3524
+ result
3525
+ end
3526
+
3527
+ def as_json(options = {})
3528
+ result = {}
3529
+
3530
+ result["p0"] = @p0.nil? ? {} : @p0.as_json(options) if !options[
3531
+ :compact
3532
+ ] || has_p0?
3533
+ result["p1"] = @p1.nil? ? {} : @p1.as_json(options) if !options[
3534
+ :compact
3535
+ ] || has_p1?
3536
+
3436
3537
  result
3437
3538
  end
3539
+
3540
+ def to_json(as_json_options = {})
3541
+ require "json"
3542
+ JSON.dump(as_json(as_json_options))
3543
+ end
3438
3544
  end
3439
3545
  class Color
3440
3546
  def self.decode(buff)
@@ -3609,7 +3715,7 @@ module Api
3609
3715
 
3610
3716
  unknown_bytes = +"".b
3611
3717
  val = tag
3612
- while val != 0
3718
+ loop do
3613
3719
  byte = val & 0x7F
3614
3720
 
3615
3721
  val >>= 7
@@ -3620,6 +3726,7 @@ module Api
3620
3726
 
3621
3727
  byte |= 0x80 if val != 0
3622
3728
  unknown_bytes << byte
3729
+ break if val == 0
3623
3730
  end
3624
3731
 
3625
3732
  case wire_type
@@ -3694,7 +3801,7 @@ module Api
3694
3801
  end
3695
3802
 
3696
3803
  val = value
3697
- while val != 0
3804
+ loop do
3698
3805
  byte = val & 0x7F
3699
3806
 
3700
3807
  val >>= 7
@@ -3705,6 +3812,7 @@ module Api
3705
3812
 
3706
3813
  byte |= 0x80 if val != 0
3707
3814
  unknown_bytes << byte
3815
+ break if val == 0
3708
3816
  end
3709
3817
 
3710
3818
  unknown_bytes << buff.byteslice(index, value)
@@ -4101,38 +4209,41 @@ module Api
4101
4209
  end
4102
4210
  def _encode(buff)
4103
4211
  val = @r
4104
- if val != 0
4212
+ if has_r?
4105
4213
  buff << 0x08
4106
4214
 
4107
- while val != 0
4215
+ loop do
4108
4216
  byte = val & 0x7F
4109
4217
  val >>= 7
4110
4218
  byte |= 0x80 if val > 0
4111
4219
  buff << byte
4220
+ break if val == 0
4112
4221
  end
4113
4222
  end
4114
4223
 
4115
4224
  val = @g
4116
- if val != 0
4225
+ if has_g?
4117
4226
  buff << 0x10
4118
4227
 
4119
- while val != 0
4228
+ loop do
4120
4229
  byte = val & 0x7F
4121
4230
  val >>= 7
4122
4231
  byte |= 0x80 if val > 0
4123
4232
  buff << byte
4233
+ break if val == 0
4124
4234
  end
4125
4235
  end
4126
4236
 
4127
4237
  val = @b
4128
- if val != 0
4238
+ if has_b?
4129
4239
  buff << 0x18
4130
4240
 
4131
- while val != 0
4241
+ loop do
4132
4242
  byte = val & 0x7F
4133
4243
  val >>= 7
4134
4244
  byte |= 0x80 if val > 0
4135
4245
  buff << byte
4246
+ break if val == 0
4136
4247
  end
4137
4248
  end
4138
4249
  buff << @_unknown_fields if @_unknown_fields
@@ -4141,11 +4252,28 @@ module Api
4141
4252
 
4142
4253
  def to_h
4143
4254
  result = {}
4144
- result["r".to_sym] = @r
4145
- result["g".to_sym] = @g
4146
- result["b".to_sym] = @b
4255
+
4256
+ result[:"r"] = @r
4257
+ result[:"g"] = @g
4258
+ result[:"b"] = @b
4259
+
4260
+ result
4261
+ end
4262
+
4263
+ def as_json(options = {})
4264
+ result = {}
4265
+
4266
+ result["r"] = @r if !options[:compact] || has_r?
4267
+ result["g"] = @g if !options[:compact] || has_g?
4268
+ result["b"] = @b if !options[:compact] || has_b?
4269
+
4147
4270
  result
4148
4271
  end
4272
+
4273
+ def to_json(as_json_options = {})
4274
+ require "json"
4275
+ JSON.dump(as_json(as_json_options))
4276
+ end
4149
4277
  end
4150
4278
  class DebugText
4151
4279
  def self.decode(buff)
@@ -4346,7 +4474,7 @@ module Api
4346
4474
 
4347
4475
  unknown_bytes = +"".b
4348
4476
  val = tag
4349
- while val != 0
4477
+ loop do
4350
4478
  byte = val & 0x7F
4351
4479
 
4352
4480
  val >>= 7
@@ -4357,6 +4485,7 @@ module Api
4357
4485
 
4358
4486
  byte |= 0x80 if val != 0
4359
4487
  unknown_bytes << byte
4488
+ break if val == 0
4360
4489
  end
4361
4490
 
4362
4491
  case wire_type
@@ -4431,7 +4560,7 @@ module Api
4431
4560
  end
4432
4561
 
4433
4562
  val = value
4434
- while val != 0
4563
+ loop do
4435
4564
  byte = val & 0x7F
4436
4565
 
4437
4566
  val >>= 7
@@ -4442,6 +4571,7 @@ module Api
4442
4571
 
4443
4572
  byte |= 0x80 if val != 0
4444
4573
  unknown_bytes << byte
4574
+ break if val == 0
4445
4575
  end
4446
4576
 
4447
4577
  unknown_bytes << buff.byteslice(index, value)
@@ -5120,13 +5250,14 @@ module Api
5120
5250
  end
5121
5251
 
5122
5252
  val = @text
5123
- if ((len = val.bytesize) > 0)
5253
+ if (len = val.bytesize) > 0 || has_text?
5124
5254
  buff << 0x12
5125
- while len != 0
5255
+ loop do
5126
5256
  byte = len & 0x7F
5127
5257
  len >>= 7
5128
5258
  byte |= 0x80 if len > 0
5129
5259
  buff << byte
5260
+ break if len == 0
5130
5261
  end
5131
5262
 
5132
5263
  buff << (val.ascii_only? ? val : val.b)
@@ -5229,14 +5360,15 @@ module Api
5229
5360
  end
5230
5361
 
5231
5362
  val = @size
5232
- if val != 0
5363
+ if has_size?
5233
5364
  buff << 0x28
5234
5365
 
5235
- while val != 0
5366
+ loop do
5236
5367
  byte = val & 0x7F
5237
5368
  val >>= 7
5238
5369
  byte |= 0x80 if val > 0
5239
5370
  buff << byte
5371
+ break if val == 0
5240
5372
  end
5241
5373
  end
5242
5374
  buff << @_unknown_fields if @_unknown_fields
@@ -5245,13 +5377,46 @@ module Api
5245
5377
 
5246
5378
  def to_h
5247
5379
  result = {}
5248
- result["color".to_sym] = @color.to_h
5249
- result["text".to_sym] = @text
5250
- result["virtual_pos".to_sym] = @virtual_pos.to_h
5251
- result["world_pos".to_sym] = @world_pos.to_h
5252
- result["size".to_sym] = @size
5380
+
5381
+ result[:"color"] = @color.to_h
5382
+ result[:"text"] = @text
5383
+ result[:"virtual_pos"] = @virtual_pos.to_h
5384
+ result[:"world_pos"] = @world_pos.to_h
5385
+ result[:"size"] = @size
5386
+
5387
+ result
5388
+ end
5389
+
5390
+ def as_json(options = {})
5391
+ result = {}
5392
+
5393
+ result["color"] = @color.nil? ? {} : @color.as_json(options) if !options[
5394
+ :compact
5395
+ ] || has_color?
5396
+ result["text"] = @text if !options[:compact] || has_text?
5397
+ result["virtualPos"] = (
5398
+ if @virtual_pos.nil?
5399
+ {}
5400
+ else
5401
+ @virtual_pos.as_json(options)
5402
+ end
5403
+ ) if !options[:compact] || has_virtual_pos?
5404
+ result["worldPos"] = (
5405
+ if @world_pos.nil?
5406
+ {}
5407
+ else
5408
+ @world_pos.as_json(options)
5409
+ end
5410
+ ) if !options[:compact] || has_world_pos?
5411
+ result["size"] = @size if !options[:compact] || has_size?
5412
+
5253
5413
  result
5254
5414
  end
5415
+
5416
+ def to_json(as_json_options = {})
5417
+ require "json"
5418
+ JSON.dump(as_json(as_json_options))
5419
+ end
5255
5420
  end
5256
5421
  class DebugLine
5257
5422
  def self.decode(buff)
@@ -5380,7 +5545,7 @@ module Api
5380
5545
 
5381
5546
  unknown_bytes = +"".b
5382
5547
  val = tag
5383
- while val != 0
5548
+ loop do
5384
5549
  byte = val & 0x7F
5385
5550
 
5386
5551
  val >>= 7
@@ -5391,6 +5556,7 @@ module Api
5391
5556
 
5392
5557
  byte |= 0x80 if val != 0
5393
5558
  unknown_bytes << byte
5559
+ break if val == 0
5394
5560
  end
5395
5561
 
5396
5562
  case wire_type
@@ -5465,7 +5631,7 @@ module Api
5465
5631
  end
5466
5632
 
5467
5633
  val = value
5468
- while val != 0
5634
+ loop do
5469
5635
  byte = val & 0x7F
5470
5636
 
5471
5637
  val >>= 7
@@ -5476,6 +5642,7 @@ module Api
5476
5642
 
5477
5643
  byte |= 0x80 if val != 0
5478
5644
  unknown_bytes << byte
5645
+ break if val == 0
5479
5646
  end
5480
5647
 
5481
5648
  unknown_bytes << buff.byteslice(index, value)
@@ -5873,10 +6040,30 @@ module Api
5873
6040
 
5874
6041
  def to_h
5875
6042
  result = {}
5876
- result["color".to_sym] = @color.to_h
5877
- result["line".to_sym] = @line.to_h
6043
+
6044
+ result[:"color"] = @color.to_h
6045
+ result[:"line"] = @line.to_h
6046
+
6047
+ result
6048
+ end
6049
+
6050
+ def as_json(options = {})
6051
+ result = {}
6052
+
6053
+ result["color"] = @color.nil? ? {} : @color.as_json(options) if !options[
6054
+ :compact
6055
+ ] || has_color?
6056
+ result["line"] = @line.nil? ? {} : @line.as_json(options) if !options[
6057
+ :compact
6058
+ ] || has_line?
6059
+
5878
6060
  result
5879
6061
  end
6062
+
6063
+ def to_json(as_json_options = {})
6064
+ require "json"
6065
+ JSON.dump(as_json(as_json_options))
6066
+ end
5880
6067
  end
5881
6068
  class DebugBox
5882
6069
  def self.decode(buff)
@@ -6024,7 +6211,7 @@ module Api
6024
6211
 
6025
6212
  unknown_bytes = +"".b
6026
6213
  val = tag
6027
- while val != 0
6214
+ loop do
6028
6215
  byte = val & 0x7F
6029
6216
 
6030
6217
  val >>= 7
@@ -6035,6 +6222,7 @@ module Api
6035
6222
 
6036
6223
  byte |= 0x80 if val != 0
6037
6224
  unknown_bytes << byte
6225
+ break if val == 0
6038
6226
  end
6039
6227
 
6040
6228
  case wire_type
@@ -6109,7 +6297,7 @@ module Api
6109
6297
  end
6110
6298
 
6111
6299
  val = value
6112
- while val != 0
6300
+ loop do
6113
6301
  byte = val & 0x7F
6114
6302
 
6115
6303
  val >>= 7
@@ -6120,6 +6308,7 @@ module Api
6120
6308
 
6121
6309
  byte |= 0x80 if val != 0
6122
6310
  unknown_bytes << byte
6311
+ break if val == 0
6123
6312
  end
6124
6313
 
6125
6314
  unknown_bytes << buff.byteslice(index, value)
@@ -6677,11 +6866,34 @@ module Api
6677
6866
 
6678
6867
  def to_h
6679
6868
  result = {}
6680
- result["color".to_sym] = @color.to_h
6681
- result["min".to_sym] = @min.to_h
6682
- result["max".to_sym] = @max.to_h
6869
+
6870
+ result[:"color"] = @color.to_h
6871
+ result[:"min"] = @min.to_h
6872
+ result[:"max"] = @max.to_h
6873
+
6683
6874
  result
6684
6875
  end
6876
+
6877
+ def as_json(options = {})
6878
+ result = {}
6879
+
6880
+ result["color"] = @color.nil? ? {} : @color.as_json(options) if !options[
6881
+ :compact
6882
+ ] || has_color?
6883
+ result["min"] = @min.nil? ? {} : @min.as_json(options) if !options[
6884
+ :compact
6885
+ ] || has_min?
6886
+ result["max"] = @max.nil? ? {} : @max.as_json(options) if !options[
6887
+ :compact
6888
+ ] || has_max?
6889
+
6890
+ result
6891
+ end
6892
+
6893
+ def to_json(as_json_options = {})
6894
+ require "json"
6895
+ JSON.dump(as_json(as_json_options))
6896
+ end
6685
6897
  end
6686
6898
  class DebugSphere
6687
6899
  def self.decode(buff)
@@ -6829,7 +7041,7 @@ module Api
6829
7041
 
6830
7042
  unknown_bytes = +"".b
6831
7043
  val = tag
6832
- while val != 0
7044
+ loop do
6833
7045
  byte = val & 0x7F
6834
7046
 
6835
7047
  val >>= 7
@@ -6840,6 +7052,7 @@ module Api
6840
7052
 
6841
7053
  byte |= 0x80 if val != 0
6842
7054
  unknown_bytes << byte
7055
+ break if val == 0
6843
7056
  end
6844
7057
 
6845
7058
  case wire_type
@@ -6914,7 +7127,7 @@ module Api
6914
7127
  end
6915
7128
 
6916
7129
  val = value
6917
- while val != 0
7130
+ loop do
6918
7131
  byte = val & 0x7F
6919
7132
 
6920
7133
  val >>= 7
@@ -6925,6 +7138,7 @@ module Api
6925
7138
 
6926
7139
  byte |= 0x80 if val != 0
6927
7140
  unknown_bytes << byte
7141
+ break if val == 0
6928
7142
  end
6929
7143
 
6930
7144
  unknown_bytes << buff.byteslice(index, value)
@@ -7376,7 +7590,7 @@ module Api
7376
7590
  end
7377
7591
 
7378
7592
  val = @r
7379
- if val != 0
7593
+ if has_r?
7380
7594
  buff << 0x1d
7381
7595
 
7382
7596
  [val].pack("e", buffer: buff)
@@ -7387,11 +7601,31 @@ module Api
7387
7601
 
7388
7602
  def to_h
7389
7603
  result = {}
7390
- result["color".to_sym] = @color.to_h
7391
- result["p".to_sym] = @p.to_h
7392
- result["r".to_sym] = @r
7604
+
7605
+ result[:"color"] = @color.to_h
7606
+ result[:"p"] = @p.to_h
7607
+ result[:"r"] = @r
7608
+
7393
7609
  result
7394
7610
  end
7611
+
7612
+ def as_json(options = {})
7613
+ result = {}
7614
+
7615
+ result["color"] = @color.nil? ? {} : @color.as_json(options) if !options[
7616
+ :compact
7617
+ ] || has_color?
7618
+ result["p"] = @p.nil? ? {} : @p.as_json(options) if !options[:compact] ||
7619
+ has_p?
7620
+ result["r"] = @r if !options[:compact] || has_r?
7621
+
7622
+ result
7623
+ end
7624
+
7625
+ def to_json(as_json_options = {})
7626
+ require "json"
7627
+ JSON.dump(as_json(as_json_options))
7628
+ end
7395
7629
  end
7396
7630
  class DebugCreateUnit
7397
7631
  def self.decode(buff)
@@ -7585,7 +7819,7 @@ module Api
7585
7819
 
7586
7820
  unknown_bytes = +"".b
7587
7821
  val = tag
7588
- while val != 0
7822
+ loop do
7589
7823
  byte = val & 0x7F
7590
7824
 
7591
7825
  val >>= 7
@@ -7596,6 +7830,7 @@ module Api
7596
7830
 
7597
7831
  byte |= 0x80 if val != 0
7598
7832
  unknown_bytes << byte
7833
+ break if val == 0
7599
7834
  end
7600
7835
 
7601
7836
  case wire_type
@@ -7670,7 +7905,7 @@ module Api
7670
7905
  end
7671
7906
 
7672
7907
  val = value
7673
- while val != 0
7908
+ loop do
7674
7909
  byte = val & 0x7F
7675
7910
 
7676
7911
  val >>= 7
@@ -7681,6 +7916,7 @@ module Api
7681
7916
 
7682
7917
  byte |= 0x80 if val != 0
7683
7918
  unknown_bytes << byte
7919
+ break if val == 0
7684
7920
  end
7685
7921
 
7686
7922
  unknown_bytes << buff.byteslice(index, value)
@@ -8202,22 +8438,23 @@ module Api
8202
8438
  end
8203
8439
  def _encode(buff)
8204
8440
  val = @unit_type
8205
- if val != 0
8441
+ if has_unit_type?
8206
8442
  buff << 0x08
8207
8443
 
8208
- while val != 0
8444
+ loop do
8209
8445
  byte = val & 0x7F
8210
8446
  val >>= 7
8211
8447
  byte |= 0x80 if val > 0
8212
8448
  buff << byte
8449
+ break if val == 0
8213
8450
  end
8214
8451
  end
8215
8452
 
8216
8453
  val = @owner
8217
- if val != 0
8454
+ if has_owner?
8218
8455
  buff << 0x10
8219
8456
 
8220
- while val != 0
8457
+ loop do
8221
8458
  byte = val & 0x7F
8222
8459
 
8223
8460
  val >>= 7
@@ -8228,6 +8465,7 @@ module Api
8228
8465
 
8229
8466
  byte |= 0x80 if val != 0
8230
8467
  buff << byte
8468
+ break if val == 0
8231
8469
  end
8232
8470
  end
8233
8471
 
@@ -8280,14 +8518,15 @@ module Api
8280
8518
  end
8281
8519
 
8282
8520
  val = @quantity
8283
- if val != 0
8521
+ if has_quantity?
8284
8522
  buff << 0x20
8285
8523
 
8286
- while val != 0
8524
+ loop do
8287
8525
  byte = val & 0x7F
8288
8526
  val >>= 7
8289
8527
  byte |= 0x80 if val > 0
8290
8528
  buff << byte
8529
+ break if val == 0
8291
8530
  end
8292
8531
  end
8293
8532
  buff << @_unknown_fields if @_unknown_fields
@@ -8296,12 +8535,32 @@ module Api
8296
8535
 
8297
8536
  def to_h
8298
8537
  result = {}
8299
- result["unit_type".to_sym] = @unit_type
8300
- result["owner".to_sym] = @owner
8301
- result["pos".to_sym] = @pos.to_h
8302
- result["quantity".to_sym] = @quantity
8538
+
8539
+ result[:"unit_type"] = @unit_type
8540
+ result[:"owner"] = @owner
8541
+ result[:"pos"] = @pos.to_h
8542
+ result[:"quantity"] = @quantity
8543
+
8303
8544
  result
8304
8545
  end
8546
+
8547
+ def as_json(options = {})
8548
+ result = {}
8549
+
8550
+ result["unitType"] = @unit_type if !options[:compact] || has_unit_type?
8551
+ result["owner"] = @owner if !options[:compact] || has_owner?
8552
+ result["pos"] = @pos.nil? ? {} : @pos.as_json(options) if !options[
8553
+ :compact
8554
+ ] || has_pos?
8555
+ result["quantity"] = @quantity if !options[:compact] || has_quantity?
8556
+
8557
+ result
8558
+ end
8559
+
8560
+ def to_json(as_json_options = {})
8561
+ require "json"
8562
+ JSON.dump(as_json(as_json_options))
8563
+ end
8305
8564
  end
8306
8565
  class DebugKillUnit
8307
8566
  def self.decode(buff)
@@ -8405,7 +8664,7 @@ module Api
8405
8664
 
8406
8665
  unknown_bytes = +"".b
8407
8666
  val = tag
8408
- while val != 0
8667
+ loop do
8409
8668
  byte = val & 0x7F
8410
8669
 
8411
8670
  val >>= 7
@@ -8416,6 +8675,7 @@ module Api
8416
8675
 
8417
8676
  byte |= 0x80 if val != 0
8418
8677
  unknown_bytes << byte
8678
+ break if val == 0
8419
8679
  end
8420
8680
 
8421
8681
  case wire_type
@@ -8490,7 +8750,7 @@ module Api
8490
8750
  end
8491
8751
 
8492
8752
  val = value
8493
- while val != 0
8753
+ loop do
8494
8754
  byte = val & 0x7F
8495
8755
 
8496
8756
  val >>= 7
@@ -8501,6 +8761,7 @@ module Api
8501
8761
 
8502
8762
  byte |= 0x80 if val != 0
8503
8763
  unknown_bytes << byte
8764
+ break if val == 0
8504
8765
  end
8505
8766
 
8506
8767
  unknown_bytes << buff.byteslice(index, value)
@@ -8700,11 +8961,12 @@ module Api
8700
8961
  if val != 0
8701
8962
  buff << 0x08
8702
8963
 
8703
- while val != 0
8964
+ loop do
8704
8965
  byte = val & 0x7F
8705
8966
  val >>= 7
8706
8967
  byte |= 0x80 if val > 0
8707
8968
  buff << byte
8969
+ break if val == 0
8708
8970
  end
8709
8971
  end
8710
8972
  end
@@ -8715,9 +8977,26 @@ module Api
8715
8977
 
8716
8978
  def to_h
8717
8979
  result = {}
8718
- result["tag".to_sym] = @tag
8980
+
8981
+ result[:"tag"] = @tag
8982
+
8983
+ result
8984
+ end
8985
+
8986
+ def as_json(options = {})
8987
+ result = {}
8988
+
8989
+ tmp_tag = @tag
8990
+
8991
+ result["tag"] = tmp_tag if !options[:compact] || tmp_tag.any?
8992
+
8719
8993
  result
8720
8994
  end
8995
+
8996
+ def to_json(as_json_options = {})
8997
+ require "json"
8998
+ JSON.dump(as_json(as_json_options))
8999
+ end
8721
9000
  end
8722
9001
  class DebugTestProcess
8723
9002
  def self.decode(buff)
@@ -8734,27 +9013,17 @@ module Api
8734
9013
  EXIT = 3
8735
9014
 
8736
9015
  def self.lookup(val)
8737
- if val == 0
8738
- :ENUM_TEST_UNSET
8739
- elsif val == 1
8740
- :HANG
8741
- elsif val == 2
8742
- :CRASH
8743
- elsif val == 3
8744
- :EXIT
8745
- end
9016
+ return :ENUM_TEST_UNSET if val == 0
9017
+ return :HANG if val == 1
9018
+ return :CRASH if val == 2
9019
+ return :EXIT if val == 3
8746
9020
  end
8747
9021
 
8748
9022
  def self.resolve(val)
8749
- if val == :ENUM_TEST_UNSET
8750
- 0
8751
- elsif val == :HANG
8752
- 1
8753
- elsif val == :CRASH
8754
- 2
8755
- elsif val == :EXIT
8756
- 3
8757
- end
9023
+ return 0 if val == :ENUM_TEST_UNSET
9024
+ return 1 if val == :HANG
9025
+ return 2 if val == :CRASH
9026
+ return 3 if val == :EXIT
8758
9027
  end
8759
9028
  end
8760
9029
  # required field readers
@@ -8770,6 +9039,7 @@ module Api
8770
9039
  # enum writers
8771
9040
  def test=(v)
8772
9041
  @test = Api::DebugTestProcess::Test.resolve(v) || v
9042
+ @_bitmask |= 0x0000000000000001
8773
9043
  end
8774
9044
 
8775
9045
  # BEGIN writers for optional fields
@@ -8811,6 +9081,10 @@ module Api
8811
9081
  self.class.encode(self)
8812
9082
  end
8813
9083
 
9084
+ def has_test?
9085
+ (@_bitmask & 0x0000000000000001) == 0x0000000000000001
9086
+ end
9087
+
8814
9088
  def has_delay_ms?
8815
9089
  (@_bitmask & 0x0000000000000002) == 0x0000000000000002
8816
9090
  end
@@ -8883,7 +9157,7 @@ module Api
8883
9157
 
8884
9158
  unknown_bytes = +"".b
8885
9159
  val = tag
8886
- while val != 0
9160
+ loop do
8887
9161
  byte = val & 0x7F
8888
9162
 
8889
9163
  val >>= 7
@@ -8894,6 +9168,7 @@ module Api
8894
9168
 
8895
9169
  byte |= 0x80 if val != 0
8896
9170
  unknown_bytes << byte
9171
+ break if val == 0
8897
9172
  end
8898
9173
 
8899
9174
  case wire_type
@@ -8968,7 +9243,7 @@ module Api
8968
9243
  end
8969
9244
 
8970
9245
  val = value
8971
- while val != 0
9246
+ loop do
8972
9247
  byte = val & 0x7F
8973
9248
 
8974
9249
  val >>= 7
@@ -8979,6 +9254,7 @@ module Api
8979
9254
 
8980
9255
  byte |= 0x80 if val != 0
8981
9256
  unknown_bytes << byte
9257
+ break if val == 0
8982
9258
  end
8983
9259
 
8984
9260
  unknown_bytes << buff.byteslice(index, value)
@@ -9291,10 +9567,10 @@ module Api
9291
9567
  end
9292
9568
  def _encode(buff)
9293
9569
  val = @test
9294
- if val != 0
9570
+ if has_test?
9295
9571
  buff << 0x08
9296
9572
 
9297
- while val != 0
9573
+ loop do
9298
9574
  byte = val & 0x7F
9299
9575
 
9300
9576
  val >>= 7
@@ -9305,14 +9581,15 @@ module Api
9305
9581
 
9306
9582
  byte |= 0x80 if val != 0
9307
9583
  buff << byte
9584
+ break if val == 0
9308
9585
  end
9309
9586
  end
9310
9587
 
9311
9588
  val = @delay_ms
9312
- if val != 0
9589
+ if has_delay_ms?
9313
9590
  buff << 0x10
9314
9591
 
9315
- while val != 0
9592
+ loop do
9316
9593
  byte = val & 0x7F
9317
9594
 
9318
9595
  val >>= 7
@@ -9323,6 +9600,7 @@ module Api
9323
9600
 
9324
9601
  byte |= 0x80 if val != 0
9325
9602
  buff << byte
9603
+ break if val == 0
9326
9604
  end
9327
9605
  end
9328
9606
  buff << @_unknown_fields if @_unknown_fields
@@ -9331,10 +9609,26 @@ module Api
9331
9609
 
9332
9610
  def to_h
9333
9611
  result = {}
9334
- result["test".to_sym] = @test
9335
- result["delay_ms".to_sym] = @delay_ms
9612
+
9613
+ result[:"test"] = @test
9614
+ result[:"delay_ms"] = @delay_ms
9615
+
9336
9616
  result
9337
9617
  end
9618
+
9619
+ def as_json(options = {})
9620
+ result = {}
9621
+
9622
+ result["test"] = @test if !options[:compact] || has_test?
9623
+ result["delayMs"] = @delay_ms if !options[:compact] || has_delay_ms?
9624
+
9625
+ result
9626
+ end
9627
+
9628
+ def to_json(as_json_options = {})
9629
+ require "json"
9630
+ JSON.dump(as_json(as_json_options))
9631
+ end
9338
9632
  end
9339
9633
  class DebugSetScore
9340
9634
  def self.decode(buff)
@@ -9444,7 +9738,7 @@ module Api
9444
9738
 
9445
9739
  unknown_bytes = +"".b
9446
9740
  val = tag
9447
- while val != 0
9741
+ loop do
9448
9742
  byte = val & 0x7F
9449
9743
 
9450
9744
  val >>= 7
@@ -9455,6 +9749,7 @@ module Api
9455
9749
 
9456
9750
  byte |= 0x80 if val != 0
9457
9751
  unknown_bytes << byte
9752
+ break if val == 0
9458
9753
  end
9459
9754
 
9460
9755
  case wire_type
@@ -9529,7 +9824,7 @@ module Api
9529
9824
  end
9530
9825
 
9531
9826
  val = value
9532
- while val != 0
9827
+ loop do
9533
9828
  byte = val & 0x7F
9534
9829
 
9535
9830
  val >>= 7
@@ -9540,6 +9835,7 @@ module Api
9540
9835
 
9541
9836
  byte |= 0x80 if val != 0
9542
9837
  unknown_bytes << byte
9838
+ break if val == 0
9543
9839
  end
9544
9840
 
9545
9841
  unknown_bytes << buff.byteslice(index, value)
@@ -9670,7 +9966,7 @@ module Api
9670
9966
  end
9671
9967
  def _encode(buff)
9672
9968
  val = @score
9673
- if val != 0
9969
+ if has_score?
9674
9970
  buff << 0x0d
9675
9971
 
9676
9972
  [val].pack("e", buffer: buff)
@@ -9681,9 +9977,24 @@ module Api
9681
9977
 
9682
9978
  def to_h
9683
9979
  result = {}
9684
- result["score".to_sym] = @score
9980
+
9981
+ result[:"score"] = @score
9982
+
9685
9983
  result
9686
9984
  end
9985
+
9986
+ def as_json(options = {})
9987
+ result = {}
9988
+
9989
+ result["score"] = @score if !options[:compact] || has_score?
9990
+
9991
+ result
9992
+ end
9993
+
9994
+ def to_json(as_json_options = {})
9995
+ require "json"
9996
+ JSON.dump(as_json(as_json_options))
9997
+ end
9687
9998
  end
9688
9999
  class DebugEndGame
9689
10000
  def self.decode(buff)
@@ -9699,23 +10010,15 @@ module Api
9699
10010
  DECLARE_VICTORY = 2
9700
10011
 
9701
10012
  def self.lookup(val)
9702
- if val == 0
9703
- :ENUM_END_RESULT_UNSET
9704
- elsif val == 1
9705
- :SURRENDER
9706
- elsif val == 2
9707
- :DECLARE_VICTORY
9708
- end
10013
+ return :ENUM_END_RESULT_UNSET if val == 0
10014
+ return :SURRENDER if val == 1
10015
+ return :DECLARE_VICTORY if val == 2
9709
10016
  end
9710
10017
 
9711
10018
  def self.resolve(val)
9712
- if val == :ENUM_END_RESULT_UNSET
9713
- 0
9714
- elsif val == :SURRENDER
9715
- 1
9716
- elsif val == :DECLARE_VICTORY
9717
- 2
9718
- end
10019
+ return 0 if val == :ENUM_END_RESULT_UNSET
10020
+ return 1 if val == :SURRENDER
10021
+ return 2 if val == :DECLARE_VICTORY
9719
10022
  end
9720
10023
  end
9721
10024
  # required field readers
@@ -9727,9 +10030,12 @@ module Api
9727
10030
  # enum writers
9728
10031
  def end_result=(v)
9729
10032
  @end_result = Api::DebugEndGame::EndResult.resolve(v) || v
10033
+ @_bitmask |= 0x0000000000000001
9730
10034
  end
9731
10035
 
9732
10036
  def initialize(end_result: nil)
10037
+ @_bitmask = 0
10038
+
9733
10039
  if end_result == nil
9734
10040
  @end_result = 0
9735
10041
  else
@@ -9743,7 +10049,13 @@ module Api
9743
10049
  self.class.encode(self)
9744
10050
  end
9745
10051
 
10052
+ def has_end_result?
10053
+ (@_bitmask & 0x0000000000000001) == 0x0000000000000001
10054
+ end
10055
+
9746
10056
  def decode_from(buff, index, len)
10057
+ @_bitmask = 0
10058
+
9747
10059
  @end_result = 0
9748
10060
 
9749
10061
  return self if index >= len
@@ -9808,7 +10120,7 @@ module Api
9808
10120
 
9809
10121
  unknown_bytes = +"".b
9810
10122
  val = tag
9811
- while val != 0
10123
+ loop do
9812
10124
  byte = val & 0x7F
9813
10125
 
9814
10126
  val >>= 7
@@ -9819,6 +10131,7 @@ module Api
9819
10131
 
9820
10132
  byte |= 0x80 if val != 0
9821
10133
  unknown_bytes << byte
10134
+ break if val == 0
9822
10135
  end
9823
10136
 
9824
10137
  case wire_type
@@ -9893,7 +10206,7 @@ module Api
9893
10206
  end
9894
10207
 
9895
10208
  val = value
9896
- while val != 0
10209
+ loop do
9897
10210
  byte = val & 0x7F
9898
10211
 
9899
10212
  val >>= 7
@@ -9904,6 +10217,7 @@ module Api
9904
10217
 
9905
10218
  byte |= 0x80 if val != 0
9906
10219
  unknown_bytes << byte
10220
+ break if val == 0
9907
10221
  end
9908
10222
 
9909
10223
  unknown_bytes << buff.byteslice(index, value)
@@ -10096,10 +10410,10 @@ module Api
10096
10410
  end
10097
10411
  def _encode(buff)
10098
10412
  val = @end_result
10099
- if val != 0
10413
+ if has_end_result?
10100
10414
  buff << 0x08
10101
10415
 
10102
- while val != 0
10416
+ loop do
10103
10417
  byte = val & 0x7F
10104
10418
 
10105
10419
  val >>= 7
@@ -10110,6 +10424,7 @@ module Api
10110
10424
 
10111
10425
  byte |= 0x80 if val != 0
10112
10426
  buff << byte
10427
+ break if val == 0
10113
10428
  end
10114
10429
  end
10115
10430
  buff << @_unknown_fields if @_unknown_fields
@@ -10118,9 +10433,24 @@ module Api
10118
10433
 
10119
10434
  def to_h
10120
10435
  result = {}
10121
- result["end_result".to_sym] = @end_result
10436
+
10437
+ result[:"end_result"] = @end_result
10438
+
10122
10439
  result
10123
10440
  end
10441
+
10442
+ def as_json(options = {})
10443
+ result = {}
10444
+
10445
+ result["endResult"] = @end_result if !options[:compact] || has_end_result?
10446
+
10447
+ result
10448
+ end
10449
+
10450
+ def to_json(as_json_options = {})
10451
+ require "json"
10452
+ JSON.dump(as_json(as_json_options))
10453
+ end
10124
10454
  end
10125
10455
  class DebugSetUnitValue
10126
10456
  def self.decode(buff)
@@ -10137,27 +10467,17 @@ module Api
10137
10467
  SHIELDS = 3
10138
10468
 
10139
10469
  def self.lookup(val)
10140
- if val == 0
10141
- :ENUM_UNIT_VALUE_UNSET
10142
- elsif val == 1
10143
- :ENERGY
10144
- elsif val == 2
10145
- :LIFE
10146
- elsif val == 3
10147
- :SHIELDS
10148
- end
10470
+ return :ENUM_UNIT_VALUE_UNSET if val == 0
10471
+ return :ENERGY if val == 1
10472
+ return :LIFE if val == 2
10473
+ return :SHIELDS if val == 3
10149
10474
  end
10150
10475
 
10151
10476
  def self.resolve(val)
10152
- if val == :ENUM_UNIT_VALUE_UNSET
10153
- 0
10154
- elsif val == :ENERGY
10155
- 1
10156
- elsif val == :LIFE
10157
- 2
10158
- elsif val == :SHIELDS
10159
- 3
10160
- end
10477
+ return 0 if val == :ENUM_UNIT_VALUE_UNSET
10478
+ return 1 if val == :ENERGY
10479
+ return 2 if val == :LIFE
10480
+ return 3 if val == :SHIELDS
10161
10481
  end
10162
10482
  end
10163
10483
  # required field readers
@@ -10175,6 +10495,7 @@ module Api
10175
10495
  # enum writers
10176
10496
  def unit_value=(v)
10177
10497
  @unit_value = Api::DebugSetUnitValue::UnitValue.resolve(v) || v
10498
+ @_bitmask |= 0x0000000000000001
10178
10499
  end
10179
10500
 
10180
10501
  # BEGIN writers for optional fields
@@ -10229,6 +10550,10 @@ module Api
10229
10550
  self.class.encode(self)
10230
10551
  end
10231
10552
 
10553
+ def has_unit_value?
10554
+ (@_bitmask & 0x0000000000000001) == 0x0000000000000001
10555
+ end
10556
+
10232
10557
  def has_value?
10233
10558
  (@_bitmask & 0x0000000000000002) == 0x0000000000000002
10234
10559
  end
@@ -10306,7 +10631,7 @@ module Api
10306
10631
 
10307
10632
  unknown_bytes = +"".b
10308
10633
  val = tag
10309
- while val != 0
10634
+ loop do
10310
10635
  byte = val & 0x7F
10311
10636
 
10312
10637
  val >>= 7
@@ -10317,6 +10642,7 @@ module Api
10317
10642
 
10318
10643
  byte |= 0x80 if val != 0
10319
10644
  unknown_bytes << byte
10645
+ break if val == 0
10320
10646
  end
10321
10647
 
10322
10648
  case wire_type
@@ -10391,7 +10717,7 @@ module Api
10391
10717
  end
10392
10718
 
10393
10719
  val = value
10394
- while val != 0
10720
+ loop do
10395
10721
  byte = val & 0x7F
10396
10722
 
10397
10723
  val >>= 7
@@ -10402,6 +10728,7 @@ module Api
10402
10728
 
10403
10729
  byte |= 0x80 if val != 0
10404
10730
  unknown_bytes << byte
10731
+ break if val == 0
10405
10732
  end
10406
10733
 
10407
10734
  unknown_bytes << buff.byteslice(index, value)
@@ -10760,10 +11087,10 @@ module Api
10760
11087
  end
10761
11088
  def _encode(buff)
10762
11089
  val = @unit_value
10763
- if val != 0
11090
+ if has_unit_value?
10764
11091
  buff << 0x08
10765
11092
 
10766
- while val != 0
11093
+ loop do
10767
11094
  byte = val & 0x7F
10768
11095
 
10769
11096
  val >>= 7
@@ -10774,25 +11101,27 @@ module Api
10774
11101
 
10775
11102
  byte |= 0x80 if val != 0
10776
11103
  buff << byte
11104
+ break if val == 0
10777
11105
  end
10778
11106
  end
10779
11107
 
10780
11108
  val = @value
10781
- if val != 0
11109
+ if has_value?
10782
11110
  buff << 0x15
10783
11111
 
10784
11112
  [val].pack("e", buffer: buff)
10785
11113
  end
10786
11114
 
10787
11115
  val = @unit_tag
10788
- if val != 0
11116
+ if has_unit_tag?
10789
11117
  buff << 0x18
10790
11118
 
10791
- while val != 0
11119
+ loop do
10792
11120
  byte = val & 0x7F
10793
11121
  val >>= 7
10794
11122
  byte |= 0x80 if val > 0
10795
11123
  buff << byte
11124
+ break if val == 0
10796
11125
  end
10797
11126
  end
10798
11127
  buff << @_unknown_fields if @_unknown_fields
@@ -10801,10 +11130,27 @@ module Api
10801
11130
 
10802
11131
  def to_h
10803
11132
  result = {}
10804
- result["unit_value".to_sym] = @unit_value
10805
- result["value".to_sym] = @value
10806
- result["unit_tag".to_sym] = @unit_tag
11133
+
11134
+ result[:"unit_value"] = @unit_value
11135
+ result[:"value"] = @value
11136
+ result[:"unit_tag"] = @unit_tag
11137
+
11138
+ result
11139
+ end
11140
+
11141
+ def as_json(options = {})
11142
+ result = {}
11143
+
11144
+ result["unitValue"] = @unit_value if !options[:compact] || has_unit_value?
11145
+ result["value"] = @value if !options[:compact] || has_value?
11146
+ result["unitTag"] = @unit_tag if !options[:compact] || has_unit_tag?
11147
+
10807
11148
  result
10808
11149
  end
11150
+
11151
+ def to_json(as_json_options = {})
11152
+ require "json"
11153
+ JSON.dump(as_json(as_json_options))
11154
+ end
10809
11155
  end
10810
11156
  end