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

import * as flatbuffers from 'flatbuffers';

import { TileRecord } from '../scrabblefb/tile-record.js';


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

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

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

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

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

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

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

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

tiles(index: number, obj?:TileRecord):TileRecord|null {
  const offset = this.bb!.__offset(this.bb_pos, 14);
  return offset ? (obj || new TileRecord()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}

tilesLength():number {
  const offset = this.bb!.__offset(this.bb_pos, 14);
  return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}

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

wordsLength():number {
  const offset = this.bb!.__offset(this.bb_pos, 16);
  return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}

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

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

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

static startMoveRecord(builder:flatbuffers.Builder) {
  builder.startObject(10);
}

static addPlayer(builder:flatbuffers.Builder, player:number) {
  builder.addFieldInt32(0, player, 0);
}

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

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

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

static addMainCol(builder:flatbuffers.Builder, mainCol:number) {
  builder.addFieldInt32(4, mainCol, 0);
}

static addTiles(builder:flatbuffers.Builder, tilesOffset:flatbuffers.Offset) {
  builder.addFieldOffset(5, tilesOffset, 0);
}

static createTilesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
  builder.startVector(4, data.length, 4);
  for (let i = data.length - 1; i >= 0; i--) {
    builder.addOffset(data[i]!);
  }
  return builder.endVector();
}

static startTilesVector(builder:flatbuffers.Builder, numElems:number) {
  builder.startVector(4, numElems, 4);
}

static addWords(builder:flatbuffers.Builder, wordsOffset:flatbuffers.Offset) {
  builder.addFieldOffset(6, wordsOffset, 0);
}

static createWordsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
  builder.startVector(4, data.length, 4);
  for (let i = data.length - 1; i >= 0; i--) {
    builder.addOffset(data[i]!);
  }
  return builder.endVector();
}

static startWordsVector(builder:flatbuffers.Builder, numElems:number) {
  builder.startVector(4, numElems, 4);
}

static addCount(builder:flatbuffers.Builder, count:number) {
  builder.addFieldInt32(7, count, 0);
}

static addScore(builder:flatbuffers.Builder, score:number) {
  builder.addFieldInt32(8, score, 0);
}

static addTotal(builder:flatbuffers.Builder, total:number) {
  builder.addFieldInt32(9, total, 0);
}

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

static createMoveRecord(builder:flatbuffers.Builder, player:number, actionOffset:flatbuffers.Offset, dirOffset:flatbuffers.Offset, mainRow:number, mainCol:number, tilesOffset:flatbuffers.Offset, wordsOffset:flatbuffers.Offset, count:number, score:number, total:number):flatbuffers.Offset {
  MoveRecord.startMoveRecord(builder);
  MoveRecord.addPlayer(builder, player);
  MoveRecord.addAction(builder, actionOffset);
  MoveRecord.addDir(builder, dirOffset);
  MoveRecord.addMainRow(builder, mainRow);
  MoveRecord.addMainCol(builder, mainCol);
  MoveRecord.addTiles(builder, tilesOffset);
  MoveRecord.addWords(builder, wordsOffset);
  MoveRecord.addCount(builder, count);
  MoveRecord.addScore(builder, score);
  MoveRecord.addTotal(builder, total);
  return MoveRecord.endMoveRecord(builder);
}
}
