Add biome revisions readable content and visible projectile outcomes
This commit is contained in:
@@ -17,6 +17,7 @@ var ErrCatalogInvalid = errors.New("invalid catalog change")
|
||||
var catalogRequestID = regexp.MustCompile(`^[a-f0-9-]{32,36}$`)
|
||||
|
||||
type CatalogChange struct {
|
||||
TargetID string `json:"targetId,omitempty"`
|
||||
Attack *content.CombatAttack `json:"attack,omitempty"`
|
||||
Mob *content.MobDefinition `json:"mob,omitempty"`
|
||||
Loot *content.LootTable `json:"loot,omitempty"`
|
||||
@@ -141,6 +142,12 @@ func (d *DB) CatalogAfter(ctx context.Context, after int64) (*content.Catalog, e
|
||||
return &catalog, err
|
||||
}
|
||||
func (c CatalogChange) validate() error {
|
||||
if (c.Op == "update-biome") != (c.TargetID != "") {
|
||||
return fmt.Errorf("%w: only biome edits require an existing target", ErrCatalogInvalid)
|
||||
}
|
||||
if c.Biome != nil && c.Biome.Revision != 0 {
|
||||
return fmt.Errorf("%w: revisions are assigned by the server", ErrCatalogInvalid)
|
||||
}
|
||||
if !catalogRequestID.MatchString(c.ID) || c.ExpectedVersion < 1 || len(c.Reason) < 5 || len(c.Reason) > 240 {
|
||||
return fmt.Errorf("%w: request ID, current version and 5-240 character reason required", ErrCatalogInvalid)
|
||||
}
|
||||
@@ -166,6 +173,8 @@ func (c CatalogChange) validate() error {
|
||||
valid = c.Resource != nil
|
||||
case "create-biome":
|
||||
valid = c.Biome != nil
|
||||
case "update-biome":
|
||||
valid = c.Biome != nil && c.Biome.ID == ""
|
||||
case "create-consumable":
|
||||
valid = c.Consumable != nil
|
||||
case "create-title":
|
||||
|
||||
Reference in New Issue
Block a user