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.
@@ -18,59 +18,33 @@ module Api
18
18
  SUMMONED = 11
19
19
 
20
20
  def self.lookup(val)
21
- if val == 0
22
- :ENUM_ATTRIBUTE_UNSET
23
- elsif val == 1
24
- :LIGHT
25
- elsif val == 2
26
- :ARMORED
27
- elsif val == 3
28
- :BIOLOGICAL
29
- elsif val == 4
30
- :MECHANICAL
31
- elsif val == 5
32
- :ROBOTIC
33
- elsif val == 6
34
- :PSIONIC
35
- elsif val == 7
36
- :MASSIVE
37
- elsif val == 8
38
- :STRUCTURE
39
- elsif val == 9
40
- :HOVER
41
- elsif val == 10
42
- :HEROIC
43
- elsif val == 11
44
- :SUMMONED
45
- end
21
+ return :ENUM_ATTRIBUTE_UNSET if val == 0
22
+ return :LIGHT if val == 1
23
+ return :ARMORED if val == 2
24
+ return :BIOLOGICAL if val == 3
25
+ return :MECHANICAL if val == 4
26
+ return :ROBOTIC if val == 5
27
+ return :PSIONIC if val == 6
28
+ return :MASSIVE if val == 7
29
+ return :STRUCTURE if val == 8
30
+ return :HOVER if val == 9
31
+ return :HEROIC if val == 10
32
+ return :SUMMONED if val == 11
46
33
  end
47
34
 
48
35
  def self.resolve(val)
49
- if val == :ENUM_ATTRIBUTE_UNSET
50
- 0
51
- elsif val == :LIGHT
52
- 1
53
- elsif val == :ARMORED
54
- 2
55
- elsif val == :BIOLOGICAL
56
- 3
57
- elsif val == :MECHANICAL
58
- 4
59
- elsif val == :ROBOTIC
60
- 5
61
- elsif val == :PSIONIC
62
- 6
63
- elsif val == :MASSIVE
64
- 7
65
- elsif val == :STRUCTURE
66
- 8
67
- elsif val == :HOVER
68
- 9
69
- elsif val == :HEROIC
70
- 10
71
- elsif val == :SUMMONED
72
- 11
73
- end
36
+ return 0 if val == :ENUM_ATTRIBUTE_UNSET
37
+ return 1 if val == :LIGHT
38
+ return 2 if val == :ARMORED
39
+ return 3 if val == :BIOLOGICAL
40
+ return 4 if val == :MECHANICAL
41
+ return 5 if val == :ROBOTIC
42
+ return 6 if val == :PSIONIC
43
+ return 7 if val == :MASSIVE
44
+ return 8 if val == :STRUCTURE
45
+ return 9 if val == :HOVER
46
+ return 10 if val == :HEROIC
47
+ return 11 if val == :SUMMONED
74
48
  end
75
49
  end
76
50
 
@@ -91,35 +65,21 @@ module Api
91
65
  POINT_OR_NONE = 5
92
66
 
93
67
  def self.lookup(val)
94
- if val == 0
95
- :ENUM_TARGET_UNSET
96
- elsif val == 1
97
- :NONE
98
- elsif val == 2
99
- :POINT
100
- elsif val == 3
101
- :UNIT
102
- elsif val == 4
103
- :POINT_OR_UNIT
104
- elsif val == 5
105
- :POINT_OR_NONE
106
- end
68
+ return :ENUM_TARGET_UNSET if val == 0
69
+ return :NONE if val == 1
70
+ return :POINT if val == 2
71
+ return :UNIT if val == 3
72
+ return :POINT_OR_UNIT if val == 4
73
+ return :POINT_OR_NONE if val == 5
107
74
  end
108
75
 
109
76
  def self.resolve(val)
110
- if val == :ENUM_TARGET_UNSET
111
- 0
112
- elsif val == :NONE
113
- 1
114
- elsif val == :POINT
115
- 2
116
- elsif val == :UNIT
117
- 3
118
- elsif val == :POINT_OR_UNIT
119
- 4
120
- elsif val == :POINT_OR_NONE
121
- 5
122
- end
77
+ return 0 if val == :ENUM_TARGET_UNSET
78
+ return 1 if val == :NONE
79
+ return 2 if val == :POINT
80
+ return 3 if val == :UNIT
81
+ return 4 if val == :POINT_OR_UNIT
82
+ return 5 if val == :POINT_OR_NONE
123
83
  end
124
84
  end
125
85
  # required field readers
@@ -161,6 +121,7 @@ module Api
161
121
  # enum writers
162
122
  def target=(v)
163
123
  @target = Api::AbilityData::Target.resolve(v) || v
124
+ @_bitmask |= 0x0000000000000100
164
125
  end
165
126
 
166
127
  # BEGIN writers for optional fields
@@ -425,6 +386,10 @@ module Api
425
386
  (@_bitmask & 0x0000000000000080) == 0x0000000000000080
426
387
  end
427
388
 
389
+ def has_target?
390
+ (@_bitmask & 0x0000000000000100) == 0x0000000000000100
391
+ end
392
+
428
393
  def has_allow_minimap?
429
394
  (@_bitmask & 0x0000000000000200) == 0x0000000000000200
430
395
  end
@@ -530,7 +495,7 @@ module Api
530
495
 
531
496
  unknown_bytes = +"".b
532
497
  val = tag
533
- while val != 0
498
+ loop do
534
499
  byte = val & 0x7F
535
500
 
536
501
  val >>= 7
@@ -541,6 +506,7 @@ module Api
541
506
 
542
507
  byte |= 0x80 if val != 0
543
508
  unknown_bytes << byte
509
+ break if val == 0
544
510
  end
545
511
 
546
512
  case wire_type
@@ -615,7 +581,7 @@ module Api
615
581
  end
616
582
 
617
583
  val = value
618
- while val != 0
584
+ loop do
619
585
  byte = val & 0x7F
620
586
 
621
587
  val >>= 7
@@ -626,6 +592,7 @@ module Api
626
592
 
627
593
  byte |= 0x80 if val != 0
628
594
  unknown_bytes << byte
595
+ break if val == 0
629
596
  end
630
597
 
631
598
  unknown_bytes << buff.byteslice(index, value)
@@ -2010,109 +1977,116 @@ module Api
2010
1977
  end
2011
1978
  def _encode(buff)
2012
1979
  val = @ability_id
2013
- if val != 0
1980
+ if has_ability_id?
2014
1981
  buff << 0x08
2015
1982
 
2016
- while val != 0
1983
+ loop do
2017
1984
  byte = val & 0x7F
2018
1985
  val >>= 7
2019
1986
  byte |= 0x80 if val > 0
2020
1987
  buff << byte
1988
+ break if val == 0
2021
1989
  end
2022
1990
  end
2023
1991
 
2024
1992
  val = @link_name
2025
- if ((len = val.bytesize) > 0)
1993
+ if (len = val.bytesize) > 0 || has_link_name?
2026
1994
  buff << 0x12
2027
- while len != 0
1995
+ loop do
2028
1996
  byte = len & 0x7F
2029
1997
  len >>= 7
2030
1998
  byte |= 0x80 if len > 0
2031
1999
  buff << byte
2000
+ break if len == 0
2032
2001
  end
2033
2002
 
2034
2003
  buff << (val.ascii_only? ? val : val.b)
