Add terrain biomes jumping and extensible gathering professions
This commit is contained in:
+39
-8
@@ -19,6 +19,7 @@ var StatLinks = map[string][]string{
|
||||
}
|
||||
|
||||
type StatModifier struct {
|
||||
Skill string `json:"skill,omitempty" yaml:"skill"`
|
||||
Stat string `json:"stat" yaml:"stat"`
|
||||
Flat float64 `json:"flat" yaml:"flat"`
|
||||
Percent float64 `json:"percent" yaml:"percent"`
|
||||
@@ -44,12 +45,13 @@ type ItemDefinition struct {
|
||||
Modifiers []StatModifier `json:"modifiers" yaml:"modifiers"`
|
||||
}
|
||||
type Catalog struct {
|
||||
Version int64 `json:"version"`
|
||||
Titles []Title `json:"titles"`
|
||||
Items []ItemDefinition `json:"items"`
|
||||
Stats StatsRules `json:"stats"`
|
||||
RequirementSets []RequirementSet `json:"requirementSets,omitempty"`
|
||||
EffectSets []EffectSet `json:"effectSets,omitempty"`
|
||||
Gathering *GatheringContent `json:"gathering,omitempty"`
|
||||
Version int64 `json:"version"`
|
||||
Titles []Title `json:"titles"`
|
||||
Items []ItemDefinition `json:"items"`
|
||||
Stats StatsRules `json:"stats"`
|
||||
RequirementSets []RequirementSet `json:"requirementSets,omitempty"`
|
||||
EffectSets []EffectSet `json:"effectSets,omitempty"`
|
||||
}
|
||||
|
||||
func KnownStat(stat string) bool {
|
||||
@@ -85,7 +87,7 @@ func ValidateModifiers(modifiers []StatModifier) error {
|
||||
return fmt.Errorf("too many modifiers")
|
||||
}
|
||||
for _, m := range modifiers {
|
||||
if !KnownStat(m.Stat) || math.IsNaN(m.Flat) || math.IsInf(m.Flat, 0) || math.Abs(m.Flat) > 1000000 || math.IsNaN(m.Percent) || math.IsInf(m.Percent, 0) || m.Percent < -100 || m.Percent > 10000 {
|
||||
if (!KnownStat(m.Stat) && !GatheringStat(m.Stat)) || (m.Skill != "" && (!GatheringStat(m.Stat) || !titleID.MatchString(m.Skill))) || math.IsNaN(m.Flat) || math.IsInf(m.Flat, 0) || math.Abs(m.Flat) > 1000000 || math.IsNaN(m.Percent) || math.IsInf(m.Percent, 0) || m.Percent < -100 || m.Percent > 10000 {
|
||||
return fmt.Errorf("invalid modifier for %q", m.Stat)
|
||||
}
|
||||
}
|
||||
@@ -122,6 +124,35 @@ func (item ItemDefinition) Validate() error {
|
||||
return ValidateModifiers(item.Modifiers)
|
||||
}
|
||||
func (c Catalog) Validate() error {
|
||||
if c.Gathering != nil {
|
||||
if err := c.Gathering.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
mods := []StatModifier{}
|
||||
for _, i := range c.Items {
|
||||
mods = append(mods, i.Modifiers...)
|
||||
}
|
||||
for _, t := range c.Titles {
|
||||
mods = append(mods, t.Effects.Modifiers...)
|
||||
}
|
||||
for _, e := range c.EffectSets {
|
||||
mods = append(mods, e.Modifiers...)
|
||||
}
|
||||
for _, v := range c.Gathering.Consumables {
|
||||
mods = append(mods, v.Modifiers...)
|
||||
}
|
||||
if err := c.Gathering.ValidateScopes(mods); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, v := range c.Gathering.Consumables {
|
||||
for _, i := range c.Items {
|
||||
if v.ID == i.ID {
|
||||
return fmt.Errorf("consumable/equipment identity collision")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := c.validateLibrary(); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -165,5 +196,5 @@ func DefaultCatalog() (Catalog, error) {
|
||||
if err != nil {
|
||||
return Catalog{}, err
|
||||
}
|
||||
return Catalog{Version: 1, Titles: b.Titles, Items: b.Items, Stats: *b.Stats}, nil
|
||||
return Catalog{Gathering: b.Gathering, Version: 1, Titles: b.Titles, Items: b.Items, Stats: *b.Stats}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user