feat: Cards writings and balancing (M8)
This commit is contained in:
+18
-3
@@ -114,7 +114,10 @@ func (c *cardChecker) conditions(id string, cond obj) {
|
||||
for _, bound := range []string{"min", "max"} {
|
||||
m, _ := cond[bound].(obj)
|
||||
for k, v := range m {
|
||||
okKey := c.condStats[k] || (strings.HasPrefix(k, "q:") && c.sectors[strings.TrimPrefix(k, "q:")])
|
||||
okKey := c.condStats[k] ||
|
||||
(strings.HasPrefix(k, "q:") && c.sectors[strings.TrimPrefix(k, "q:")]) ||
|
||||
(strings.HasPrefix(k, "ratio:") && c.sectors[strings.TrimPrefix(k, "ratio:")]) ||
|
||||
(strings.HasPrefix(k, "tax:") && c.revenues[strings.TrimPrefix(k, "tax:")] && k != "tax:other")
|
||||
if !okKey {
|
||||
t.Errorf("%s.conditions.%s: unknown stat %q", id, bound, k)
|
||||
}
|
||||
@@ -200,6 +203,7 @@ func TestCards(t *testing.T) {
|
||||
|
||||
followOnly := map[string]bool{}
|
||||
total := 0
|
||||
perCategory := map[string]int{}
|
||||
for _, f := range index["files"].([]any) {
|
||||
file := f.(string)
|
||||
raw, err := web.Files.ReadFile("data/cards/" + file)
|
||||
@@ -220,6 +224,7 @@ func TestCards(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
total++
|
||||
perCategory[stem]++
|
||||
if c.ids[id] {
|
||||
t.Errorf("duplicate card id %s", id)
|
||||
}
|
||||
@@ -281,7 +286,17 @@ func TestCards(t *testing.T) {
|
||||
t.Errorf("%s: flag %q is used in conditions but never set by any card", by, fl)
|
||||
}
|
||||
}
|
||||
if total < 60 {
|
||||
t.Errorf("only %d cards; M4 expects at least 60", total)
|
||||
if total < 800 {
|
||||
t.Errorf("only %d cards; M7 expects at least 800", total)
|
||||
}
|
||||
minPerCategory := map[string]int{
|
||||
"economy": 90, "social": 60, "health": 55, "education": 55, "security": 60, "defense": 55,
|
||||
"foreign": 60, "industry": 60, "transport": 55, "housing": 35, "environment": 45,
|
||||
"justice": 55, "culture": 35, "crises": 45,
|
||||
}
|
||||
for cat, min := range minPerCategory {
|
||||
if perCategory[cat] < min {
|
||||
t.Errorf("category %s has %d cards; M7 expects at least %d", cat, perCategory[cat], min)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user