-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcivReligionsNaming.go
127 lines (114 loc) · 3.86 KB
/
civReligionsNaming.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
package genworldvoronoi
import (
"strings"
"github.com/Flokey82/go_gens/genlanguage"
"github.com/Flokey82/go_gens/genreligion"
"github.com/Flokey82/go_gens/genstory"
)
func (m *Civ) getFolkReligionName(rlgGen *genreligion.Generator, c *Culture, lang *genlanguage.Language, deity *genreligion.Deity, rel *genreligion.Classification, r int) (*genstory.Generated, string) {
// Calculate all available tokens.
//
// TODO: Find a way to only generate the tokens when needed.
// This might work by using the modifier functions of the generator,
// which are only called when a token is used.
var tokens []genstory.TokenReplacement
tokens = append(tokens, genstory.TokenReplacement{
Token: genreligion.TokenCulture,
Replacement: c.Name,
}, genstory.TokenReplacement{
Token: genreligion.TokenType,
Replacement: rel.Type,
})
if deity != nil {
tokens = append(tokens, genstory.TokenReplacement{
Token: genreligion.TokenSurpreme,
Replacement: deity.Name,
})
}
// Generate the name and method.
gen, err := rlgGen.GenFaithName(tokens)
if err != nil {
return nil, err.Error()
}
return gen, ReligionExpCulture
}
// getOrganizedReligionName generates a name for the given form and deity at the given center.
// This code is based on:
// https://github.com/Azgaar/Fantasy-Map-Generator/blob/master/modules/religions-generator.js
func (m *Civ) getOrganizedReligionName(rlgGen *genreligion.Generator, c *Culture, lang *genlanguage.Language, deity *genreligion.Deity, rel *genreligion.Classification, r int) (*genstory.Generated, string) {
// Returns the name of the city, -state, or culture at the given region.
place := func() string {
// Get the name of the city at the region.
for _, city := range m.Cities {
if city.ID == r {
return city.Name
}
}
// If unsuccessful, Check if we have a state at the region
// and use the capital name.
if stateId := m.RegionToCityState[r]; stateId >= 0 {
for _, city := range m.Cities {
if city.ID == stateId {
return city.Name
}
}
}
// TODO: Try the empire name.
return "" // If unsuccessful, return an empty string.
}
// Calculate all available tokens.
//
// TODO: Find a way to only generate the tokens when needed.
// This might work by using the modifier functions of the generator,
// which are only called when a token is used.
var tokens []genstory.TokenReplacement
tokens = append(tokens, genstory.TokenReplacement{
Token: genreligion.TokenCulture,
Replacement: c.Name,
}, genstory.TokenReplacement{
Token: genreligion.TokenType,
Replacement: rel.Type,
}, genstory.TokenReplacement{
Token: genreligion.TokenRandom,
Replacement: lang.MakeName(), // TODO: Use the religion generator to generat religous terms.
})
// Try to find a location token.
if place := place(); place != "" {
tokens = append(tokens, genstory.TokenReplacement{
Token: genreligion.TokenPlace,
Replacement: strings.Split(place, " ")[0],
})
}
// If we have a deity, add it to the tokens.
if deity != nil {
tokens = append(tokens, genstory.TokenReplacement{
Token: genreligion.TokenSurpreme,
Replacement: deity.Name,
})
}
// Generate the name and method.
gen, err := rlgGen.GenFaithName(tokens)
if err != nil {
return nil, err.Error()
}
// Select expansion based on the method which indicates the
// focus of the faith (culture, location, or... global).
var expansion string
switch gen.Template {
case genreligion.MethodCultureIsm,
genreligion.MethodCultureType:
expansion = ReligionExpCulture
case genreligion.MethodPlaceIanType,
genreligion.MethodPlaceIsm:
expansion = ReligionExpState
default:
expansion = ReligionExpGlobal
}
return gen, expansion
}
const (
// Expansion modes.
ReligionExpGlobal = genreligion.ReligionExpGlobal
ReligionExpState = genreligion.ReligionExpState
ReligionExpCulture = genreligion.ReligionExpCulture
)