Add terrain biomes jumping and extensible gathering professions
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"aeternalis/server/content"
|
||||
"aeternalis/server/internal/game"
|
||||
"context"
|
||||
"errors"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestReusableGatheringCatalogPublication(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
db, err := Open(ctx, "file:"+filepath.ToSlash(filepath.Join(t.TempDir(), "gathering.db")))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer db.Close()
|
||||
c, _ := db.Catalog(ctx)
|
||||
publish := func(change CatalogChange) string {
|
||||
t.Helper()
|
||||
change.ID = game.ID()
|
||||
change.ExpectedVersion = c.Version
|
||||
change.Reason = "Gathering content test"
|
||||
if _, err := db.PreviewCatalog(ctx, change); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
result, err := db.PublishCatalog(ctx, "admin", change)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
replay, err := db.PublishCatalog(ctx, "admin", change)
|
||||
if err != nil || replay != result {
|
||||
t.Fatal("publication replay changed identity", err)
|
||||
}
|
||||
c, err = db.Catalog(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return result.ID
|
||||
}
|
||||
skill := publish(CatalogChange{Op: "create-gathering-skill", GatheringSkill: &content.GatheringSkill{Name: "Forager", BaseXP: 20, XPPerLevel: 10, MaxLevel: 1000}})
|
||||
biome := publish(CatalogChange{Op: "create-biome", Biome: &content.BiomeDefinition{Name: "Wetlands", Color: "#445566", Weight: 1}})
|
||||
publish(CatalogChange{Op: "create-resource", Resource: &content.ResourceDefinition{Name: "Reeds", SkillID: skill, Model: "herb", Output: "self", RequiredLevel: 2, Amount: 2, XP: 5, Seconds: 1, RespawnSeconds: 30, Density: 4, Biomes: []string{biome}}})
|
||||
publish(CatalogChange{Op: "create-consumable", Consumable: &content.GatheringConsumable{Name: "Forager tonic", Seconds: 60, Modifiers: []content.StatModifier{{Stat: "gatheringLevel", Skill: skill, Flat: 5}}}})
|
||||
bad := CatalogChange{ID: game.ID(), ExpectedVersion: c.Version, Reason: "Invalid skill scope", Op: "create-effect-set", EffectSet: &content.EffectSet{Name: "Bad scope", Modifiers: []content.StatModifier{{Stat: "gatheringXP", Skill: "missing", Percent: 50}}}}
|
||||
if _, err := db.PublishCatalog(ctx, "admin", bad); !errors.Is(err, ErrCatalogInvalid) {
|
||||
t.Fatal("unknown skill reference accepted", err)
|
||||
}
|
||||
after, _ := db.Catalog(ctx)
|
||||
if after.Version != c.Version {
|
||||
t.Fatal("invalid publication mutated version")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user