battle-fetch: migrate to user.games.battle ConnectRPC command
Tests · UI / test (push) Has been cancelled
Tests · Go / test (pull_request) Successful in 2m6s
Tests · Go / test (push) Successful in 2m7s
Tests · Integration / integration (pull_request) Successful in 1m47s
Tests · UI / test (pull_request) Failing after 3m42s

The Phase 27 BattleViewer was the last UI surface still issuing raw
fetch() against the backend REST contract (`/api/v1/user/games/...
/battles/...`). The dev-deploy gateway never proxied that path, so
the viewer worked only in tools/local-dev/. Move it onto the signed
ConnectRPC channel every other authenticated surface already uses.

Wire pieces:
- FBS GameBattleRequest in pkg/schema/fbs/battle.fbs, regenerated
  Go + TS bindings.
- MessageTypeUserGamesBattle constant + GameBattleRequest struct in
  pkg/model/report/messages.go.
- pkg/transcoder/battle.go gains GameBattleRequestToPayload and
  PayloadToGameBattleRequest helpers.
- gateway games_commands.go switches on the new message type and
  GETs /api/v1/user/games/{id}/battles/{turn}/{battle_id}; the JSON
  response is re-encoded as a FlatBuffers BattleReport before being
  returned. 404 from backend surfaces as the canonical `not_found`
  gateway error.
- ui/frontend/src/api/battle-fetch.ts now builds the FBS request,
  calls GalaxyClient.executeCommand, and decodes the FBS response
  into the existing UI shape (Record<string,string> race/ship maps,
  string-form UUID). BattleFetchError carries an HTTP-style status
  derived from the result code so the active-view's not_found branch
  keeps working.
- battle.svelte pulls the GalaxyClient from the in-game shell
  context. While the layout's boot Promise.all is in flight the
  effect stays in `loading` until the client handle becomes
  non-null.