2035
2004
  end
2036
2005
 
2037
2006
  val = @link_index
2038
- if val != 0
2007
+ if has_link_index?
2039
2008
  buff << 0x18
2040
2009
 
2041
- while val != 0
2010
+ loop do
2042
2011
  byte = val & 0x7F
2043
2012
  val >>= 7
2044
2013
  byte |= 0x80 if val > 0
2045
2014
  buff << byte
2015
+ break if val == 0
2046
2016
  end
2047
2017
  end
2048
2018
 
2049
2019
  val = @button_name
2050
- if ((len = val.bytesize) > 0)
2020
+ if (len = val.bytesize) > 0 || has_button_name?
2051
2021
  buff << 0x22
2052
- while len != 0
2022
+ loop do
2053
2023
  byte = len & 0x7F
2054
2024
  len >>= 7
2055
2025
  byte |= 0x80 if len > 0
2056
2026
  buff << byte
2027
+ break if len == 0
2057
2028
  end
2058
2029
 
2059
2030
  buff << (val.ascii_only? ? val : val.b)
2060
2031
  end
2061
2032
 
2062
2033
  val = @friendly_name
2063
- if ((len = val.bytesize) > 0)
2034
+ if (len = val.bytesize) > 0 || has_friendly_name?
2064
2035
  buff << 0x2a
2065
- while len != 0
2036
+ loop do
2066
2037
  byte = len & 0x7F
2067
2038
  len >>= 7
2068
2039
  byte |= 0x80 if len > 0
2069
2040
  buff << byte
2041
+ break if len == 0
2070
2042
  end
2071
2043
 
2072
2044
  buff << (val.ascii_only? ? val : val.b)
2073
2045
  end
2074
2046
 
2075
2047
  val = @hotkey
2076
- if ((len = val.bytesize) > 0)
2048
+ if (len = val.bytesize) > 0 || has_hotkey?
2077
2049
  buff << 0x32
2078
- while len != 0
2050
+ loop do
2079
2051
  byte = len & 0x7F
2080
2052
  len >>= 7
2081
2053
  byte |= 0x80 if len > 0
2082
2054
  buff << byte
2055
+ break if len == 0
2083
2056
  end
2084
2057
 
2085
2058
  buff << (val.ascii_only? ? val : val.b)
2086
2059
  end
2087
2060
 
2088
2061
  val = @remaps_to_ability_id
2089
- if val != 0
2062
+ if has_remaps_to_ability_id?
2090
2063
  buff << 0x38
2091
2064
 
2092
- while val != 0
2065
+ loop do
2093
2066
  byte = val & 0x7F
2094
2067
  val >>= 7
2095
2068
  byte |= 0x80 if val > 0
2096
2069
  buff << byte
2070
+ break if val == 0
2097
2071
  end
2098
2072
  end
2099
2073
 
2100
- val = @available
2101
- if val == true
2074
+ if has_available?
2075
+ val = @available
2102
2076
  buff << 0x40
2103
2077
 
2104
- buff << 1
2105
- elsif val == false
2106
- # Default value, encode nothing
2107
- else
2108
- raise "bool values should be true or false"
2078
+ if val == true
2079
+ buff << 1
2080
+ elsif val == false
2081
+ buff << 0
2082
+ end
2109
2083
  end
2110
2084
 
2111
2085
  val = @target
2112
- if val != 0
2086
+ if has_target?
2113
2087
  buff << 0x48
2114
2088
 
2115
- while val != 0
2089
+ loop do
2116
2090
  byte = val & 0x7F
2117
2091
 
2118
2092
  val >>= 7
@@ -2123,62 +2097,63 @@ module Api
2123
2097
 
2124
2098
  byte |= 0x80 if val != 0
2125
2099
  buff << byte
2100
+ break if val == 0
2126
2101
  end
2127
2102
  end
2128
2103
 
2129
- val = @allow_minimap
2130
- if val == true
2104
+ if has_allow_minimap?
2105
+ val = @allow_minimap
2131
2106
  buff << 0x50
2132
2107
 
2133
- buff << 1
2134
- elsif val == false
2135
- # Default value, encode nothing
2136
- else
2137
- raise "bool values should be true or false"
2108
+ if val == true
2109
+ buff << 1
2110
+ elsif val == false
2111
+ buff << 0
2112
+ end
2138
2113
  end
2139
2114
 
2140
- val = @allow_autocast
2141
- if val == true
2115
+ if has_allow_autocast?
2116
+ val = @allow_autocast
2142
2117
  buff << 0x58
2143
2118
 
2144
- buff << 1
2145
- elsif val == false
2146
- # Default value, encode nothing
2147
- else
2148
- raise "bool values should be true or false"
2119
+ if val == true
2120
+ buff << 1
2121
+ elsif val == false
2122
+ buff << 0
2123
+ end
2149
2124
  end
2150
2125
 
2151
- val = @is_building
2152
- if val == true
2126
+ if has_is_building?
2127
+ val = @is_building
2153
2128
  buff << 0x60
2154
2129
 
2155
- buff << 1
2156
- elsif val == false
2157
- # Default value, encode nothing
2158
- else
2159
- raise "bool values should be true or false"
2130
+ if val == true
2131
+ buff << 1
2132
+ elsif val == false
2133
+ buff << 0
2134
+ end
2160
2135
  end
2161
2136
 
2162
2137
  val = @footprint_radius
2163
- if val != 0
2138
+ if has_footprint_radius?
2164
2139
  buff << 0x6d
2165
2140
 
2166
2141
  [val].pack("e", buffer: buff)
2167
2142
  end
2168
2143
 
2169
- val = @is_instant_placement
2170
- if val == true
2144
+ if has_is_instant_placement?
2145
+ val = @is_instant_placement
2171
2146
  buff << 0x70
2172
2147
 
2173
- buff << 1
2174
- elsif val == false
2175
- # Default value, encode nothing
2176
- else
2177
- raise "bool values should be true or false"
2148
+ if val == true
2149
+ buff << 1
2150
+ elsif val == false
2151
+ buff << 0
2152
+ end
2178
2153
  end
2179
2154
 
2180
2155
  val = @cast_range
2181
- if val != 0
2156
+ if has_cast_range?
2182
2157
  buff << 0x7d
2183
2158
 
2184
2159
  [val].pack("e", buffer: buff)
@@ -2189,23 +2164,62 @@ module Api
2189
2164
 
2190
2165
  def to_h
2191
2166
  result = {}
