Class: Api::ResponseStep

Inherits:
Object
  • Object
show all
Defined in:
lib/sc2ai/protocol/sc2api_pb.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(simulation_loop: nil) ⇒ ResponseStep

END writers for optional fields



24993
24994
24995
24996
24997
24998
24999
25000
25001
25002
25003
25004
25005
25006
# File 'lib/sc2ai/protocol/sc2api_pb.rb', line 24993

def initialize(simulation_loop: nil)
  @_bitmask = 0

  if simulation_loop == nil
    @simulation_loop = 0
  else
    unless 0 <= simulation_loop && simulation_loop <= 4_294_967_295
      raise RangeError,
            "Value (#{simulation_loop}) for field simulation_loop is out of bounds (0..4294967295)"
    end
    @_bitmask |= 0x0000000000000001
    @simulation_loop = simulation_loop
  end
end

Instance Attribute Details

#simulation_loopObject

optional field readers



24978
24979
24980
# File 'lib/sc2ai/protocol/sc2api_pb.rb', line 24978

def simulation_loop
  @simulation_loop
end

Class Method Details

.decode(buff) ⇒ Object



24967
24968
24969
# File 'lib/sc2ai/protocol/sc2api_pb.rb', line 24967

def self.decode(buff)
  allocate.decode_from(buff.b, 0, buff.bytesize)
end

.encode(obj) ⇒ Object



24971
24972
24973
# File 'lib/sc2ai/protocol/sc2api_pb.rb', line 24971

def self.encode(obj)
  obj._encode("".b)
end

Instance Method Details

#_encode(buff) ⇒ Object



25325
25326
25327
25328
25329
25330
25331
25332
25333
25334
25335
25336
25337
25338
25339
# File 'lib/sc2ai/protocol/sc2api_pb.rb', line 25325

def _encode(buff)
  val = @simulation_loop
  if val != 0
    buff << 0x08

    while val != 0
      byte = val & 0x7F
      val >>= 7
      byte |= 0x80 if val > 0
      buff << byte
    end
  end

  buff
end

#decode_from(buff, index, len) ⇒ Object



25016
25017
25018
25019
25020
25021
25022
25023
25024
25025
25026
25027
25028
25029
25030
25031
25032
25033
25034
25035
25036
25037
25038
25039
25040
25041
25042
25043
25044
25045
25046
25047
25048
25049
25050
25051
25052
25053
25054
25055
25056
25057
25058
25059
25060
25061
25062
25063
25064
25065
25066
25067
25068
25069
25070
25071
25072
25073
25074
25075
25076
25077
25078
25079
25080
25081
25082
25083
25084
25085
25086
25087
25088
25089
25090
25091
25092
25093
25094
25095
25096
25097
25098
25099
25100
25101
25102
25103
25104
25105
25106
25107
25108
25109
25110
25111
25112
25113
25114
25115
25116
25117
25118
25119
25120
25121
25122
25123
25124
25125
25126
25127
25128
25129
25130
25131
25132
25133
25134
25135
25136
25137
25138
25139
25140
25141
25142
25143
25144
25145
25146
25147
25148
25149
25150
25151
25152
25153
25154
25155
25156
25157
25158
25159
25160
25161
25162
25163
25164
25165
25166
25167
25168
25169
25170
25171
25172
25173
25174
25175
25176
25177
25178
25179
25180
25181
25182
25183
25184
25185
25186
25187
25188
25189
25190
25191
25192
25193
25194
25195
25196
25197
25198
25199
25200
25201
25202
25203
25204
25205
25206
25207
25208
25209
25210
25211
25212
25213
25214
25215
25216
25217
25218
25219
25220
25221
25222
25223
25224
25225
25226
25227
25228
25229
25230
25231
25232
25233
25234
25235
25236
25237
25238
25239
25240
25241
25242
25243
25244
25245
25246
25247
25248
25249
25250
25251
25252
25253
25254
25255
25256
25257
25258
25259
25260
25261
25262
25263
25264
25265
25266
25267
25268
25269
25270
25271
25272
25273
25274
25275
25276
25277
25278
25279
25280
25281
25282
25283
25284
25285
25286
25287
25288
25289
25290
25291
25292
25293
25294
25295
25296
25297
25298
25299
25300
25301
25302
25303
25304
25305
25306
25307
25308
25309
25310
25311
25312
25313
25314
25315
25316
25317
25318
25319
25320
25321
25322
25323
25324
# File 'lib/sc2ai/protocol/sc2api_pb.rb', line 25016

