Files
galaxy-game/internal/model/game/battle.go
T
2026-01-14 14:40:04 +02:00

33 lines
797 B
Go

package game
import (
"encoding/json"
"github.com/google/uuid"
)
type BattleReport struct {
ID uuid.UUID `json:"id"`
Planet uint `json:"planet"`
PlanetName string `json:"planet_name"`
Races map[int]string `json:"races"`
Ships map[int]string `json:"ships"`
Protocol []BattleActionReport `json:"protocol"`
}
type BattleActionReport struct {
Attacker int `json:"r1"`
AttackerShipClass int `json:"s1"`
Defender int `json:"r2"`
DefenderShipClass int `json:"s2"`
Destroyed bool `json:"d"`
}
func (b BattleReport) MarshalBinary() (data []byte, err error) {
return json.Marshal(&b)
}
func (b *BattleReport) UnmarshalBinary(data []byte) error {
return json.Unmarshal(data, b)
}