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

import * as flatbuffers from 'flatbuffers';

import { BestMoveView } from '../scrabblefb/best-move-view.js';


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

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

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

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

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

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

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

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

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

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

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

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

static startStatsView(builder:flatbuffers.Builder) {
  builder.startObject(8);
}

static addWins(builder:flatbuffers.Builder, wins:number) {
  builder.addFieldInt32(0, wins, 0);
}

static addLosses(builder:flatbuffers.Builder, losses:number) {
  builder.addFieldInt32(1, losses, 0);
}

static addDraws(builder:flatbuffers.Builder, draws:number) {
  builder.addFieldInt32(2, draws, 0);
}

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

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

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

static createBestMovesVector(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 startBestMovesVector(builder:flatbuffers.Builder, numElems:number) {
  builder.startVector(4, numElems, 4);
}

static addMoves(builder:flatbuffers.Builder, moves:number) {
  builder.addFieldInt32(6, moves, 0);
}

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

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

static createStatsView(builder:flatbuffers.Builder, wins:number, losses:number, draws:number, maxGamePoints:number, maxWordPoints:number, bestMovesOffset:flatbuffers.Offset, moves:number, hintsUsed:number):flatbuffers.Offset {
  StatsView.startStatsView(builder);
  StatsView.addWins(builder, wins);
  StatsView.addLosses(builder, losses);
  StatsView.addDraws(builder, draws);
  StatsView.addMaxGamePoints(builder, maxGamePoints);
  StatsView.addMaxWordPoints(builder, maxWordPoints);
  StatsView.addBestMoves(builder, bestMovesOffset);
  StatsView.addMoves(builder, moves);
  StatsView.addHintsUsed(builder, hintsUsed);
  return StatsView.endStatsView(builder);
}
}
