-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.go
182 lines (153 loc) · 4.05 KB
/
events.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
package runequest
import "fmt"
// FamilyMember tracks family history through previous character history
type FamilyMember struct {
Name string
Homeland string
Occupation string
Relation string
Born int
Died int
Alive bool
Description string
}
// Year represents the base element of a history
type Year struct {
Year int
HomelandModifiers map[string]int
// Map Homeland name to modifier on d20 roll
OccupationModifiers map[string]int
// Map Occupation name to modifier on d20 roll
Events map[int]*Event
}
// Event represents a full event in previous character history
type Event struct {
Year int
Name string
Start bool
End bool
Description string
Participant string
// Character, Parent, Grandparent
HomelandModifiers map[string]int
// Map Homeland name to modifier on d20 roll
OccupationModifiers map[string]int
// Map Occupation name to modifier on d20 roll
Results []EventResult
FollowingEventSlug string
FollowingEventMod int
Slug string
}
// EventResult is a specific die range of random results from previous
// Character history
type EventResult struct {
Range []int
Description string
Skills []Skill
Passions []Ability
Lunars int
Reputation int
Equipment string
Lethal bool
Boon bool
RandomDeath bool
ImmediateFollowEvent string
ImmediateFollowMod int
NextFollowEvent string
NextFollowMod int
}
// Boon represents a random benefit from an EventResult
type Boon struct {
Range []int
Description string
Skills []Skill
Passsions []Ability
Lunars int
Reputation int
Equipment string
}
// RandomCauseOfDeath is a random extinction event for family
type RandomCauseOfDeath struct {
Range []int
Description string
Skills []Skill
Passsions []Ability
Lunars int
Reputation int
Equipment string
Lethal bool
}
// DetermineHistory generates a character's lifepath history
func DetermineHistory(c *Character, e Event, m int) (string, bool) {
var homeland, occupation string
fmt.Println(e.Participant)
switch {
case e.Participant == "Grandparent":
if !c.Grandparent.Alive {
return "Grandparent deceased", false
}
homeland = c.Grandparent.Homeland
occupation = c.Grandparent.Occupation
case e.Participant == "Parent":
if !c.Parent.Alive {
return "Parent deceased", false
}
homeland = c.Parent.Homeland
occupation = c.Parent.Occupation
fmt.Println("Character")
homeland = c.Homeland.Name
occupation = c.Occupation.Name
}
hlBonus, ok := e.HomelandModifiers[homeland]
if !ok {
return "didn't participate", false
}
ocBonus, ok := e.OccupationModifiers[occupation]
if !ok {
ocBonus = 0
}
roll := RollDice(20, 1, hlBonus+ocBonus+m, 1)
if roll > 20 {
roll = 20
}
if roll < 1 {
roll = 1
}
for _, r := range e.Results {
if IsInIntArray(r.Range, roll) {
fmt.Println(r.Description, e.End)
c.Lunars += r.Lunars
c.Abilities["Reputation"].CreationBonusValue += r.Reputation
text := r.Description
for _, s := range r.Skills {
// Update skills
text += "\nSkills: "
c.Skills[s.Name].Updates = append(c.Skills[s.Name].Updates, s.Updates[0])
text += fmt.Sprintf("%s +%d%%", s.Name, s.Updates[0].Value)
}
for _, p := range r.Passions {
// Update skills
text += "\nPassions: "
_, ok := c.Abilities[p.Name]
if !ok {
c.Abilities[p.Name] = &Ability{
CoreString: p.CoreString,
UserString: p.UserString,
Base: 60,
Updates: []*Update{},
}
}
fmt.Println(r.ImmediateFollowEvent, r.ImmediateFollowMod)
c.Abilities[p.Name].Updates = append(c.Abilities[p.Name].Updates, p.Updates[0])
text += fmt.Sprintf("%s +%d%%", p.Name, p.Updates[0].Value)
}
e.Description = text
e.Results = []EventResult{r}
c.History = append(c.History, &e)
if e.End {
return e.Name + " Ending", true
}
}
}
return e.Name + " Continuing", false
}