package content import ( p "aeternalis/server/internal/protocol" "fmt" "regexp" "slices" ) // Appearance is a bounded, versioned presentation recipe. It never changes combat // radius, collision, movement speed, or any character/creature stats. type Appearance = p.Appearance type VisualPreset struct { ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` Appearance Appearance `json:"appearance"` } var appearanceColor = regexp.MustCompile(`^#[0-9a-fA-F]{6}$`) func ValidateAppearance(a *Appearance, families ...string) error { if a == nil { return nil } // Existing worlds retain their original models. if !slices.Contains(families, a.Family) || a.Version != 1 || a.Variant < 0 || a.Variant > 3 || a.Seed < 1 || a.Seed > 65535 || !finiteRange(a.Height, .75, 1.25) || !finiteRange(a.Width, .75, 1.25) || !finiteRange(a.Detail, 0, 1) || !appearanceColor.MatchString(a.Primary) || !appearanceColor.MatchString(a.Secondary) || !appearanceColor.MatchString(a.Accent) { return fmt.Errorf("invalid appearance: choose a supported form, bounded proportions, and six-digit colors") } return nil } func (c Catalog) validateVisuals() error { if len(c.Visuals) > 1024 { return fmt.Errorf("visual library is full") } seen := map[string]bool{} for _, v := range c.Visuals { if !titleID.MatchString(v.ID) || len(v.Name) < 1 || len(v.Name) > 80 || len(v.Description) > 500 || seen[v.ID] { return fmt.Errorf("invalid visual identity") } if err := ValidateAppearance(&v.Appearance, "human", "creature", "tree", "rock", "plant"); err != nil { return err } seen[v.ID] = true } return nil }