48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
package report
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type BattleReport struct {
|
|
ID uuid.UUID `json:"id"`
|
|
Turn uint `json:"turn"`
|
|
Planet uint `json:"planet"`
|
|
PlanetName string `json:"planet_name"`
|
|
Races map[int]uuid.UUID `json:"races"`
|
|
Ships map[int]BattleReportGroup `json:"ships"`
|
|
Protocol []BattleActionReport `json:"protocol"`
|
|
}
|
|
|
|
type BattleReportGroup struct {
|
|
OwnerID uuid.UUID `json:"ownerId"`
|
|
InBattle bool `json:"inBattle"`
|
|
Number uint `json:"num"`
|
|
NumberLeft uint `json:"numLeft"`
|
|
ClassName string `json:"className"`
|
|
LoadType string `json:"loadType"`
|
|
LoadQuantity Float `json:"loadQuantity"`
|
|
Drive Float `json:"drive"`
|
|
Weapons Float `json:"wwapons"`
|
|
Shields Float `json:"shields"`
|
|
Cargo Float `json:"cargo"`
|
|
}
|
|
|
|
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)
|
|
}
|