Files
galaxy-game/model/report/battle.go
T
Ilia Denisov 8f982278d2 support multi-module (#4)
* add multimodule
* re-package modules
2026-02-22 08:57:19 +02:00

44 lines
1.2 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 {
InBattle bool `json:"inBattle"`
Number uint `json:"num"`
NumberLeft uint `json:"numLeft"`
LoadQuantity Float `json:"loadQuantity"`
Tech map[string]Float `json:"tech"`
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)
}