2192
- result["ability_id".to_sym] = @ability_id
2193
- result["link_name".to_sym] = @link_name
2194
- result["link_index".to_sym] = @link_index
2195
- result["button_name".to_sym] = @button_name
2196
- result["friendly_name".to_sym] = @friendly_name
2197
- result["hotkey".to_sym] = @hotkey
2198
- result["remaps_to_ability_id".to_sym] = @remaps_to_ability_id
2199
- result["available".to_sym] = @available
2200
- result["target".to_sym] = @target
2201
- result["allow_minimap".to_sym] = @allow_minimap
2202
- result["allow_autocast".to_sym] = @allow_autocast
2203
- result["is_building".to_sym] = @is_building
2204
- result["footprint_radius".to_sym] = @footprint_radius
2205
- result["is_instant_placement".to_sym] = @is_instant_placement
2206
- result["cast_range".to_sym] = @cast_range
2167
+
2168
+ result[:"ability_id"] = @ability_id
2169
+ result[:"link_name"] = @link_name
2170
+ result[:"link_index"] = @link_index
2171
+ result[:"button_name"] = @button_name
2172
+ result[:"friendly_name"] = @friendly_name
2173
+ result[:"hotkey"] = @hotkey
2174
+ result[:"remaps_to_ability_id"] = @remaps_to_ability_id
2175
+ result[:"available"] = @available
2176
+ result[:"target"] = @target
2177
+ result[:"allow_minimap"] = @allow_minimap
2178
+ result[:"allow_autocast"] = @allow_autocast
2179
+ result[:"is_building"] = @is_building
2180
+ result[:"footprint_radius"] = @footprint_radius
2181
+ result[:"is_instant_placement"] = @is_instant_placement
2182
+ result[:"cast_range"] = @cast_range
2183
+
2184
+ result
2185
+ end
2186
+
2187
+ def as_json(options = {})
2188
+ result = {}
2189
+
2190
+ result["abilityId"] = @ability_id if !options[:compact] || has_ability_id?
2191
+ result["linkName"] = @link_name if !options[:compact] || has_link_name?
2192
+ result["linkIndex"] = @link_index if !options[:compact] || has_link_index?
2193
+ result["buttonName"] = @button_name if !options[:compact] ||
2194
+ has_button_name?
2195
+ result["friendlyName"] = @friendly_name if !options[:compact] ||
2196
+ has_friendly_name?
2197
+ result["hotkey"] = @hotkey if !options[:compact] || has_hotkey?
2198
+ result["remapsToAbilityId"] = @remaps_to_ability_id if !options[
2199
+ :compact
2200
+ ] || has_remaps_to_ability_id?
2201
+ result["available"] = @available if !options[:compact] || has_available?
2202
+ result["target"] = @target if !options[:compact] || has_target?
2203
+ result["allowMinimap"] = @allow_minimap if !options[:compact] ||
2204
+ has_allow_minimap?
2205
+ result["allowAutocast"] = @allow_autocast if !options[:compact] ||
2206
+ has_allow_autocast?
2207
+ result["isBuilding"] = @is_building if !options[:compact] ||
2208
+ has_is_building?
2209
+ result["footprintRadius"] = @footprint_radius if !options[:compact] ||
2210
+ has_footprint_radius?
2211
+ result["isInstantPlacement"] = @is_instant_placement if !options[
2212
+ :compact
2213
+ ] || has_is_instant_placement?
2214
+ result["castRange"] = @cast_range if !options[:compact] || has_cast_range?
2215
+
2207
2216
  result
2208
2217
  end
2218
+
2219
+ def to_json(as_json_options = {})
2220
+ require "json"
2221
+ JSON.dump(as_json(as_json_options))
2222
+ end
2209
2223
  end
2210
2224
  class DamageBonus
2211
2225
  def self.decode(buff)
@@ -2228,6 +2242,7 @@ module Api
2228
2242
  # enum writers
2229
2243
  def attribute=(v)
2230
2244
  @attribute = Api::Attribute.resolve(v) || v
2245
+ @_bitmask |= 0x0000000000000001
2231
2246
  end
2232
2247
 
2233
2248
  # BEGIN writers for optional fields
@@ -2260,6 +2275,10 @@ module Api
2260
2275
  self.class.encode(self)
2261
2276
  end
2262
2277
 
2278
+ def has_attribute?
2279
+ (@_bitmask & 0x0000000000000001) == 0x0000000000000001
2280
+ end
2281
+
2263
2282
  def has_bonus?
2264
2283
  (@_bitmask & 0x0000000000000002) == 0x0000000000000002
2265
2284
  end
@@ -2332,7 +2351,7 @@ module Api
2332
2351
 
2333
2352
  unknown_bytes = +"".b
2334
2353
  val = tag
2335
- while val != 0
2354
+ loop do
2336
2355
  byte = val & 0x7F
2337
2356
 
2338
2357
  val >>= 7
@@ -2343,6 +2362,7 @@ module Api
2343
2362
 
2344
2363
  byte |= 0x80 if val != 0
2345
2364
  unknown_bytes << byte
2365
+ break if val == 0
2346
2366
  end
2347
2367
 
2348
2368
  case wire_type
@@ -2417,7 +2437,7 @@ module Api
2417
2437
  end
2418
2438
 
2419
2439
  val = value
2420
- while val != 0
2440
+ loop do
2421
2441
  byte = val & 0x7F
2422
2442
 
2423
2443
  val >>= 7
@@ -2428,6 +2448,7 @@ module Api
2428
2448
 
2429
2449
  byte |= 0x80 if val != 0
2430
2450
  unknown_bytes << byte
2451
+ break if val == 0
2431
2452
  end
2432
2453
 
2433
2454
  unknown_bytes << buff.byteslice(index, value)
@@ -2678,10 +2699,10 @@ module Api
2678
2699
  end
2679
2700
  def _encode(buff)
2680
2701
  val = @attribute
2681
- if val != 0
2702
+ if has_attribute?
2682
2703
  buff << 0x08
2683
2704
 
2684
- while val != 0
2705
+ loop do
2685
2706
  byte = val & 0x7F
2686
2707
 
2687
2708
  val >>= 7
@@ -2692,11 +2713,12 @@ module Api
2692
2713
 
2693
2714
  byte |= 0x80 if val != 0
2694
2715
  buff << byte
2716
+ break if val == 0
2695
2717
  end
2696
2718
  end
2697
2719
 
2698
2720
  val = @bonus
2699
- if val != 0
2721
+ if has_bonus?
2700
2722
  buff << 0x15
2701
2723
 
2702
2724
  [val].pack("e", buffer: buff)
@@ -2707,10 +2729,26 @@ module Api
2707
2729
 
2708
2730
  def to_h
2709
2731
  result = {}
2710
- result["attribute".to_sym] = @attribute
2711
- result["bonus".to_sym] = @bonus
2732
+
2733
+ result[:"attribute"] = @attribute
2734
+ result[:"bonus"] = @bonus
2735
+
2736
+ result
2737
+ end
2738
+
2739
+ def as_json(options = {})
2740
+ result = {}
2741
+
2742
+ result["attribute"] = @attribute if !options[:compact] || has_attribute?
2743
+ result["bonus"] = @bonus if !options[:compact] || has_bonus?
2744
+
2712
2745
  result
2713
2746
  end
2747
+
2748
+ def to_json(as_json_options = {})
2749
+ require "json"
2750
+ JSON.dump(as_json(as_json_options))
2751
+ end
2714
2752
  end
2715
2753
  class Weapon
2716
2754
  def self.decode(buff)
@@ -2727,27 +2765,17 @@ module Api
2727
2765
  ANY = 3
2728
2766
 
2729
2767
  def self.lookup(val)
2730
- if val == 0
2731
- :ENUM_TARGET_TYPE_UNSET
2732
- elsif val == 1
2733
- :GROUND
2734
- elsif val == 2
2735
- :AIR
2736
- elsif val == 3
2737
- :ANY
2738
- end
2768
+ return :ENUM_TARGET_TYPE_UNSET if val == 0
2769
+ return :GROUND if val == 1
2770
+ return :AIR if val == 2
2771
+ return :ANY if val == 3
2739
2772
  end
2740
2773
 
2741
2774
  def self.resolve(val)
