forked from ironarachne/world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathage.go
28 lines (21 loc) · 859 Bytes
/
age.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
package character
import (
"math/rand"
"github.com/ironarachne/world/pkg/age"
"github.com/ironarachne/world/pkg/math"
)
func getAgeFromParents(parents Couple) (int, age.Category) {
lowestAge := math.Min(parents.Partner1.Age, parents.Partner2.Age)
childAge := rand.Intn(lowestAge-18) + 1
childAgeCategory := age.GetCategoryFromAge(childAge, parents.Partner1.Race.AgeCategories)
return childAge, childAgeCategory
}
// ChangeAge changes the age and age category of a character
func (character Character) ChangeAge(newAge int) Character {
c := age.GetCategoryFromAge(newAge, character.Race.AgeCategories)
character.Age = newAge
character.AgeCategory = c
character.Height = age.GetRandomHeight(character.Gender.Name, character.AgeCategory)
character.Weight = age.GetRandomWeight(character.Gender.Name, character.AgeCategory)
return character
}