Skip to content

Commit

Permalink
Use the simplified pantheon for culture religion
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Overmyer committed May 28, 2019
1 parent f637083 commit 865b663
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 29 deletions.
18 changes: 2 additions & 16 deletions pkg/culture/religion.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// Religion is a culture's religion
type Religion struct {
Class ReligionClass
Pantheon pantheon.Pantheon
Pantheon pantheon.SimplifiedPantheon
GatheringPlaceName string
}

Expand All @@ -23,27 +23,13 @@ type ReligionClass struct {
func (culture Culture) generateReligion() Religion {
religion := Religion{}

deities := make(map[string]pantheon.Deity)

religion.Class = randomReligionClass()
religion.GatheringPlaceName = religion.randomGatheringPlaceName()

if religion.Class.PantheonMaxSize > 0 {
religion.Pantheon = pantheon.Generate(religion.Class.PantheonMaxSize, culture.Language)
}

for _, deity := range religion.Pantheon.Deities {
if deity.Gender.Name == "male" {
deity.Name = culture.Language.RandomGenderedName("male")
} else {
deity.Name = culture.Language.RandomGenderedName("female")
}
deities[deity.Name] = deity
religion.Pantheon = pantheon.GenerateForDisplay(religion.Class.PantheonMaxSize, culture.Language)
}

religion.Pantheon.Deities = deities
religion.Pantheon.Deities = religion.Pantheon.GenerateRelationships()

return religion
}

Expand Down
24 changes: 13 additions & 11 deletions pkg/pantheon/deities.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ type Deity struct {

// SimplifiedDeity is a display version of deity
type SimplifiedDeity struct {
Name string
Gender string
Domains []string
Description string
Name string `json:"name"`
Gender string `json:"gender"`
Domains []string `json:"domains"`
Description string `json:"description"`
}

// GenerateDeity generates a random deity
Expand Down Expand Up @@ -62,7 +62,7 @@ func (pantheon Pantheon) GenerateDeity(lang language.Language) Deity {

deity.PersonalityTraits = deity.getRandomTraits()

deity.Name = lang.RandomName()
deity.Name = lang.RandomGenderedName(deity.Gender.Name)

return deity
}
Expand All @@ -73,7 +73,7 @@ func randomDeityNameFromMap(deities map[string]Deity) string {
names = append(names, d.Name)
}

return names[rand.Intn(len(names)-1)]
return names[rand.Intn(len(names))]
}

func (deity Deity) simplify() SimplifiedDeity {
Expand Down Expand Up @@ -110,12 +110,14 @@ func (deity Deity) simplify() SimplifiedDeity {

relationships := []string{}

for _, r := range deity.Relationships {
relationship = r.Descriptor + " " + r.Target
relationships = append(relationships, relationship)
}
if len(deity.Relationships) > 0 {
for _, r := range deity.Relationships {
relationship = r.Descriptor + " " + r.Target
relationships = append(relationships, relationship)
}

description += deity.Name + " " + words.CombinePhrases(relationships) + "."
description += deity.Name + " " + words.CombinePhrases(relationships) + "."
}

sd.Description = description

Expand Down
6 changes: 4 additions & 2 deletions pkg/pantheon/pantheon.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Pantheon struct {

// SimplifiedPantheon is a simplified version of the data for display
type SimplifiedPantheon struct {
Deities []SimplifiedDeity
Deities []SimplifiedDeity `json:"deities"`
}

// Generate creates a random pantheon of deities
Expand All @@ -30,7 +30,9 @@ func Generate(maxSize int, lang language.Language) Pantheon {
pantheon.Deities[deity.Name] = deity
}

pantheon.Deities = pantheon.GenerateRelationships()
if len(pantheon.Deities) > 1 {
pantheon.Deities = pantheon.GenerateRelationships()
}

return pantheon
}
Expand Down

0 comments on commit 865b663

Please sign in to comment.