-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatistic.go
91 lines (78 loc) · 1.68 KB
/
statistic.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
package runequest
import "fmt"
// Statistic is a core element for all characters in an RPG system
type Statistic struct {
Name string
Base int
RuneBonus int
HomelandBonus int
Updates []*Update
Total int
Max int
Min int
ExperienceCheck bool
}
func (s *Statistic) String() string {
text := fmt.Sprintf("%s: %d", s.Name, s.Total)
return text
}
// StatMap gives default ordering for stats
var StatMap = []string{
"STR", "CON", "SIZ", "DEX", "INT", "POW", "CHA"}
// SpiritMap is a base map of stats for Spirits
var SpiritMap = []string{
"INT", "POW", "CHA",
}
// ElementalMap is a base map of stast for Elementals
var ElementalMap = []string{
"SIZ", "POW", "STR",
}
// UpdateStatistic updates values for stats after being modified
func (s *Statistic) UpdateStatistic() {
updates := 0
for _, u := range s.Updates {
updates += u.Value
}
s.Total = s.Base + s.RuneBonus + updates
if s.Total > s.Max {
s.Total = s.Max
}
}
// RuneQuestStats is the base stats for RuneQuest
var RuneQuestStats = map[string]*Statistic{
"STR": &Statistic{
Name: "Strength",
Base: RollDice(6, 1, 0, 3),
Max: 21,
},
"DEX": &Statistic{
Name: "Dexterity",
Base: RollDice(6, 1, 0, 3),
Max: 21,
},
"INT": &Statistic{
Name: "Intelligence",
Base: RollDice(6, 1, 6, 2),
Max: 21,
},
"CON": &Statistic{
Name: "Constitution",
Base: RollDice(6, 1, 6, 2),
Max: 21,
},
"POW": &Statistic{
Name: "Power",
Base: RollDice(6, 1, 0, 3),
Max: 21,
},
"SIZ": &Statistic{
Name: "Size",
Base: RollDice(6, 1, 6, 2),
Max: 21,
},
"CHA": &Statistic{
Name: "Charisma",
Base: RollDice(6, 1, 0, 3),
Max: 21,
},
}