Add durable recipe discovery and profession crafting
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package content
|
||||
|
||||
import (
|
||||
"math"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCraftContentValidationAndCurves(t *testing.T) {
|
||||
c, e := DefaultCatalog()
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
r := c.Crafting.Rules
|
||||
if !(r.Failure(1, 10) > r.Failure(1, 1) && r.Failure(20, 1) < r.Failure(1, 1) && r.Loss(20) < r.Loss(1)) {
|
||||
t.Fatal("craft level curves reversed")
|
||||
}
|
||||
if r.Failure(1, 1000) != r.MaxFailure || r.Failure(1000, 1) != r.MinFailure || r.Loss(1000) != r.MinLoss {
|
||||
t.Fatal("curve bounds ignored")
|
||||
}
|
||||
for _, change := range []func(*Catalog){
|
||||
func(c *Catalog) {
|
||||
r := c.Crafting.Recipes[0]
|
||||
r.ID = "duplicate"
|
||||
c.Crafting.Recipes = append(c.Crafting.Recipes, r)
|
||||
},
|
||||
func(c *Catalog) { c.Crafting.Recipes[0].Profession = "missing" },
|
||||
func(c *Catalog) { c.Crafting.Recipes[0].Inputs = map[string]int64{"spear": 1} },
|
||||
func(c *Catalog) { c.Crafting.Recipes[0].Outputs = map[string]int64{"missing": 1} },
|
||||
func(c *Catalog) { c.Crafting.Materials[0].ID = "spear" },
|
||||
func(c *Catalog) { c.Crafting.Rules.BaseFailure = math.NaN() },
|
||||
func(c *Catalog) { c.Items[0].CraftRolls = 9 },
|
||||
func(c *Catalog) { c.Crafting.Recipes[0].Titles = []string{"missing"} },
|
||||
} {
|
||||
fresh, e := DefaultCatalog()
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
change(&fresh)
|
||||
if fresh.Validate() == nil {
|
||||
t.Fatal("invalid craft catalog accepted")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user