// 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 '../battle/uuid.js';


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

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

static getSizePrefixedRootAsGameBattleRequest(bb:flatbuffers.ByteBuffer, obj?:GameBattleRequest):GameBattleRequest {
  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
  return (obj || new GameBattleRequest()).__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():number {
  const offset = this.bb!.__offset(this.bb_pos, 6);
  return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
}

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

static startGameBattleRequest(builder:flatbuffers.Builder) {
  builder.startObject(3);
}

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

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

static addBattleId(builder:flatbuffers.Builder, battleIdOffset:flatbuffers.Offset) {
  builder.addFieldStruct(2, battleIdOffset, 0);
}

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


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


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

export class GameBattleRequestT implements flatbuffers.IGeneratedObject {
constructor(
  public gameId: UUIDT|null = null,
  public turn: number = 0,
  public battleId: UUIDT|null = null
){}


pack(builder:flatbuffers.Builder): flatbuffers.Offset {
  GameBattleRequest.startGameBattleRequest(builder);
  GameBattleRequest.addGameId(builder, (this.gameId !== null ? this.gameId!.pack(builder) : 0));
  GameBattleRequest.addTurn(builder, this.turn);
  GameBattleRequest.addBattleId(builder, (this.battleId !== null ? this.battleId!.pack(builder) : 0));

  return GameBattleRequest.endGameBattleRequest(builder);
}
}
