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

/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */

import * as flatbuffers from 'flatbuffers';

import { UUID, UUIDT } from '../common/uuid.js';


export class UserGamesOrderGet implements flatbuffers.IUnpackableObject<UserGamesOrderGetT> {
  bb: flatbuffers.ByteBuffer|null = null;
  bb_pos = 0;
  __init(i:number, bb:flatbuffers.ByteBuffer):UserGamesOrderGet {
  this.bb_pos = i;
  this.bb = bb;
  return this;
}

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

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

gameId(obj?:UUID):UUID|null {
  const offset = this.bb!.__offset(this.bb_pos, 4);
  return offset ? (obj || new UUID()).__init(this.bb_pos + offset, this.bb!) : null;
}

turn():bigint {
  const offset = this.bb!.__offset(this.bb_pos, 6);
  return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}

static startUserGamesOrderGet(builder:flatbuffers.Builder) {
  builder.startObject(2);
}

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

static addTurn(builder:flatbuffers.Builder, turn:bigint) {
  builder.addFieldInt64(1, turn, BigInt('0'));
}

static endUserGamesOrderGet(builder:flatbuffers.Builder):flatbuffers.Offset {
  const offset = builder.endObject();
  builder.requiredField(offset, 4) // game_id
  return offset;
}

static createUserGamesOrderGet(builder:flatbuffers.Builder, gameIdOffset:flatbuffers.Offset, turn:bigint):flatbuffers.Offset {
  UserGamesOrderGet.startUserGamesOrderGet(builder);
  UserGamesOrderGet.addGameId(builder, gameIdOffset);
  UserGamesOrderGet.addTurn(builder, turn);
  return UserGamesOrderGet.endUserGamesOrderGet(builder);
}

unpack(): UserGamesOrderGetT {
  return new UserGamesOrderGetT(
    (this.gameId() !== null ? this.gameId()!.unpack() : null),
    this.turn()
  );
}


unpackTo(_o: UserGamesOrderGetT): void {
  _o.gameId = (this.gameId() !== null ? this.gameId()!.unpack() : null);
  _o.turn = this.turn();
}
}

export class UserGamesOrderGetT implements flatbuffers.IGeneratedObject {
constructor(
  public gameId: UUIDT|null = null,
  public turn: bigint = BigInt('0')
){}


pack(builder:flatbuffers.Builder): flatbuffers.Offset {
  return UserGamesOrderGet.createUserGamesOrderGet(builder,
    (this.gameId !== null ? this.gameId!.pack(builder) : 0),
    this.turn
  );
}
}
