Files
galaxy-game/internal/model/report/battle.go
T
2026-02-03 23:41:18 +02:00

51 lines
1.6 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"`
// PlanetOwnedID uuid.UUID `json:"-"` // TODO: need this? for make report: bombings: initial owher of a planet
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"`
DriveTech Float `json:"drive"`
WeaponsTech Float `json:"wwapons"`
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)
}