-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.go
162 lines (148 loc) · 3.78 KB
/
stats.go
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package aifiver
import "log"
// Opinion by type
// - Same trait
// - Opposite trait
// - Attraction
type Opinion int
const (
TOpinionSame Opinion = iota // Same trait
TOpinionOpposite // Opposite trait
TOpinionAttraction // Attraction
)
// String implements the stringer function for an opinion.
func (o Opinion) String() string {
switch o {
case TOpinionSame:
return "same trait"
case TOpinionOpposite:
return "opposite trait"
case TOpinionAttraction:
return "attraction"
}
return "unknown"
}
// Fate that can befall an individual
// - Early death
// - Capture in battle
// - Death in battle
// - Accidental injury
// - Bad investment
// - Scheme fallacy
// - Scheme discovery
type Fate int
const (
TFateEarlyDeath Fate = iota // Early death
TFateCaptureInBattle // Capture in battle
TFateDeathInBattle // Death in battle
TFateAccident // Accidental injury
TFateBadInvestment // Bad investment
TFateSchemeFallacy // Scheme fallacy
TFateSchemeDiscovery // Scheme discovery
)
// String implements the stringer function for a fate.
func (f Fate) String() string {
switch f {
case TFateEarlyDeath:
return "early death"
case TFateCaptureInBattle:
return "capture"
case TFateDeathInBattle:
return "death"
case TFateAccident:
return "accident"
case TFateBadInvestment:
return "investment"
case TFateSchemeFallacy:
return "scheme fallacy"
case TFateSchemeDiscovery:
return "scheme discovery"
}
return "unknown"
}
// AIMod influences a specific aspect of decision making
// - AI Boldness
// - AI Compassion
// - AI Energy
// - AI Greed
// - AI Honor
// - AI Rationality
// - AI Sociability
// - AI Vengefulness
type AIMod int
const (
TAIModBoldness AIMod = iota // AI Boldness
TAIModCompassion // AI Compassion
TAIModEnergy // AI Energy
TAIModGreed // AI Greed
TAIModHonor // AI Honor
TAIModRationality // AI Rationality
TAIModSociability // AI Sociability
TAIModVengefulness // AI Vengefulness
)
// String implements the stringer function for an ai modifier.
func (a AIMod) String() string {
switch a {
case TAIModBoldness:
return "boldness"
case TAIModCompassion:
return "compassion"
case TAIModEnergy:
return "energy"
case TAIModGreed:
return "greed"
case TAIModHonor:
return "honor"
case TAIModRationality:
return "rationality"
case TAIModSociability:
return "sociability"
case TAIModVengefulness:
return "vengefulness"
}
return "unknown"
}
type Stats struct {
Opinion map[Opinion]int // Opinion modifiers
Fate map[Fate]int // Chance modifier for fates
Skill map[Skill]int // Skill modifiers
AI map[AIMod]int // AI modifiers
}
func NewStats() *Stats {
return &Stats{
Opinion: make(map[Opinion]int),
Fate: make(map[Fate]int),
Skill: make(map[Skill]int),
AI: make(map[AIMod]int),
}
}
func (s *Stats) add(st *Stats) {
for key, val := range st.Opinion {
s.Opinion[key] += val
}
for key, val := range st.Fate {
s.Fate[key] += val
}
for key, val := range st.Skill {
s.Skill[key] += val
}
for key, val := range st.AI {
s.AI[key] += val
}
}
// Log logs the stats.
func (s *Stats) Log() {
log.Println("Stats:")
for key, val := range s.Opinion {
log.Printf(" Opinion %s: %v\n", key, val)
}
for key, val := range s.Fate {
log.Printf(" Fate %s: %v\n", key, val)
}
for key, val := range s.Skill {
log.Printf(" Skill %s: %v\n", key, val)
}
for key, val := range s.AI {
log.Printf(" AI %s: %v\n", key, val)
}
}