Add terrain biomes jumping and extensible gathering professions

This commit is contained in:
dingo
2026-09-08 21:54:23 -04:00
parent 141cb9e6b2
commit df7b245ca7
34 changed files with 1895 additions and 184 deletions
+22 -2
View File
@@ -17,6 +17,11 @@ var ErrCatalogInvalid = errors.New("invalid catalog change")
var catalogRequestID = regexp.MustCompile(`^[a-f0-9-]{32,36}$`)
type CatalogChange struct {
GatheringSkill *content.GatheringSkill `json:"gatheringSkill,omitempty"`
Resource *content.ResourceDefinition `json:"resource,omitempty"`
Biome *content.BiomeDefinition `json:"biome,omitempty"`
Consumable *content.GatheringConsumable `json:"consumable,omitempty"`
ID string `json:"id"`
ExpectedVersion int64 `json:"expectedVersion"`
Op string `json:"op"`
@@ -37,7 +42,7 @@ type CatalogResult struct {
// Explicit definition IDs are reserved for trusted seed/import code. Browser
// publications omit them; the server assigns an ID after resolving request replay.
func (c CatalogChange) HasDefinitionID() bool {
return (c.Title != nil && c.Title.ID != "") || (c.Item != nil && c.Item.ID != "") || (c.RequirementSet != nil && c.RequirementSet.ID != "") || (c.EffectSet != nil && c.EffectSet.ID != "")
return (c.GatheringSkill != nil && c.GatheringSkill.ID != "") || (c.Resource != nil && c.Resource.ID != "") || (c.Biome != nil && c.Biome.ID != "") || (c.Consumable != nil && c.Consumable.ID != "") || (c.Title != nil && c.Title.ID != "") || (c.Item != nil && c.Item.ID != "") || (c.RequirementSet != nil && c.RequirementSet.ID != "") || (c.EffectSet != nil && c.EffectSet.ID != "")
}
type CatalogAudit struct {
@@ -94,6 +99,13 @@ func decodeCatalog(version int64, raw string) (content.Catalog, error) {
if catalog.Version != version {
return catalog, errors.New("catalog version mismatch")
}
if catalog.Gathering == nil {
b, err := content.Load()
if err != nil {
return catalog, err
}
catalog.Gathering = b.Gathering
}
return catalog, catalog.Validate()
}
func (d *DB) Catalog(ctx context.Context) (content.Catalog, error) {
@@ -123,12 +135,20 @@ func (c CatalogChange) validate() error {
}
valid := false
count := 0
for _, present := range []bool{c.Title != nil, c.Item != nil, c.Stats != nil, c.RequirementSet != nil, c.EffectSet != nil} {
for _, present := range []bool{c.GatheringSkill != nil, c.Resource != nil, c.Biome != nil, c.Consumable != nil, c.Title != nil, c.Item != nil, c.Stats != nil, c.RequirementSet != nil, c.EffectSet != nil} {
if present {
count++
}
}
switch c.Op {
case "create-gathering-skill":
valid = c.GatheringSkill != nil
case "create-resource":
valid = c.Resource != nil
case "create-biome":
valid = c.Biome != nil
case "create-consumable":
valid = c.Consumable != nil
case "create-title":
valid = c.Title != nil && c.Item == nil && c.Stats == nil
case "create-item":