Skip to content

Commit 242991b

Browse files
committed
Added in config file for stats
1 parent 24cf5e9 commit 242991b

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package configs
2+
3+
type Statistics struct {
4+
BaseStats StatDefaults `yaml:"BaseStats"`
5+
Factors StatFactors `yaml:"Factors"`
6+
}
7+
8+
type StatDefaults struct {
9+
Strength ConfigInt `yaml:"Strength"` // Muscular strength
10+
Speed ConfigInt `yaml:"Speed"` // Speed and agility
11+
Smarts ConfigInt `yaml:"Smarts"` // Intelligence and wisdom
12+
Vitality ConfigInt `yaml:"Vitality"` // Health and stamina
13+
Mysticism ConfigInt `yaml:"Mysticism"` // Magic and mana
14+
Perception ConfigInt `yaml:"Perception"` // How well you notice things
15+
}
16+
17+
type StatFactors struct {
18+
BaseModFactor ConfigFloat `yaml:"BaseModFactor"` // How much of a scaling to apply to levels before multiplying by racial stat
19+
NaturalGainsModFactor ConfigFloat `yaml:"NaturalGainsModFactor"` // Free stats gained per level modded by this
20+
}
21+
22+
func (s *Statistics) Validate() {
23+
// Validate base stats are reasonable (minimum 1)
24+
if s.BaseStats.Strength < 1 {
25+
s.BaseStats.Strength = 1
26+
}
27+
if s.BaseStats.Speed < 1 {
28+
s.BaseStats.Speed = 1
29+
}
30+
if s.BaseStats.Smarts < 1 {
31+
s.BaseStats.Smarts = 1
32+
}
33+
if s.BaseStats.Vitality < 1 {
34+
s.BaseStats.Vitality = 1
35+
}
36+
if s.BaseStats.Mysticism < 1 {
37+
s.BaseStats.Mysticism = 1
38+
}
39+
if s.BaseStats.Perception < 1 {
40+
s.BaseStats.Perception = 1
41+
}
42+
43+
// Validate factors are reasonable
44+
if s.Factors.BaseModFactor <= 0 {
45+
s.Factors.BaseModFactor = 0.3333333334 // default
46+
}
47+
if s.Factors.NaturalGainsModFactor <= 0 {
48+
s.Factors.NaturalGainsModFactor = 0.5 // default
49+
}
50+
}
51+
52+
func GetStatisticsConfig() Statistics {
53+
configDataLock.RLock()
54+
defer configDataLock.RUnlock()
55+
56+
if !configData.validated {
57+
configData.Validate()
58+
}
59+
return configData.Statistics
60+
}

0 commit comments

Comments
 (0)