package content import "fmt" type ItemUseEffect struct { Kind string `json:"kind" yaml:"kind"` Amount float64 `json:"amount" yaml:"amount"` } func (e ItemUseEffect) Valid() bool { return (e.Kind == "heal" || e.Kind == "weapon-coating") && finiteRange(e.Amount, .1, 10000) } type InventoryRules struct { StopWeightRatio float64 `yaml:"stopWeightRatio"` SlowdownExponent float64 `yaml:"slowdownExponent"` BreakdownBase float64 `yaml:"breakdownBase"` BreakdownMax float64 `yaml:"breakdownMax"` BreakdownLevelScale float64 `yaml:"breakdownLevelScale"` RecipeChance float64 `yaml:"recipeChance"` ActionCooldown float64 `yaml:"actionCooldown"` } func (r InventoryRules) Validate() error { if r.StopWeightRatio != 2 || !finiteRange(r.SlowdownExponent, 1, 4) || !finiteRange(r.BreakdownBase, 0, 100) || !finiteRange(r.BreakdownMax, r.BreakdownBase, 99) || !finiteRange(r.BreakdownLevelScale, 1, 1000) || r.RecipeChance != .01 || !finiteRange(r.ActionCooldown, .1, 30) { return fmt.Errorf("invalid inventory rules") } return nil }