- ui/Makefile FBS_INPUTS gains battle.fbs.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Ilia Denisov
2026-05-16 12:41:54 +02:00
parent 8bc75fd71b
commit ebd156ece2
20 changed files with 1513 additions and 29 deletions
@@ -0,0 +1,12 @@
// 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 */
export { BattleActionReport, BattleActionReportT } from './battle/battle-action-report.js';
export { BattleReport, BattleReportT } from './battle/battle-report.js';
export { BattleReportGroup, BattleReportGroupT } from './battle/battle-report-group.js';
export { GameBattleRequest, GameBattleRequestT } from './battle/game-battle-request.js';
export { RaceEntry, RaceEntryT } from './battle/race-entry.js';
export { ShipEntry, ShipEntryT } from './battle/ship-entry.js';
export { TechEntry, TechEntryT } from './battle/tech-entry.js';
export { UUID, UUIDT } from './battle/uuid.js';
@@ -0,0 +1,130 @@
// 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';
export class BattleActionReport implements flatbuffers.IUnpackableObject<BattleActionReportT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):BattleActionReport {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsBattleActionReport(bb:flatbuffers.ByteBuffer, obj?:BattleActionReport):BattleActionReport {
return (obj || new BattleActionReport()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsBattleActionReport(bb:flatbuffers.ByteBuffer, obj?:BattleActionReport):BattleActionReport {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new BattleActionReport()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
attacker():bigint {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}
attackerShipClass():bigint {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}
defender():bigint {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}
defenderShipClass():bigint {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}
destroyed():boolean {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
}
static startBattleActionReport(builder:flatbuffers.Builder) {
builder.startObject(5);
}
static addAttacker(builder:flatbuffers.Builder, attacker:bigint) {
builder.addFieldInt64(0, attacker, BigInt('0'));
}
static addAttackerShipClass(builder:flatbuffers.Builder, attackerShipClass:bigint) {
builder.addFieldInt64(1, attackerShipClass, BigInt('0'));
}
static addDefender(builder:flatbuffers.Builder, defender:bigint) {
builder.addFieldInt64(2, defender, BigInt('0'));
}
static addDefenderShipClass(builder:flatbuffers.Builder, defenderShipClass:bigint) {
builder.addFieldInt64(3, defenderShipClass, BigInt('0'));
}
static addDestroyed(builder:flatbuffers.Builder, destroyed:boolean) {
builder.addFieldInt8(4, +destroyed, +false);
}
static endBattleActionReport(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createBattleActionReport(builder:flatbuffers.Builder, attacker:bigint, attackerShipClass:bigint, defender:bigint, defenderShipClass:bigint, destroyed:boolean):flatbuffers.Offset {
BattleActionReport.startBattleActionReport(builder);
BattleActionReport.addAttacker(builder, attacker);
BattleActionReport.addAttackerShipClass(builder, attackerShipClass);
BattleActionReport.addDefender(builder, defender);
BattleActionReport.addDefenderShipClass(builder, defenderShipClass);
BattleActionReport.addDestroyed(builder, destroyed);
return BattleActionReport.endBattleActionReport(builder);
}
unpack(): BattleActionReportT {
return new BattleActionReportT(
this.attacker(),
this.attackerShipClass(),
this.defender(),
this.defenderShipClass(),
this.destroyed()
);
}
unpackTo(_o: BattleActionReportT): void {
_o.attacker = this.attacker();
_o.attackerShipClass = this.attackerShipClass();
_o.defender = this.defender();
_o.defenderShipClass = this.defenderShipClass();
_o.destroyed = this.destroyed();
}
}
export class BattleActionReportT implements flatbuffers.IGeneratedObject {
constructor(
public attacker: bigint = BigInt('0'),
public attackerShipClass: bigint = BigInt('0'),
public defender: bigint = BigInt('0'),
public defenderShipClass: bigint = BigInt('0'),
public destroyed: boolean = false
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return BattleActionReport.createBattleActionReport(builder,
this.attacker,
this.attackerShipClass,
this.defender,
this.defenderShipClass,
this.destroyed
);
}
}
@@ -0,0 +1,201 @@
// 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 { TechEntry, TechEntryT } from '../battle/tech-entry.js';
export class BattleReportGroup implements flatbuffers.IUnpackableObject<BattleReportGroupT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):BattleReportGroup {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsBattleReportGroup(bb:flatbuffers.ByteBuffer, obj?:BattleReportGroup):BattleReportGroup {
return (obj || new BattleReportGroup()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsBattleReportGroup(bb:flatbuffers.ByteBuffer, obj?:BattleReportGroup):BattleReportGroup {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new BattleReportGroup()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
inBattle():boolean {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
}
number():bigint {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
numberLeft():bigint {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
loadQuantity():number {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
tech(index: number, obj?:TechEntry):TechEntry|null {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? (obj || new TechEntry()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
techLength():number {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
race():string|null
race(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
race(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
className():string|null
className(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
className(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 16);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
loadType():string|null
loadType(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
loadType(optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 18);
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}
static startBattleReportGroup(builder:flatbuffers.Builder) {
builder.startObject(8);
}
static addInBattle(builder:flatbuffers.Builder, inBattle:boolean) {
builder.addFieldInt8(0, +inBattle, +false);
}
static addNumber(builder:flatbuffers.Builder, number:bigint) {
builder.addFieldInt64(1, number, BigInt('0'));
}
static addNumberLeft(builder:flatbuffers.Builder, numberLeft:bigint) {
builder.addFieldInt64(2, numberLeft, BigInt('0'));
}
static addLoadQuantity(builder:flatbuffers.Builder, loadQuantity:number) {
builder.addFieldFloat32(3, loadQuantity, 0.0);
}
static addTech(builder:flatbuffers.Builder, techOffset:flatbuffers.Offset) {
builder.addFieldOffset(4, techOffset, 0);
}
static createTechVector(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 startTechVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addRace(builder:flatbuffers.Builder, raceOffset:flatbuffers.Offset) {
builder.addFieldOffset(5, raceOffset, 0);
}
static addClassName(builder:flatbuffers.Builder, classNameOffset:flatbuffers.Offset) {
builder.addFieldOffset(6, classNameOffset, 0);
}
static addLoadType(builder:flatbuffers.Builder, loadTypeOffset:flatbuffers.Offset) {
builder.addFieldOffset(7, loadTypeOffset, 0);
}
static endBattleReportGroup(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createBattleReportGroup(builder:flatbuffers.Builder, inBattle:boolean, number:bigint, numberLeft:bigint, loadQuantity:number, techOffset:flatbuffers.Offset, raceOffset:flatbuffers.Offset, classNameOffset:flatbuffers.Offset, loadTypeOffset:flatbuffers.Offset):flatbuffers.Offset {
BattleReportGroup.startBattleReportGroup(builder);
BattleReportGroup.addInBattle(builder, inBattle);
BattleReportGroup.addNumber(builder, number);
BattleReportGroup.addNumberLeft(builder, numberLeft);
BattleReportGroup.addLoadQuantity(builder, loadQuantity);
BattleReportGroup.addTech(builder, techOffset);
BattleReportGroup.addRace(builder, raceOffset);
BattleReportGroup.addClassName(builder, classNameOffset);
BattleReportGroup.addLoadType(builder, loadTypeOffset);
return BattleReportGroup.endBattleReportGroup(builder);
}
unpack(): BattleReportGroupT {
return new BattleReportGroupT(
this.inBattle(),
this.number(),
this.numberLeft(),
this.loadQuantity(),
this.bb!.createObjList<TechEntry, TechEntryT>(this.tech.bind(this), this.techLength()),
this.race(),
this.className(),
this.loadType()
);
}
unpackTo(_o: BattleReportGroupT): void {
_o.inBattle = this.inBattle();
_o.number = this.number();
_o.numberLeft = this.numberLeft();
_o.loadQuantity = this.loadQuantity();
_o.tech = this.bb!.createObjList<TechEntry, TechEntryT>(this.tech.bind(this), this.techLength());
_o.race = this.race();
_o.className = this.className();
_o.loadType = this.loadType();
}
}
export class BattleReportGroupT implements flatbuffers.IGeneratedObject {
constructor(
public inBattle: boolean = false,
public number: bigint = BigInt('0'),
public numberLeft: bigint = BigInt('0'),
public loadQuantity: number = 0.0,
public tech: (TechEntryT)[] = [],
public race: string|Uint8Array|null = null,
public className: string|Uint8Array|null = null,
public loadType: string|Uint8Array|null = null
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const tech = BattleReportGroup.createTechVector(builder, builder.createObjectOffsetList(this.tech));
const race = (this.race !== null ? builder.createString(this.race!) : 0);
const className = (this.className !== null ? builder.createString(this.className!) : 0);
const loadType = (this.loadType !== null ? builder.createString(this.loadType!) : 0);
return BattleReportGroup.createBattleReportGroup(builder,
this.inBattle,
this.number,
this.numberLeft,
this.loadQuantity,
tech,
race,
className,
loadType
);
}
}
@@ -0,0 +1,215 @@
// 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 { BattleActionReport, BattleActionReportT } from '../battle/battle-action-report.js';
import { RaceEntry, RaceEntryT } from '../battle/race-entry.js';
import { ShipEntry, ShipEntryT } from '../battle/ship-entry.js';
import { UUID, UUIDT } from '../battle/uuid.js';
export class BattleReport implements flatbuffers.IUnpackableObject<BattleReportT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):BattleReport {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsBattleReport(bb:flatbuffers.ByteBuffer, obj?:BattleReport):BattleReport {
return (obj || new BattleReport()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsBattleReport(bb:flatbuffers.ByteBuffer, obj?:BattleReport):BattleReport {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new BattleReport()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
id(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;
}
planet():bigint {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}
planetName():string|null
planetName(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
planetName(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;
}
races(index: number, obj?:RaceEntry):RaceEntry|null {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? (obj || new RaceEntry()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
racesLength():number {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
ships(index: number, obj?:ShipEntry):ShipEntry|null {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? (obj || new ShipEntry()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
shipsLength():number {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
protocol(index: number, obj?:BattleActionReport):BattleActionReport|null {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? (obj || new BattleActionReport()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
protocolLength():number {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
static startBattleReport(builder:flatbuffers.Builder) {
builder.startObject(6);
}
static addId(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset) {
builder.addFieldStruct(0, idOffset, 0);
}
static addPlanet(builder:flatbuffers.Builder, planet:bigint) {
builder.addFieldInt64(1, planet, BigInt('0'));
}
static addPlanetName(builder:flatbuffers.Builder, planetNameOffset:flatbuffers.Offset) {
builder.addFieldOffset(2, planetNameOffset, 0);
}
static addRaces(builder:flatbuffers.Builder, racesOffset:flatbuffers.Offset) {
builder.addFieldOffset(3, racesOffset, 0);
}
static createRacesVector(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 startRacesVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addShips(builder:flatbuffers.Builder, shipsOffset:flatbuffers.Offset) {
builder.addFieldOffset(4, shipsOffset, 0);
}
static createShipsVector(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 startShipsVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addProtocol(builder:flatbuffers.Builder, protocolOffset:flatbuffers.Offset) {
builder.addFieldOffset(5, protocolOffset, 0);
}
static createProtocolVector(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 startProtocolVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static endBattleReport(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
builder.requiredField(offset, 4) // id
return offset;
}
static finishBattleReportBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
builder.finish(offset);
}
static finishSizePrefixedBattleReportBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
builder.finish(offset, undefined, true);
}
static createBattleReport(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset, planet:bigint, planetNameOffset:flatbuffers.Offset, racesOffset:flatbuffers.Offset, shipsOffset:flatbuffers.Offset, protocolOffset:flatbuffers.Offset):flatbuffers.Offset {
BattleReport.startBattleReport(builder);
BattleReport.addId(builder, idOffset);
BattleReport.addPlanet(builder, planet);
BattleReport.addPlanetName(builder, planetNameOffset);
BattleReport.addRaces(builder, racesOffset);
BattleReport.addShips(builder, shipsOffset);
BattleReport.addProtocol(builder, protocolOffset);
return BattleReport.endBattleReport(builder);
}
unpack(): BattleReportT {
return new BattleReportT(
(this.id() !== null ? this.id()!.unpack() : null),
this.planet(),
this.planetName(),
this.bb!.createObjList<RaceEntry, RaceEntryT>(this.races.bind(this), this.racesLength()),
this.bb!.createObjList<ShipEntry, ShipEntryT>(this.ships.bind(this), this.shipsLength()),
this.bb!.createObjList<BattleActionReport, BattleActionReportT>(this.protocol.bind(this), this.protocolLength())
);
}
unpackTo(_o: BattleReportT): void {
_o.id = (this.id() !== null ? this.id()!.unpack() : null);
_o.planet = this.planet();
_o.planetName = this.planetName();
_o.races = this.bb!.createObjList<RaceEntry, RaceEntryT>(this.races.bind(this), this.racesLength());
_o.ships = this.bb!.createObjList<ShipEntry, ShipEntryT>(this.ships.bind(this), this.shipsLength());
_o.protocol = this.bb!.createObjList<BattleActionReport, BattleActionReportT>(this.protocol.bind(this), this.protocolLength());
}
}
export class BattleReportT implements flatbuffers.IGeneratedObject {
constructor(
public id: UUIDT|null = null,
public planet: bigint = BigInt('0'),
public planetName: string|Uint8Array|null = null,
public races: (RaceEntryT)[] = [],
public ships: (ShipEntryT)[] = [],
public protocol: (BattleActionReportT)[] = []
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const planetName = (this.planetName !== null ? builder.createString(this.planetName!) : 0);
const races = BattleReport.createRacesVector(builder, builder.createObjectOffsetList(this.races));
const ships = BattleReport.createShipsVector(builder, builder.createObjectOffsetList(this.ships));
const protocol = BattleReport.createProtocolVector(builder, builder.createObjectOffsetList(this.protocol));
return BattleReport.createBattleReport(builder,
(this.id !== null ? this.id!.pack(builder) : 0),
this.planet,
planetName,
races,
ships,
protocol
);
}
}
@@ -0,0 +1,99 @@
// 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);
}
}
@@ -0,0 +1,85 @@
// 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 RaceEntry implements flatbuffers.IUnpackableObject<RaceEntryT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):RaceEntry {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsRaceEntry(bb:flatbuffers.ByteBuffer, obj?:RaceEntry):RaceEntry {
return (obj || new RaceEntry()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsRaceEntry(bb:flatbuffers.ByteBuffer, obj?:RaceEntry):RaceEntry {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new RaceEntry()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
key():bigint {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}
value(obj?:UUID):UUID|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? (obj || new UUID()).__init(this.bb_pos + offset, this.bb!) : null;
}
static startRaceEntry(builder:flatbuffers.Builder) {
builder.startObject(2);
}
static addKey(builder:flatbuffers.Builder, key:bigint) {
builder.addFieldInt64(0, key, BigInt('0'));
}
static addValue(builder:flatbuffers.Builder, valueOffset:flatbuffers.Offset) {
builder.addFieldStruct(1, valueOffset, 0);
}
static endRaceEntry(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
builder.requiredField(offset, 6) // value
return offset;
}
unpack(): RaceEntryT {
return new RaceEntryT(
this.key(),
(this.value() !== null ? this.value()!.unpack() : null)
);
}
unpackTo(_o: RaceEntryT): void {
_o.key = this.key();
_o.value = (this.value() !== null ? this.value()!.unpack() : null);
}
}
export class RaceEntryT implements flatbuffers.IGeneratedObject {
constructor(
public key: bigint = BigInt('0'),
public value: UUIDT|null = null
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
RaceEntry.startRaceEntry(builder);
RaceEntry.addKey(builder, this.key);
RaceEntry.addValue(builder, (this.value !== null ? this.value!.pack(builder) : 0));
return RaceEntry.endRaceEntry(builder);
}
}
@@ -0,0 +1,86 @@
// 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 { BattleReportGroup, BattleReportGroupT } from '../battle/battle-report-group.js';
export class ShipEntry implements flatbuffers.IUnpackableObject<ShipEntryT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):ShipEntry {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsShipEntry(bb:flatbuffers.ByteBuffer, obj?:ShipEntry):ShipEntry {
return (obj || new ShipEntry()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsShipEntry(bb:flatbuffers.ByteBuffer, obj?:ShipEntry):ShipEntry {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new ShipEntry()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
key():bigint {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}
value(obj?:BattleReportGroup):BattleReportGroup|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? (obj || new BattleReportGroup()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
}
static startShipEntry(builder:flatbuffers.Builder) {
builder.startObject(2);
}
static addKey(builder:flatbuffers.Builder, key:bigint) {
builder.addFieldInt64(0, key, BigInt('0'));
}
static addValue(builder:flatbuffers.Builder, valueOffset:flatbuffers.Offset) {
builder.addFieldOffset(1, valueOffset, 0);
}
static endShipEntry(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
unpack(): ShipEntryT {
return new ShipEntryT(
this.key(),
(this.value() !== null ? this.value()!.unpack() : null)
);
}
unpackTo(_o: ShipEntryT): void {
_o.key = this.key();
_o.value = (this.value() !== null ? this.value()!.unpack() : null);
}
}
export class ShipEntryT implements flatbuffers.IGeneratedObject {
constructor(
public key: bigint = BigInt('0'),
public value: BattleReportGroupT|null = null
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const value = (this.value !== null ? this.value!.pack(builder) : 0);
ShipEntry.startShipEntry(builder);
ShipEntry.addKey(builder, this.key);
ShipEntry.addValue(builder, value);
return ShipEntry.endShipEntry(builder);
}
}
@@ -0,0 +1,92 @@
// 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';
export class TechEntry implements flatbuffers.IUnpackableObject<TechEntryT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):TechEntry {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsTechEntry(bb:flatbuffers.ByteBuffer, obj?:TechEntry):TechEntry {
return (obj || new TechEntry()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsTechEntry(bb:flatbuffers.ByteBuffer, obj?:TechEntry):TechEntry {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new TechEntry()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
key():string|null
key(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
key(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;
}
value():number {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
static startTechEntry(builder:flatbuffers.Builder) {
builder.startObject(2);
}
static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, keyOffset, 0);
}
static addValue(builder:flatbuffers.Builder, value:number) {
builder.addFieldFloat32(1, value, 0.0);
}
static endTechEntry(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static createTechEntry(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset, value:number):flatbuffers.Offset {
TechEntry.startTechEntry(builder);
TechEntry.addKey(builder, keyOffset);
TechEntry.addValue(builder, value);
return TechEntry.endTechEntry(builder);
}
unpack(): TechEntryT {
return new TechEntryT(
this.key(),
this.value()
);
}
unpackTo(_o: TechEntryT): void {
_o.key = this.key();
_o.value = this.value();
}
}
export class TechEntryT implements flatbuffers.IGeneratedObject {
constructor(
public key: string|Uint8Array|null = null,
public value: number = 0.0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const key = (this.key !== null ? builder.createString(this.key!) : 0);
return TechEntry.createTechEntry(builder,
key,
this.value
);
}
}
@@ -0,0 +1,65 @@
// 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';
export class UUID implements flatbuffers.IUnpackableObject<UUIDT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):UUID {
this.bb_pos = i;
this.bb = bb;
return this;
}
hi():bigint {
return this.bb!.readUint64(this.bb_pos);
}
lo():bigint {
return this.bb!.readUint64(this.bb_pos + 8);
}
static sizeOf():number {
return 16;
}
static createUUID(builder:flatbuffers.Builder, hi: bigint, lo: bigint):flatbuffers.Offset {
builder.prep(8, 16);
builder.writeInt64(BigInt(lo ?? 0));
builder.writeInt64(BigInt(hi ?? 0));
return builder.offset();
}
unpack(): UUIDT {
return new UUIDT(
this.hi(),
this.lo()
);
}
unpackTo(_o: UUIDT): void {
_o.hi = this.hi();
_o.lo = this.lo();
}
}
export class UUIDT implements flatbuffers.IGeneratedObject {
constructor(
public hi: bigint = BigInt('0'),
public lo: bigint = BigInt('0')
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
return UUID.createUUID(builder,
this.hi,
this.lo
);
}
}