Add biome revisions readable content and visible projectile outcomes
This commit is contained in:
@@ -31,11 +31,13 @@ type ResourceDefinition struct {
|
||||
Biomes []string `json:"biomes" yaml:"biomes"`
|
||||
}
|
||||
type BiomeDefinition struct {
|
||||
ID string `json:"id" yaml:"id"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
Description string `json:"description" yaml:"description"`
|
||||
Color string `json:"color" yaml:"color"`
|
||||
Weight int64 `json:"weight" yaml:"weight"`
|
||||
Revision int64 `json:"revision,omitempty" yaml:"revision"`
|
||||
Resources []string `json:"resources" yaml:"resources"`
|
||||
ID string `json:"id" yaml:"id"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
Description string `json:"description" yaml:"description"`
|
||||
Color string `json:"color" yaml:"color"`
|
||||
Weight int64 `json:"weight" yaml:"weight"`
|
||||
}
|
||||
type GatheringConsumable struct {
|
||||
ID string `json:"id" yaml:"id"`
|
||||
@@ -45,10 +47,11 @@ type GatheringConsumable struct {
|
||||
Modifiers []StatModifier `json:"modifiers" yaml:"modifiers"`
|
||||
}
|
||||
type GatheringContent struct {
|
||||
Skills []GatheringSkill `json:"skills" yaml:"skills"`
|
||||
Resources []ResourceDefinition `json:"resources" yaml:"resources"`
|
||||
Biomes []BiomeDefinition `json:"biomes" yaml:"biomes"`
|
||||
Consumables []GatheringConsumable `json:"consumables" yaml:"consumables"`
|
||||
BiomeHistory []BiomeDefinition `json:"biomeHistory,omitempty" yaml:"biomeHistory"`
|
||||
Skills []GatheringSkill `json:"skills" yaml:"skills"`
|
||||
Resources []ResourceDefinition `json:"resources" yaml:"resources"`
|
||||
Biomes []BiomeDefinition `json:"biomes" yaml:"biomes"`
|
||||
Consumables []GatheringConsumable `json:"consumables" yaml:"consumables"`
|
||||
}
|
||||
type GatheringRules struct {
|
||||
FailureBase float64 `json:"failureBase" yaml:"failureBase"`
|
||||
@@ -84,6 +87,9 @@ func (r GatheringRules) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (g GatheringContent) Validate() error {
|
||||
if len(g.BiomeHistory) > 1024 {
|
||||
return fmt.Errorf("biome revision history limit reached")
|
||||
}
|
||||
if len(g.Skills) < 1 || len(g.Skills) > 64 || len(g.Resources) > 256 || len(g.Biomes) < 1 || len(g.Biomes) > 32 || len(g.Consumables) > 256 {
|
||||
return fmt.Errorf("invalid gathering content counts")
|
||||
}
|
||||
@@ -125,6 +131,18 @@ func (g GatheringContent) Validate() error {
|
||||
seen[id] = true
|
||||
}
|
||||
}
|
||||
for _, b := range append(slices.Clone(g.Biomes), g.BiomeHistory...) {
|
||||
if b.Revision < 0 || len(b.Resources) > 256 {
|
||||
return fmt.Errorf("invalid biome revision")
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
for _, id := range b.Resources {
|
||||
if seen[id] || !slices.ContainsFunc(g.Resources, func(r ResourceDefinition) bool { return r.ID == id }) {
|
||||
return fmt.Errorf("unknown/duplicate biome resource %q", id)
|
||||
}
|
||||
seen[id] = true
|
||||
}
|
||||
}
|
||||
for _, c := range g.Consumables {
|
||||
if !identity(c.ID, c.Name, c.Description) || !finiteRange(c.Seconds, 1, 86400) || len(c.Modifiers) < 1 {
|
||||
return fmt.Errorf("invalid consumable %q", c.ID)
|
||||
|
||||
Reference in New Issue
Block a user