2742
- if val == :ENUM_TARGET_TYPE_UNSET
2743
- 0
2744
- elsif val == :GROUND
2745
- 1
2746
- elsif val == :AIR
2747
- 2
2748
- elsif val == :ANY
2749
- 3
2750
- end
2775
+ return 0 if val == :ENUM_TARGET_TYPE_UNSET
2776
+ return 1 if val == :GROUND
2777
+ return 2 if val == :AIR
2778
+ return 3 if val == :ANY
2751
2779
  end
2752
2780
  end
2753
2781
  # required field readers
@@ -2775,6 +2803,7 @@ module Api
2775
2803
  # enum writers
2776
2804
  def type=(v)
2777
2805
  @type = Api::Weapon::TargetType.resolve(v) || v
2806
+ @_bitmask |= 0x0000000000000001
2778
2807
  end
2779
2808
 
2780
2809
  # BEGIN writers for optional fields
@@ -2861,6 +2890,10 @@ module Api
2861
2890
  self.class.encode(self)
2862
2891
  end
2863
2892
 
2893
+ def has_type?
2894
+ (@_bitmask & 0x0000000000000001) == 0x0000000000000001
2895
+ end
2896
+
2864
2897
  def has_damage?
2865
2898
  (@_bitmask & 0x0000000000000002) == 0x0000000000000002
2866
2899
  end
@@ -2949,7 +2982,7 @@ module Api
2949
2982
 
2950
2983
  unknown_bytes = +"".b
2951
2984
  val = tag
2952
- while val != 0
2985
+ loop do
2953
2986
  byte = val & 0x7F
2954
2987
 
2955
2988
  val >>= 7
@@ -2960,6 +2993,7 @@ module Api
2960
2993
 
2961
2994
  byte |= 0x80 if val != 0
2962
2995
  unknown_bytes << byte
2996
+ break if val == 0
2963
2997
  end
2964
2998
 
2965
2999
  case wire_type
@@ -3034,7 +3068,7 @@ module Api
3034
3068
  end
3035
3069
 
3036
3070
  val = value
3037
- while val != 0
3071
+ loop do
3038
3072
  byte = val & 0x7F
3039
3073
 
3040
3074
  val >>= 7
@@ -3045,6 +3079,7 @@ module Api
3045
3079
 
3046
3080
  byte |= 0x80 if val != 0
3047
3081
  unknown_bytes << byte
3082
+ break if val == 0
3048
3083
  end
3049
3084
 
3050
3085
  unknown_bytes << buff.byteslice(index, value)
@@ -3655,10 +3690,10 @@ module Api
3655
3690
  end
3656
3691
  def _encode(buff)
3657
3692
  val = @type
3658
- if val != 0
3693
+ if has_type?
3659
3694
  buff << 0x08
3660
3695
 
3661
- while val != 0
3696
+ loop do
3662
3697
  byte = val & 0x7F
3663
3698
 
3664
3699
  val >>= 7
@@ -3669,11 +3704,12 @@ module Api
3669
3704
 
3670
3705
  byte |= 0x80 if val != 0
3671
3706
  buff << byte
3707
+ break if val == 0
3672
3708
  end
3673
3709
  end
3674
3710
 
3675
3711
  val = @damage
3676
- if val != 0
3712
+ if has_damage?
3677
3713
  buff << 0x15
3678
3714
 
3679
3715
  [val].pack("e", buffer: buff)
@@ -3733,26 +3769,27 @@ module Api
3733
3769
  end
3734
3770
 
3735
3771
  val = @attacks
3736
- if val != 0
3772
+ if has_attacks?
3737
3773
  buff << 0x20
3738
3774
 
3739
- while val != 0
3775
+ loop do
3740
3776
  byte = val & 0x7F
3741
3777
  val >>= 7
3742
3778
  byte |= 0x80 if val > 0
3743
3779
  buff << byte
3780
+ break if val == 0
3744
3781
  end
3745
3782
  end
3746
3783
 
3747
3784
  val = @range
3748
- if val != 0
3785
+ if has_range?
3749
3786
  buff << 0x2d
3750
3787
 
3751
3788
  [val].pack("e", buffer: buff)
3752
3789
  end
3753
3790
 
3754
3791
  val = @speed
3755
- if val != 0
3792
+ if has_speed?
3756
3793
  buff << 0x35
3757
3794
 
3758
3795
  [val].pack("e", buffer: buff)
@@ -3763,14 +3800,38 @@ module Api
3763
3800
 
3764
3801
  def to_h
3765
3802
  result = {}
3766
- result["type".to_sym] = @type
3767
- result["damage".to_sym] = @damage
3768
- result["damage_bonus".to_sym] = @damage_bonus
3769
- result["attacks".to_sym] = @attacks
3770
- result["range".to_sym] = @range
3771
- result["speed".to_sym] = @speed
3803
+
3804
+ result[:"type"] = @type
3805
+ result[:"damage"] = @damage
3806
+ result[:"damage_bonus"] = @damage_bonus.map(&:to_h)
3807
+ result[:"attacks"] = @attacks
3808
+ result[:"range"] = @range
3809
+ result[:"speed"] = @speed
3810
+
3811
+ result
3812
+ end
3813
+
3814
+ def as_json(options = {})
3815
+ result = {}
3816
+
3817
+ result["type"] = @type if !options[:compact] || has_type?
3818
+ result["damage"] = @damage if !options[:compact] || has_damage?
3819
+ tmp_damage_bonus = @damage_bonus.map { |v| v.as_json(options) }
3820
+
3821
+ result["damageBonus"] = tmp_damage_bonus if !options[:compact] ||
3822
+ tmp_damage_bonus.any?
3823
+
3824
+ result["attacks"] = @attacks if !options[:compact] || has_attacks?
3825
+ result["range"] = @range if !options[:compact] || has_range?
3826
+ result["speed"] = @speed if !options[:compact] || has_speed?
3827
+
3772
3828
  result
3773
3829
  end
3830
+
3831
+ def to_json(as_json_options = {})
3832
+ require "json"
3833
+ JSON.dump(as_json(as_json_options))
3834
+ end
3774
3835
  end
3775
3836
  class UnitTypeData
3776
3837
  def self.decode(buff)
@@ -3849,6 +3910,7 @@ module Api
3849
3910
  # enum writers
3850
3911
  def race=(v)
3851
3912
  @race = Api::Race.resolve(v) || v
3913
+ @_bitmask |= 0x0000000000000200
3852
3914
  end
3853
3915
  def attributes=(v)
3854
3916
  @attributes = Api::Attribute.resolve(v) || v
@@ -4221,6 +4283,10 @@ module Api
4221
4283
  (@_bitmask & 0x0000000000000100) == 0x0000000000000100
4222
4284
  end
4223
4285
 
4286
+ def has_race?
4287
+ (@_bitmask & 0x0000000000000200) == 0x0000000000000200
4288
+ end
4289
+
4224
4290
  def has_build_time?
4225
4291
  (@_bitmask & 0x0000000000000400) == 0x0000000000000400
4226
4292
  end
@@ -4345,7 +4411,7 @@ module Api
4345
4411
 
4346
4412
  unknown_bytes = +"".b
4347
4413
  val = tag
4348
- while val != 0
4414
+ loop do
4349
4415
  byte = val & 0x7F
4350
4416
 