def decode_from(buff, index, len)
  @_bitmask = 0

  @simulation_loop = 0

  return self if index >= len
  ## PULL_UINT64
  tag =
    if (byte0 = buff.getbyte(index)) < 0x80
      index += 1
      byte0
    elsif (byte1 = buff.getbyte(index + 1)) < 0x80
      index += 2
      (byte1 << 7) | (byte0 & 0x7F)
    elsif (byte2 = buff.getbyte(index + 2)) < 0x80
      index += 3
      (byte2 << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
    elsif (byte3 = buff.getbyte(index + 3)) < 0x80
      index += 4
      (byte3 << 21) | ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
        (byte0 & 0x7F)
    elsif (byte4 = buff.getbyte(index + 4)) < 0x80
      index += 5
      (byte4 << 28) | ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
        ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
    elsif (byte5 = buff.getbyte(index + 5)) < 0x80
      index += 6
      (byte5 << 35) | ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
        ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
    elsif (byte6 = buff.getbyte(index + 6)) < 0x80
      index += 7
      (byte6 << 42) | ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
        ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
        ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
    elsif (byte7 = buff.getbyte(index + 7)) < 0x80
      index += 8
      (byte7 << 49) | ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
        ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
        ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
    elsif (byte8 = buff.getbyte(index + 8)) < 0x80
      index += 9
      (byte8 << 56) | ((byte7 & 0x7F) << 49) | ((byte6 & 0x7F) << 42) |
        ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
        ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
        ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
    elsif (byte9 = buff.getbyte(index + 9)) < 0x80
      index += 10

      (byte9 << 63) | ((byte8 & 0x7F) << 56) | ((byte7 & 0x7F) << 49) |
        ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
        ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
        ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
    else
      raise "integer decoding error"
    end

  ## END PULL_UINT64

  found = true
  while true
    # If we have looped around since the last found tag this one is
    # unexpected, so discard it and continue.
    if !found
      wire_type = tag & 0x7
      case wire_type
      when 0
        i = 0
        while true
          newbyte = buff.getbyte(index)
          index += 1
          break if newbyte.nil? || newbyte < 0x80
          i += 1
          break if i > 9
        end
      when 1
        index += 8
      when 2
        ## PULL_BYTES
        value =
          if (byte0 = buff.getbyte(index)) < 0x80
            index += 1
            byte0
          elsif (byte1 = buff.getbyte(index + 1)) < 0x80
            index += 2
            (byte1 << 7) | (byte0 & 0x7F)
          elsif (byte2 = buff.getbyte(index + 2)) < 0x80
            index += 3
            (byte2 << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
          elsif (byte3 = buff.getbyte(index + 3)) < 0x80
            index += 4
            (byte3 << 21) | ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
              (byte0 & 0x7F)
          elsif (byte4 = buff.getbyte(index + 4)) < 0x80
            index += 5
            (byte4 << 28) | ((byte3 & 0x7F) << 21) |
              ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
              (byte0 & 0x7F)
          elsif (byte5 = buff.getbyte(index + 5)) < 0x80
            index += 6
            (byte5 << 35) | ((byte4 & 0x7F) << 28) |
              ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
              ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
          elsif (byte6 = buff.getbyte(index + 6)) < 0x80
            index += 7
            (byte6 << 42) | ((byte5 & 0x7F) << 35) |
              ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
              ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
              (byte0 & 0x7F)
          elsif (byte7 = buff.getbyte(index + 7)) < 0x80
            index += 8
            (byte7 << 49) | ((byte6 & 0x7F) << 42) |
              ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
              ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
              ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
          elsif (byte8 = buff.getbyte(index + 8)) < 0x80
            index += 9
            (byte8 << 56) | ((byte7 & 0x7F) << 49) |
              ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
              ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
              ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
              (byte0 & 0x7F)
          elsif (byte9 = buff.getbyte(index + 9)) < 0x80
            index += 10

            (byte9 << 63) | ((byte8 & 0x7F) << 56) |
              ((byte7 & 0x7F) << 49) | ((byte6 & 0x7F) << 42) |
              ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
              ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
              ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
          else
            raise "integer decoding error"
          end

        buff.byteslice(index, value)
        index += value

        ## END PULL_BYTES
      when 5
        index += 4
      else
        raise "unknown wire type #{wire_type}"
      end
      return self if index >= len
      ## PULL_UINT64
      tag =
        if (byte0 = buff.getbyte(index)) < 0x80
          index += 1
          byte0
        elsif (byte1 = buff.getbyte(index + 1)) < 0x80
          index += 2
          (byte1 << 7) | (byte0 & 0x7F)
        elsif (byte2 = buff.getbyte(index + 2)) < 0x80
          index += 3
          (byte2 << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte3 = buff.getbyte(index + 3)) < 0x80
          index += 4
          (byte3 << 21) | ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
            (byte0 & 0x7F)
        elsif (byte4 = buff.getbyte(index + 4)) < 0x80
          index += 5
          (byte4 << 28) | ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
            ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte5 = buff.getbyte(index + 5)) < 0x80
          index += 6
          (byte5 << 35) | ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
            ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte6 = buff.getbyte(index + 6)) < 0x80
          index += 7
          (byte6 << 42) | ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
            ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
            ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte7 = buff.getbyte(index + 7)) < 0x80
          index += 8
          (byte7 << 49) | ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
            ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
            ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte8 = buff.getbyte(index + 8)) < 0x80
          index += 9
          (byte8 << 56) | ((byte7 & 0x7F) << 49) | ((byte6 & 0x7F) << 42) |
            ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
            ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
            ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte9 = buff.getbyte(index + 9)) < 0x80
          index += 10

          (byte9 << 63) | ((byte8 & 0x7F) << 56) | ((byte7 & 0x7F) << 49) |
            ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
            ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
            ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        else
          raise "integer decoding error"
        end

      ## END PULL_UINT64
    end
    found = false

    if tag == 0x8
      found = true
      ## PULL_UINT64
      @simulation_loop =
        if (byte0 = buff.getbyte(index)) < 0x80
          index += 1
          byte0
        elsif (byte1 = buff.getbyte(index + 1)) < 0x80
          index += 2
          (byte1 << 7) | (byte0 & 0x7F)
        elsif (byte2 = buff.getbyte(index + 2)) < 0x80
          index += 3
          (byte2 << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte3 = buff.getbyte(index + 3)) < 0x80
          index += 4
          (byte3 << 21) | ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
            (byte0 & 0x7F)
        elsif (byte4 = buff.getbyte(index + 4)) < 0x80
          index += 5
          (byte4 << 28) | ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
            ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte5 = buff.getbyte(index + 5)) < 0x80
          index += 6
          (byte5 << 35) | ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
            ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte6 = buff.getbyte(index + 6)) < 0x80
          index += 7
          (byte6 << 42) | ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
            ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
            ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte7 = buff.getbyte(index + 7)) < 0x80
          index += 8
          (byte7 << 49) | ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
            ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
            ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte8 = buff.getbyte(index + 8)) < 0x80
          index += 9
          (byte8 << 56) | ((byte7 & 0x7F) << 49) | ((byte6 & 0x7F) << 42) |
            ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
            ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
            ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte9 = buff.getbyte(index + 9)) < 0x80
          index += 10

          (byte9 << 63) | ((byte8 & 0x7F) << 56) | ((byte7 & 0x7F) << 49) |
            ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
            ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
            ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        else
          raise "integer decoding error"
        end

      ## END PULL_UINT64

      @_bitmask |= 0x0000000000000001
      return self if index >= len
      ## PULL_UINT64
      tag =
        if (byte0 = buff.getbyte(index)) < 0x80
          index += 1
          byte0
        elsif (byte1 = buff.getbyte(index + 1)) < 0x80
          index += 2
          (byte1 << 7) | (byte0 & 0x7F)
        elsif (byte2 = buff.getbyte(index + 2)) < 0x80
          index += 3
          (byte2 << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte3 = buff.getbyte(index + 3)) < 0x80
          index += 4
          (byte3 << 21) | ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
            (byte0 & 0x7F)
        elsif (byte4 = buff.getbyte(index + 4)) < 0x80
          index += 5
          (byte4 << 28) | ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
            ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte5 = buff.getbyte(index + 5)) < 0x80
          index += 6
          (byte5 << 35) | ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
            ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte6 = buff.getbyte(index + 6)) < 0x80
          index += 7
          (byte6 << 42) | ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
            ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
            ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte7 = buff.getbyte(index + 7)) < 0x80
          index += 8
          (byte7 << 49) | ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
            ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
            ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte8 = buff.getbyte(index + 8)) < 0x80
          index += 9
          (byte8 << 56) | ((byte7 & 0x7F) << 49) | ((byte6 & 0x7F) << 42) |
            ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
            ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
            ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        elsif (byte9 = buff.getbyte(index + 9)) < 0x80
          index += 10

          (byte9 << 63) | ((byte8 & 0x7F) << 56) | ((byte7 & 0x7F) << 49) |
            ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
            ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
            ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
        else
          raise "integer decoding error"
        end

      ## END PULL_UINT64
    end

    return self if index >= len
  end
end

#has_simulation_loop?Boolean

Returns:

  • (Boolean)


25012
25013
25014
# File 'lib/sc2ai/protocol/sc2api_pb.rb', line 25012

def has_simulation_loop?
  (@_bitmask & 0x0000000000000001) == 0x0000000000000001
end

#to_hObject



25341
25342
25343
25344
25345
# File 'lib/sc2ai/protocol/sc2api_pb.rb', line 25341

def to_h
  result = {}
  result["simulation_loop".to_sym] = @simulation_loop
  result
end

#to_proto(_options = {}) ⇒ Object



25008
25009
25010
# File 'lib/sc2ai/protocol/sc2api_pb.rb', line 25008

def to_proto(_options = {})
  self.class.encode(self)
end