// automatically generated by the FlatBuffers compiler, do not modify

import * as flatbuffers from 'flatbuffers';

import { GameView } from '../scrabblefb/game-view.js';
import { MoveRecord } from '../scrabblefb/move-record.js';


export class OpponentMovedEvent {
  bb: flatbuffers.ByteBuffer|null = null;
  bb_pos = 0;
  __init(i:number, bb:flatbuffers.ByteBuffer):OpponentMovedEvent {
  this.bb_pos = i;
  this.bb = bb;
  return this;
}

static getRootAsOpponentMovedEvent(bb:flatbuffers.ByteBuffer, obj?:OpponentMovedEvent):OpponentMovedEvent {
  return (obj || new OpponentMovedEvent()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

static getSizePrefixedRootAsOpponentMovedEvent(bb:flatbuffers.ByteBuffer, obj?:OpponentMovedEvent):OpponentMovedEvent {
  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
  return (obj || new OpponentMovedEvent()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

gameId():string|null
gameId(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
gameId(optionalEncoding?:any):string|Uint8Array|null {
  const offset = this.bb!.__offset(this.bb_pos, 4);
  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}

move(obj?:MoveRecord):MoveRecord|null {
  const offset = this.bb!.__offset(this.bb_pos, 6);
  return offset ? (obj || new MoveRecord()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
}

game(obj?:GameView):GameView|null {
  const offset = this.bb!.__offset(this.bb_pos, 8);
  return offset ? (obj || new GameView()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
}

bagLen():number {
  const offset = this.bb!.__offset(this.bb_pos, 10);
  return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
}

static startOpponentMovedEvent(builder:flatbuffers.Builder) {
  builder.startObject(4);
}

static addGameId(builder:flatbuffers.Builder, gameIdOffset:flatbuffers.Offset) {
  builder.addFieldOffset(0, gameIdOffset, 0);
}

static addMove(builder:flatbuffers.Builder, moveOffset:flatbuffers.Offset) {
  builder.addFieldOffset(1, moveOffset, 0);
}

static addGame(builder:flatbuffers.Builder, gameOffset:flatbuffers.Offset) {
  builder.addFieldOffset(2, gameOffset, 0);
}

static addBagLen(builder:flatbuffers.Builder, bagLen:number) {
  builder.addFieldInt32(3, bagLen, 0);
}

static endOpponentMovedEvent(builder:flatbuffers.Builder):flatbuffers.Offset {
  const offset = builder.endObject();
  return offset;
}

}
