8a236bef14
The cargo-route picker filtered out unidentified planets, so an early-game player who had spotted but not surveyed a destination could not configure a route to it — the engine has no such restriction (`game/internal/controller/route.go.PlanetRouteSet` only checks ownership of the origin and `util.ShortDistance(...) <= FligthDistance`). Drop the unidentified guard and document the contract in `cargo-routes-ux.md` plus a comment over `reachableSet()`. Pick-mode dim now drops both alpha and tint on out-of-reach planets so bright shapes (`STYLE_LOCAL` is `0x6dd2ff`) collapse into a single muted gray. The single-channel `dimAlpha=0.3` was too gentle against the dark theme — the user reported the dim wasn't visible. Tighten to `dimAlpha=0.35 + dimTint=0x303841`; restore both on tear-down. Also threads through the user's `pkg/calc/race.go.FligthDistance` addition: `calc-bridge.md` records the new Go-side reference (the engine's `Race.FlightDistance()` already wraps it), and the picker comment points at the canonical formula location. Tests: - `inspector-planet-cargo-routes.test.ts` adds two cases — a reach-spans-every-kind case (own + foreign + uninhabited + unidentified all picked when in range) and a successful pick to an unidentified destination. - All 356 vitest cases + chromium-desktop / webkit-desktop e2e cargo-routes pass. Co-Authored-By: Claude Opus 4.7 <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.FligthDistance(r.TechLevel(TechDrive))
|
|
}
|
|
|
|
func (r Race) VisibilityDistance() float64 {
|
|
return calc.VisibilityDistance(r.TechLevel(TechDrive))
|
|
}
|