1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
package game
// Regression: pins the shipped content fixed alongside the validator work.
// The iron-bar smelt formula must improve with level (it previously capped at
// 50% at every level, destroying half the ore forever), and the pastry/pizza
// dough combines must return their empty containers like bread dough does.
import (
"path/filepath"
"testing"
"thehouseoficarus/internal/item"
)
func TestShippedIronBarSmeltFormulaImprovesWithLevel(t *testing.T) {
store := item.NewItemStore(filepath.Join("..", "..", "data"))
def, err := store.Load("iron_bar")
if err != nil {
t.Fatalf("load iron_bar: %v", err)
}
c := def.FirstCraft()
if c == nil {
t.Fatal("iron_bar has no craft recipe")
}
if c.Success == nil {
t.Fatal("iron_bar must define a success formula (fail_message/smelting failure otherwise unreachable)")
}
if c.Success.PerLevel <= 0 {
t.Errorf("iron_bar success per_level = %v, want > 0 (failure must become rarer with level)", c.Success.PerLevel)
}
if c.Success.Cap <= c.Success.Base {
t.Errorf("iron_bar success base=%v cap=%v, want cap > base (a permanent fixed chance is the defect)",
c.Success.Base, c.Success.Cap)
}
}
func TestShippedDoughRecipesReturnEmptyContainers(t *testing.T) {
store := item.NewItemStore(filepath.Join("..", "..", "data"))
for _, id := range []string{"pastry_dough", "pizza_dough"} {
def, err := store.Load(id)
if err != nil {
t.Fatalf("load %s: %v", id, err)
}
c := def.FirstCraft()
if c == nil {
t.Fatalf("%s has no craft recipe", id)
}
got := map[string]bool{}
for _, e := range c.Ingredients {
for _, bp := range e.Byproducts {
got[bp] = true
}
}
for _, want := range []string{"empty_pot", "empty_bucket"} {
if !got[want] {
t.Errorf("%s must return %s as a byproduct so the container is not destroyed", id, want)
}
}
}
}
|