2bd1b54936
Adds the gear-icon popover on the map view with per-game persistence of every category toggle plus the wrap-mode radio. Hide-by-id and visibility-fog facilities land on the renderer so every flip applies within one frame without a Pixi remount; the wrap-mode toggle keeps its existing remount + camera-preserve path. A new server-side turn force-resets every flag to defaults so a hidden category never makes the player miss the next turn's news. Also fixes the FligthDistance → FlightDistance typo in pkg/calc/race.go (plus the single Go caller); the TS side keeps duplicating the formula until a race-level WASM bridge lands. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
64 lines
1.3 KiB
Go
64 lines
1.3 KiB
Go
package game
|
|
|
|
import (
|
|
"galaxy/calc"
|
|
"strings"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type Relation string
|
|
|
|
const (
|
|
RelationWar Relation = "WAR"
|
|
RelationPeace Relation = "PEACE"
|
|
)
|
|
|
|
var (
|
|
relationSet = map[string]Relation{
|
|
strings.ToLower(RelationWar.String()): RelationWar,
|
|
strings.ToLower(RelationPeace.String()): RelationPeace,
|
|
}
|
|
)
|
|
|
|
type Race struct {
|
|
ID uuid.UUID `json:"id"`
|
|
Name string `json:"name"`
|
|
TTL uint `json:"ttl"`
|
|
Extinct bool `json:"extinct"`
|
|
Votes Float `json:"votes"`
|
|
VoteFor uuid.UUID `json:"voteFor"`
|
|
Relations []RaceRelation `json:"relations"`
|
|
Tech TechSet `json:"tech"`
|
|
Sciences []Science `json:"science,omitempty"`
|
|
ShipTypes []ShipType `json:"shipType,omitempty"`
|
|
}
|
|
|
|
func ParseRelation(v string) (Relation, bool) {
|
|
if v, ok := relationSet[strings.ToLower(v)]; ok {
|
|
return v, ok
|
|
}
|
|
return Relation(""), false
|
|
}
|
|
|
|
func (r Relation) String() string {
|
|
return string(r)
|
|
}
|
|
|
|
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 calc.FlightDistance(r.TechLevel(TechDrive))
|
|
}
|
|
|
|
func (r Race) VisibilityDistance() float64 {
|
|
return calc.VisibilityDistance(r.TechLevel(TechDrive))
|
|
}
|