4351
4417
  val >>= 7
@@ -4356,6 +4422,7 @@ module Api
4356
4422
 
4357
4423
  byte |= 0x80 if val != 0
4358
4424
  unknown_bytes << byte
4425
+ break if val == 0
4359
4426
  end
4360
4427
 
4361
4428
  case wire_type
@@ -4430,7 +4497,7 @@ module Api
4430
4497
  end
4431
4498
 
4432
4499
  val = value
4433
- while val != 0
4500
+ loop do
4434
4501
  byte = val & 0x7F
4435
4502
 
4436
4503
  val >>= 7
@@ -4441,6 +4508,7 @@ module Api
4441
4508
 
4442
4509
  byte |= 0x80 if val != 0
4443
4510
  unknown_bytes << byte
4511
+ break if val == 0
4444
4512
  end
4445
4513
 
4446
4514
  unknown_bytes << buff.byteslice(index, value)
@@ -6482,86 +6550,91 @@ module Api
6482
6550
  end
6483
6551
  def _encode(buff)
6484
6552
  val = @unit_id
6485
- if val != 0
6553
+ if has_unit_id?
6486
6554
  buff << 0x08
6487
6555
 
6488
- while val != 0
6556
+ loop do
6489
6557
  byte = val & 0x7F
6490
6558
  val >>= 7
6491
6559
  byte |= 0x80 if val > 0
6492
6560
  buff << byte
6561
+ break if val == 0
6493
6562
  end
6494
6563
  end
6495
6564
 
6496
6565
  val = @name
6497
- if ((len = val.bytesize) > 0)
6566
+ if (len = val.bytesize) > 0 || has_name?
6498
6567
  buff << 0x12
6499
- while len != 0
6568
+ loop do
6500
6569
  byte = len & 0x7F
6501
6570
  len >>= 7
6502
6571
  byte |= 0x80 if len > 0
6503
6572
  buff << byte
6573
+ break if len == 0
6504
6574
  end
6505
6575
 
6506
6576
  buff << (val.ascii_only? ? val : val.b)
6507
6577
  end
6508
6578
 
6509
- val = @available
6510
- if val == true
6579
+ if has_available?
6580
+ val = @available
6511
6581
  buff << 0x18
6512
6582
 
6513
- buff << 1
6514
- elsif val == false
6515
- # Default value, encode nothing
6516
- else
6517
- raise "bool values should be true or false"
6583
+ if val == true
6584
+ buff << 1
6585
+ elsif val == false
6586
+ buff << 0
6587
+ end
6518
6588
  end
6519
6589
 
6520
6590
  val = @cargo_size
6521
- if val != 0
6591
+ if has_cargo_size?
6522
6592
  buff << 0x20
6523
6593
 
6524
- while val != 0
6594
+ loop do
6525
6595
  byte = val & 0x7F
6526
6596
  val >>= 7
6527
6597
  byte |= 0x80 if val > 0
6528
6598
  buff << byte
6599
+ break if val == 0
6529
6600
  end
6530
6601
  end
6531
6602
 
6532
6603
  val = @mineral_cost
6533
- if val != 0
6604
+ if has_mineral_cost?
6534
6605
  buff << 0x60
6535
6606
 
6536
- while val != 0
6607
+ loop do
6537
6608
  byte = val & 0x7F
6538
6609
  val >>= 7
6539
6610
  byte |= 0x80 if val > 0
6540
6611
  buff << byte
6612
+ break if val == 0
6541
6613
  end
6542
6614
  end
6543
6615
 
6544
6616
  val = @vespene_cost
6545
- if val != 0
6617
+ if has_vespene_cost?
6546
6618
  buff << 0x68
6547
6619
 
6548
- while val != 0
6620
+ loop do
6549
6621
  byte = val & 0x7F
6550
6622
  val >>= 7
6551
6623
  byte |= 0x80 if val > 0
6552
6624
  buff << byte
6625
+ break if val == 0
6553
6626
  end
6554
6627
  end
6555
6628
 
6556
6629
  val = @food_required
6557
- if val != 0
6630
+ if has_food_required?
6558
6631
  buff << 0x75
6559
6632
 
6560
6633
  [val].pack("e", buffer: buff)
6561
6634
  end
6562
6635
 
6563
6636
  val = @food_provided
6564
- if val != 0
6637
+ if has_food_provided?
6565
6638
  buff << 0x95
6566
6639
  buff << 0x01
6567
6640
 
@@ -6569,23 +6642,24 @@ module Api
6569
6642
  end
6570
6643
 
6571
6644
  val = @ability_id
6572
- if val != 0
6645
+ if has_ability_id?
6573
6646
  buff << 0x78
6574
6647
 
6575
- while val != 0
6648
+ loop do
6576
6649
  byte = val & 0x7F
6577
6650
  val >>= 7
6578
6651
  byte |= 0x80 if val > 0
6579
6652
  buff << byte
6653
+ break if val == 0
6580
6654
  end
6581
6655
  end
6582
6656
 
6583
6657
  val = @race
6584
- if val != 0
6658
+ if has_race?
6585
6659
  buff << 0x80
6586
6660
  buff << 0x01
6587
6661
 
6588
- while val != 0
6662
+ loop do
6589
6663
  byte = val & 0x7F
6590
6664
 
6591
6665
  val >>= 7
@@ -6596,43 +6670,44 @@ module Api
6596
6670
 
6597
6671
  byte |= 0x80 if val != 0
6598
6672
  buff << byte
6673
+ break if val == 0
6599
6674
  end
6600
6675
  end
6601
6676
 
6602
6677
  val = @build_time
6603
- if val != 0
6678
+ if has_build_time?
6604
6679
  buff << 0x8d
6605
6680
  buff << 0x01
6606
6681
 
6607
6682
  [val].pack("e", buffer: buff)
6608
6683
  end
6609
6684
 
6610
- val = @has_vespene
6611
- if val == true
6685
+ if has_has_vespene?
6686
+ val = @has_vespene
6612
6687
  buff << 0x98
6613
6688
  buff << 0x01
6614
6689
 
6615
- buff << 1
6616
- elsif val == false
6617
- # Default value, encode nothing
6618
- else
6619
- raise "bool values should be true or false"
6690
+ if val == true
6691
+ buff << 1
6692
+ elsif val == false
6693
+ buff << 0
6694
+ end
6620
6695
  end
6621
6696
 
6622
- val = @has_minerals
6623
- if val == true
6697
+ if has_has_minerals?
6698
+ val = @has_minerals
6624
6699
  buff << 0xa0
6625
6700
  buff << 0x01
6626
6701
 
6627
- buff << 1
6628
- elsif val == false
6629
- # Default value, encode nothing
6630
- else
6631
- raise "bool values should be true or false"
6702
+ if val == true
6703
+ buff << 1
6704
+ elsif val == false
6705
+ buff << 0
6706
+ end
6632
6707
  end
6633
6708
 
6634
6709
  val = @sight_range
6635
- if val != 0
6710
+ if has_sight_range?
6636
6711
  buff << 0xcd
6637
6712
  buff << 0x01
6638
6713
 
@@ -6647,52 +6722,55 @@ module Api
6647
6722
  buff << 0xa8
6648
6723
  buff << 0x01
6649
6724
 
6650
- while val != 0
6725
+ loop do
6651
6726
  byte = val & 0x7F
6652
6727
  val >>= 7
