Files
galaxy-game/internal/model/report/battle.go
T
2026-02-04 13:57:25 +02:00

51 lines
1.5 KiB
Go

package report
import (
"encoding/json"
"github.com/google/uuid"
)
type BattleReport struct {
ID uuid.UUID `json:"id"`
Planet uint `json:"planet"`
PlanetName string `json:"planetName"`
Races map[int]uuid.UUID `json:"races"`
Ships map[int]BattleReportGroup `json:"ships"`
Protocol []BattleActionReport `json:"protocol"`
}
type BattleReportGroup struct {
// OwnerID uuid.UUID `json:"-"` // make report: visible ship class
InBattle bool `json:"inBattle"`
Number uint `json:"num"`
NumberLeft uint `json:"numLeft"`
// ClassArmament uint `json:"-"` // make report: visible ship class
// ClassMass Float `json:"-"` // make report: visible ship class
LoadQuantity Float `json:"loadQuantity"`
Tech map[string]Float `json:"tech"`
// DriveTech Float `json:"drive"`
// WeaponsTech Float `json:"weapons"`
// ShieldsTech Float `json:"shields"`
// CargoTech Float `json:"cargo"`
Race string `json:"race"`
ClassName string `json:"className"`
LoadType string `json:"loadType"`
}
type BattleActionReport struct {
Attacker int `json:"a"`
AttackerShipClass int `json:"sa"`
Defender int `json:"d"`
DefenderShipClass int `json:"sd"`
Destroyed bool `json:"x"`
}
func (b BattleReport) MarshalBinary() (data []byte, err error) {
return json.Marshal(&b)
}
func (b *BattleReport) UnmarshalBinary(data []byte) error {
return json.Unmarshal(data, b)
}