43 lines
818 B
Go
43 lines
818 B
Go
package game
|
|
|
|
import "github.com/google/uuid"
|
|
|
|
type Race struct {
|
|
ID uuid.UUID `json:"id"`
|
|
Name string `json:"name"`
|
|
Extinct bool `json:"extinct"`
|
|
|
|
Vote uuid.UUID `json:"vote"`
|
|
Relations []RaceRelation `json:"relations"`
|
|
|
|
Tech TechSet `json:"tech"`
|
|
|
|
Sciences []Science `json:"science,omitempty"`
|
|
|
|
ShipTypes []ShipType `json:"shipType,omitempty"`
|
|
}
|
|
|
|
type Relation string
|
|
|
|
const (
|
|
RelationWar Relation = "War"
|
|
RelationPeace Relation = "Peace"
|
|
)
|
|
|
|
type RaceRelation struct {
|
|
RaceID uuid.UUID `json:"raceId"`
|
|
Relation Relation `json:"relation"`
|
|
}
|
|
|
|
func (r Race) TechLevel(t Tech) float64 {
|
|
return r.Tech.Value(t)
|
|
}
|
|
|
|
func (r Race) FlightDistance() float64 {
|
|
return r.TechLevel(TechDrive) * 40
|
|
}
|
|
|
|
func (r Race) VisibilityDistance() float64 {
|
|
return r.TechLevel(TechDrive) * 30
|
|
}
|