6653
6728
  byte |= 0x80 if val > 0
6654
6729
  buff << byte
6730
+ break if val == 0
6655
6731
  end
6656
6732
  end
6657
6733
  end
6658
6734
  end
6659
6735
 
6660
6736
  val = @unit_alias
6661
- if val != 0
6737
+ if has_unit_alias?
6662
6738
  buff << 0xb0
6663
6739
  buff << 0x01
6664
6740
 
6665
- while val != 0
6741
+ loop do
6666
6742
  byte = val & 0x7F
6667
6743
  val >>= 7
6668
6744
  byte |= 0x80 if val > 0
6669
6745
  buff << byte
6746
+ break if val == 0
6670
6747
  end
6671
6748
  end
6672
6749
 
6673
6750
  val = @tech_requirement
6674
- if val != 0
6751
+ if has_tech_requirement?
6675
6752
  buff << 0xb8
6676
6753
  buff << 0x01
6677
6754
 
6678
- while val != 0
6755
+ loop do
6679
6756
  byte = val & 0x7F
6680
6757
  val >>= 7
6681
6758
  byte |= 0x80 if val > 0
6682
6759
  buff << byte
6760
+ break if val == 0
6683
6761
  end
6684
6762
  end
6685
6763
 
6686
- val = @require_attached
6687
- if val == true
6764
+ if has_require_attached?
6765
+ val = @require_attached
6688
6766
  buff << 0xc0
6689
6767
  buff << 0x01
6690
6768
 
6691
- buff << 1
6692
- elsif val == false
6693
- # Default value, encode nothing
6694
- else
6695
- raise "bool values should be true or false"
6769
+ if val == true
6770
+ buff << 1
6771
+ elsif val == false
6772
+ buff << 0
6773
+ end
6696
6774
  end
6697
6775
 
6698
6776
  list = @attributes
@@ -6702,7 +6780,7 @@ module Api
6702
6780
  if val != 0
6703
6781
  buff << 0x40
6704
6782
 
6705
- while val != 0
6783
+ loop do
6706
6784
  byte = val & 0x7F
6707
6785
 
6708
6786
  val >>= 7
@@ -6713,20 +6791,21 @@ module Api
6713
6791
 
6714
6792
  byte |= 0x80 if val != 0
6715
6793
  buff << byte
6794
+ break if val == 0
6716
6795
  end
6717
6796
  end
6718
6797
  end
6719
6798
  end
6720
6799
 
6721
6800
  val = @movement_speed
6722
- if val != 0
6801
+ if has_movement_speed?
6723
6802
  buff << 0x4d
6724
6803
 
6725
6804
  [val].pack("e", buffer: buff)
6726
6805
  end
6727
6806
 
6728
6807
  val = @armor
6729
- if val != 0
6808
+ if has_armor?
6730
6809
  buff << 0x55
6731
6810
 
6732
6811
  [val].pack("e", buffer: buff)
@@ -6790,30 +6869,87 @@ module Api
6790
6869
 
6791
6870
  def to_h
6792
6871
  result = {}
6793
- result["unit_id".to_sym] = @unit_id
6794
- result["name".to_sym] = @name
6795
- result["available".to_sym] = @available
6796
- result["cargo_size".to_sym] = @cargo_size
6797
- result["mineral_cost".to_sym] = @mineral_cost
6798
- result["vespene_cost".to_sym] = @vespene_cost
6799
- result["food_required".to_sym] = @food_required
6800
- result["food_provided".to_sym] = @food_provided
6801
- result["ability_id".to_sym] = @ability_id
6802
- result["race".to_sym] = @race
6803
- result["build_time".to_sym] = @build_time
6804
- result["has_vespene".to_sym] = @has_vespene
6805
- result["has_minerals".to_sym] = @has_minerals
6806
- result["sight_range".to_sym] = @sight_range
6807
- result["tech_alias".to_sym] = @tech_alias
6808
- result["unit_alias".to_sym] = @unit_alias
6809
- result["tech_requirement".to_sym] = @tech_requirement
6810
- result["require_attached".to_sym] = @require_attached
6811
- result["attributes".to_sym] = @attributes
6812
- result["movement_speed".to_sym] = @movement_speed
6813
- result["armor".to_sym] = @armor
6814
- result["weapons".to_sym] = @weapons
6872
+
6873
+ result[:"unit_id"] = @unit_id
6874
+ result[:"name"] = @name
6875
+ result[:"available"] = @available
6876
+ result[:"cargo_size"] = @cargo_size
6877
+ result[:"attributes"] = @attributes
6878
+ result[:"movement_speed"] = @movement_speed
6879
+ result[:"armor"] = @armor
6880
+ result[:"weapons"] = @weapons.map(&:to_h)
6881
+ result[:"mineral_cost"] = @mineral_cost
6882
+ result[:"vespene_cost"] = @vespene_cost
6883
+ result[:"food_required"] = @food_required
6884
+ result[:"ability_id"] = @ability_id
6885
+ result[:"race"] = @race
6886
+ result[:"build_time"] = @build_time
6887
+ result[:"food_provided"] = @food_provided
6888
+ result[:"has_vespene"] = @has_vespene
6889
+ result[:"has_minerals"] = @has_minerals
6890
+ result[:"tech_alias"] = @tech_alias
6891
+ result[:"unit_alias"] = @unit_alias
6892
+ result[:"tech_requirement"] = @tech_requirement
6893
+ result[:"require_attached"] = @require_attached
6894
+ result[:"sight_range"] = @sight_range
6895
+
6896
+ result
6897
+ end
6898
+
6899
+ def as_json(options = {})
6900
+ result = {}
6901
+
6902
+ result["unitId"] = @unit_id if !options[:compact] || has_unit_id?
6903
+ result["name"] = @name if !options[:compact] || has_name?
6904
+ result["available"] = @available if !options[:compact] || has_available?
6905
+ result["cargoSize"] = @cargo_size if !options[:compact] || has_cargo_size?
6906
+ tmp_attributes = @attributes
6907
+
6908
+ result["attributes"] = tmp_attributes if !options[:compact] ||
6909
+ tmp_attributes.any?
6910
+
6911
+ result["movementSpeed"] = @movement_speed if !options[:compact] ||
6912
+ has_movement_speed?
6913
+ result["armor"] = @armor if !options[:compact] || has_armor?
6914
+ tmp_weapons = @weapons.map { |v| v.as_json(options) }
6915
+
6916
+ result["weapons"] = tmp_weapons if !options[:compact] || tmp_weapons.any?
6917
+
6918
+ result["mineralCost"] = @mineral_cost if !options[:compact] ||
6919
+ has_mineral_cost?
6920
+ result["vespeneCost"] = @vespene_cost if !options[:compact] ||
6921
+ has_vespene_cost?
6922
+ result["foodRequired"] = @food_required if !options[:compact] ||
6923
+ has_food_required?
6924
+ result["abilityId"] = @ability_id if !options[:compact] || has_ability_id?
6925
+ result["race"] = @race if !options[:compact] || has_race?
6926
+ result["buildTime"] = @build_time if !options[:compact] || has_build_time?
6927
+ result["foodProvided"] = @food_provided if !options[:compact] ||
6928
+ has_food_provided?
6929
+ result["hasVespene"] = @has_vespene if !options[:compact] ||
6930
+ has_has_vespene?
6931
+ result["hasMinerals"] = @has_minerals if !options[:compact] ||
6932
+ has_has_minerals?
6933
+ tmp_tech_alias = @tech_alias
6934
+
6935
+ result["techAlias"] = tmp_tech_alias if !options[:compact] ||
6936
+ tmp_tech_alias.any?
6937
+
6938
+ result["unitAlias"] = @unit_alias if !options[:compact] || has_unit_alias?
6939
+ result["techRequirement"] = @tech_requirement if !options[:compact] ||
6940
+ has_tech_requirement?
6941
+ result["requireAttached"] = @require_attached if !options[:compact] ||
6942
+ has_require_attached?
6943
+ result["sightRange"] = @sight_range if !options[:compact] ||
6944
+ has_sight_range?
6945
+
6815
6946
  result
6816
6947
  end
6948
+
6949
+ def to_json(as_json_options = {})
6950
+ require "json"
6951
+ JSON.dump(as_json(as_json_options))
6952
+ end
6817
6953
  end
6818
6954
  class UpgradeData
6819
6955
  def self.decode(buff)
@@ -7061,7 +7197,7 @@ module Api
7061
7197
 
7062
7198
  unknown_bytes = +"".b
7063
7199
  val = tag
7064
- while val != 0
7200
+ loop do
7065
7201
  byte = val & 0x7F
7066
7202
 
7067
7203
  val >>= 7
@@ -7072,6 +7208,7 @@ module Api
7072
7208
 
7073
7209
  byte |= 0x80 if val != 0
7074
7210
  unknown_bytes << byte
7211
+ break if val == 0
7075
7212
  end
7076
7213
 
7077
7214
  case wire_type
@@ -7146,7 +7283,7 @@ module Api
7146
7283
  end
7147
7284
 
7148
7285
  val = value
7149
- while val != 0
7286
+ loop do
7150
7287
  byte = val & 0x7F
7151
7288
 
7152
7289
  val >>= 7
@@ -7157,6 +7294,7 @@ module Api
7157
7294
 
7158
7295
  byte |= 0x80 if val != 0
7159
7296
  unknown_bytes << byte
7297
+ break if val == 0
7160
7298
  end
7161
7299
 
7162
7300
  unknown_bytes << buff.byteslice(index, value)
@@ -7830,70 +7968,75 @@ module Api
7830
7968
  end
7831
7969
  def _encode(buff)
7832
7970
  val = @upgrade_id
7833
- if val != 0
7971
+ if has_upgrade_id?
7834
7972
  buff << 0x08
7835
7973
 
7836
- while val != 0
7974
+ loop do
7837
7975
  byte = val & 0x7F
7838
7976
  val >>= 7
7839
7977
  byte |= 0x80 if val > 0
7840
7978
  buff << byte
7979
+ break if val == 0
7841
7980
  end
7842
7981
  end
7843
7982
 
7844
7983
  val = @name
7845
- if ((len = val.bytesize) > 0)
7984
+ if (len = val.bytesize) > 0 || has_name?
7846
7985
  buff << 0x12
7847
- while len != 0
7986
+ loop do
7848
7987
  byte = len & 0x7F
7849
7988
  len >>= 7
7850
7989
  byte |= 0x80 if len > 0
7851
7990
  buff << byte
7991
+ break if len == 0
7852
7992
  end
7853
7993
 
7854
7994
  buff << (val.ascii_only? ? val : val.b)
7855
7995
  end
7856
7996
 
7857
7997
  val = @mineral_cost
7858
- if val != 0
7998
+ if has_mineral_cost?
7859
7999
  buff << 0x18
7860
8000
 
7861
- while val != 0
8001
+ loop do
7862
8002
  byte = val & 0x7F
7863
8003
  val >>= 7
7864
8004
  byte |= 0x80 if val > 0
7865
8005
  buff << byte
8006
+ break if val == 0
7866
8007
  end
7867
8008
  end
7868
8009
 
7869
8010
  val = @vespene_cost
7870
- if val != 0
8011
+ if has_vespene_cost?
7871
8012
  buff << 0x20
7872
8013
 
7873
- while val != 0
8014
+ loop do
7874
8015
  byte = val & 0x7F
7875
8016
  val >>= 7
7876
8017
  byte |= 0x80 if val > 0
7877
8018
  buff << byte
8019
+ break if val == 0
7878
8020
  end
7879
8021
  end
7880
8022
 
7881
8023
  val = @research_time
7882
- if val != 0
8024
+ if has_research_time?
7883
8025
  buff << 0x2d
7884
8026
 
7885
8027
  [val].pack("e", buffer: buff)
7886
8028
  end
7887
8029
 
7888
8030
  val = @ability_id
7889
- if val != 0
8031
+ if has_ability_id?
7890
8032
  buff << 0x30
7891
8033
 
7892
- while val != 0
8034
+ loop do
7893
8035
  byte = val & 0x7F
7894
8036
  val >>= 7
7895
8037
  byte |= 0x80 if val > 0
7896
8038
  buff << byte
8039
+ break if val == 0
7897
8040
  end
7898
8041
  end
7899
8042
  buff << @_unknown_fields if @_unknown_fields
@@ -7902,14 +8045,37 @@ module Api
7902
8045
 
7903
8046
  def to_h
7904
8047
  result = {}
7905
- result["upgrade_id".to_sym] = @upgrade_id
7906
- result["name".to_sym] = @name
7907
- result["mineral_cost".to_sym] = @mineral_cost
7908
- result["vespene_cost".to_sym] = @vespene_cost
7909
- result["research_time".to_sym] = @research_time
7910
- result["ability_id".to_sym] = @ability_id
8048
+
8049
+ result[:"upgrade_id"] = @upgrade_id
8050
+ result[:"name"] = @name
8051
+ result[:"mineral_cost"] = @mineral_cost
8052
+ result[:"vespene_cost"] = @vespene_cost
8053
+ result[:"research_time"] = @research_time
8054
+ result[:"ability_id"] = @ability_id
8055
+
8056
+ result
8057
+ end
8058
+
8059
+ def as_json(options = {})
8060
+ result = {}
8061
+
8062
+ result["upgradeId"] = @upgrade_id if !options[:compact] || has_upgrade_id?
8063
+ result["name"] = @name if !options[:compact] || has_name?
8064
+ result["mineralCost"] = @mineral_cost if !options[:compact] ||
8065
+ has_mineral_cost?
8066
+ result["vespeneCost"] = @vespene_cost if !options[:compact] ||
8067
+ has_vespene_cost?
8068
+ result["researchTime"] = @research_time if !options[:compact] ||
8069
+ has_research_time?
8070
+ result["abilityId"] = @ability_id if !options[:compact] || has_ability_id?
8071
+
7911
8072
  result
7912
8073
  end
8074
+
8075
+ def to_json(as_json_options = {})
8076
+ require "json"
8077
+ JSON.dump(as_json(as_json_options))
8078
+ end
7913
8079
  end
7914
8080
  class BuffData
7915
8081
  def self.decode(buff)
@@ -8047,7 +8213,7 @@ module Api
8047
8213
 
8048
8214
  unknown_bytes = +"".b
8049
8215
  val = tag
8050
- while val != 0
8216
+ loop do
8051
8217
  byte = val & 0x7F
8052
8218
 
8053
8219
  val >>= 7
@@ -8058,6 +8224,7 @@ module Api
8058
8224
 
8059
8225
  byte |= 0x80 if val != 0
8060
8226
  unknown_bytes << byte
8227
+ break if val == 0
8061
8228
  end
8062
8229
 
8063
8230
  case wire_type
@@ -8132,7 +8299,7 @@ module Api
8132
8299
  end
8133
8300
 
8134
8301
  val = value
8135
- while val != 0
8302
+ loop do
8136
8303
  byte = val & 0x7F
8137
8304
 
8138
8305
  val >>= 7
@@ -8143,6 +8310,7 @@ module Api
8143
8310
 
8144
8311
  byte |= 0x80 if val != 0
8145
8312
  unknown_bytes << byte
8313
+ break if val == 0
8146
8314
  end
8147
8315
 
8148
8316
  unknown_bytes << buff.byteslice(index, value)
@@ -8434,25 +8602,27 @@ module Api
8434
8602
  end
8435
8603
  def _encode(buff)
8436
8604
  val = @buff_id
8437
- if val != 0
8605
+ if has_buff_id?
8438
8606
  buff << 0x08
8439
8607
 
8440
- while val != 0
8608
+ loop do
8441
8609
  byte = val & 0x7F
8442
8610
  val >>= 7
8443
8611
  byte |= 0x80 if val > 0
8444
8612
  buff << byte
8613
+ break if val == 0
8445
8614
  end
8446
8615
  end
8447
8616
 
8448
8617
  val = @name
8449
- if ((len = val.bytesize) > 0)
8618
+ if (len = val.bytesize) > 0 || has_name?
8450
8619
  buff << 0x12
8451
- while len != 0
8620
+ loop do
8452
8621
  byte = len & 0x7F
8453
8622
  len >>= 7
8454
8623
  byte |= 0x80 if len > 0
8455
8624
  buff << byte
8625
+ break if len == 0
8456
8626
  end
8457
8627
 
8458
8628
  buff << (val.ascii_only? ? val : val.b)
@@ -8463,10 +8633,26 @@ module Api
8463
8633
 
8464
8634
  def to_h
8465
8635
  result = {}
8466
- result["buff_id".to_sym] = @buff_id
8467
- result["name".to_sym] = @name
8636
+
8637
+ result[:"buff_id"] = @buff_id
8638
+ result[:"name"] = @name
8639
+
8640
+ result
8641
+ end
8642
+
8643
+ def as_json(options = {})
8644
+ result = {}
8645
+
8646
+ result["buffId"] = @buff_id if !options[:compact] || has_buff_id?
8647
+ result["name"] = @name if !options[:compact] || has_name?
8648
+
8468
8649
  result
8469
8650
  end
8651
+
8652
+ def to_json(as_json_options = {})
8653
+ require "json"
8654
+ JSON.dump(as_json(as_json_options))
8655
+ end
8470
8656
  end
8471
8657
  class EffectData
8472
8658
  def self.decode(buff)
@@ -8642,7 +8828,7 @@ module Api
8642
8828
 
8643
8829
  unknown_bytes = +"".b
8644
8830
  val = tag
8645
- while val != 0
8831
+ loop do
8646
8832
  byte = val & 0x7F
8647
8833
 
8648
8834
  val >>= 7
@@ -8653,6 +8839,7 @@ module Api
8653
8839
 
8654
8840
  byte |= 0x80 if val != 0
8655
8841
  unknown_bytes << byte
8842
+ break if val == 0
8656
8843
  end
8657
8844
 
8658
8845
  case wire_type
@@ -8727,7 +8914,7 @@ module Api
8727
8914
  end
8728
8915
 
8729
8916
  val = value
8730
- while val != 0
8917
+ loop do
8731
8918
  byte = val & 0x7F
8732
8919
 
8733
8920
  val >>= 7
@@ -8738,6 +8925,7 @@ module Api
8738
8925
 
8739
8926
  byte |= 0x80 if val != 0
8740
8927
  unknown_bytes << byte
8928
+ break if val == 0
8741
8929
  end
8742
8930
 
8743
8931
  unknown_bytes << buff.byteslice(index, value)
@@ -9199,45 +9387,48 @@ module Api
9199
9387
  end
9200
9388
  def _encode(buff)
9201
9389
  val = @effect_id
9202
- if val != 0
9390
+ if has_effect_id?
9203
9391
  buff << 0x08
9204
9392
 
9205
- while val != 0
9393
+ loop do
9206
9394
  byte = val & 0x7F
9207
9395
  val >>= 7
9208
9396
  byte |= 0x80 if val > 0
9209
9397
  buff << byte
9398
+ break if val == 0
9210
9399
  end
9211
9400
  end
9212
9401
 
9213
9402
  val = @name
9214
- if ((len = val.bytesize) > 0)
9403
+ if (len = val.bytesize) > 0 || has_name?
9215
9404
  buff << 0x12
9216
- while len != 0
9405
+ loop do
9217
9406
  byte = len & 0x7F
9218
9407
  len >>= 7
9219
9408
  byte |= 0x80 if len > 0
9220
9409
  buff << byte
9410
+ break if len == 0
9221
9411
  end
9222
9412
 
9223
9413
  buff << (val.ascii_only? ? val : val.b)
9224
9414
  end
9225
9415
 
9226
9416
  val = @friendly_name
9227
- if ((len = val.bytesize) > 0)
9417
+ if (len = val.bytesize) > 0 || has_friendly_name?
9228
9418
  buff << 0x1a
9229
- while len != 0
9419
+ loop do
9230
9420
  byte = len & 0x7F
9231
9421
  len >>= 7
9232
9422
  byte |= 0x80 if len > 0
9233
9423
  buff << byte
9424
+ break if len == 0
9234
9425
  end
9235
9426
 
9236
9427
  buff << (val.ascii_only? ? val : val.b)
9237
9428
  end
9238
9429
 
9239
9430
  val = @radius
9240
- if val != 0
9431
+ if has_radius?
9241
9432
  buff << 0x25
9242
9433
 
9243
9434
  [val].pack("e", buffer: buff)
@@ -9248,11 +9439,30 @@ module Api
9248
9439
 
9249
9440
  def to_h
9250
9441
  result = {}
9251
- result["effect_id".to_sym] = @effect_id
9252
- result["name".to_sym] = @name
9253
- result["friendly_name".to_sym] = @friendly_name
9254
- result["radius".to_sym] = @radius
9442
+
9443
+ result[:"effect_id"] = @effect_id
9444
+ result[:"name"] = @name
9445
+ result[:"friendly_name"] = @friendly_name
9446
+ result[:"radius"] = @radius
9447
+
9448
+ result
9449
+ end
9450
+
9451
+ def as_json(options = {})
9452
+ result = {}
9453
+
9454
+ result["effectId"] = @effect_id if !options[:compact] || has_effect_id?
9455
+ result["name"] = @name if !options[:compact] || has_name?
9456
+ result["friendlyName"] = @friendly_name if !options[:compact] ||
9457
+ has_friendly_name?
9458
+ result["radius"] = @radius if !options[:compact] || has_radius?
9459
+
9255
9460
  result
9256
9461
  end
9462
+
9463
+ def to_json(as_json_options = {})
9464
+ require "json"
9465
+ JSON.dump(as_json(as_json_options))
9466
+ end
9257
9467
  end
9258
9468
  end