Documentation ¶
Index ¶
- Constants
- Variables
- func AvailableAncestries(libraries library.Libraries) []*library.NamedFileSet
- func ChooseStringOption(options []*StringOption, not string) string
- type Ancestry
- func (a *Ancestry) GenderedOptions(gender string) *Options
- func (a *Ancestry) RandomAge(resolver eval.VariableResolver, gender string, not int) int
- func (a *Ancestry) RandomEyes(gender, not string) string
- func (a *Ancestry) RandomGender(not string) string
- func (a *Ancestry) RandomHair(gender, not string) string
- func (a *Ancestry) RandomHandedness(gender, not string) string
- func (a *Ancestry) RandomHeight(resolver eval.VariableResolver, gender string, not measure.Length) measure.Length
- func (a *Ancestry) RandomName(nameGeneratorRefs []*NameGeneratorRef, gender string) string
- func (a *Ancestry) RandomSkin(gender, not string) string
- func (a *Ancestry) RandomWeight(resolver eval.VariableResolver, gender string, not measure.Weight) measure.Weight
- func (a *Ancestry) Save(filePath string) error
- type NameGenerationType
- type NameGenerator
- type NameGeneratorRef
- type Options
- func (o *Options) RandomAge(resolver eval.VariableResolver, not int) int
- func (o *Options) RandomEye(not string) string
- func (o *Options) RandomHair(not string) string
- func (o *Options) RandomHandedness(not string) string
- func (o *Options) RandomHeight(resolver eval.VariableResolver, not measure.Length) measure.Length
- func (o *Options) RandomName(nameGeneratorRefs []*NameGeneratorRef) string
- func (o *Options) RandomSkin(not string) string
- func (o *Options) RandomWeight(resolver eval.VariableResolver, not measure.Weight) measure.Weight
- type StringOption
- type WeightedAncestryOptions
Constants ¶
const ( Simple = NameGenerationType("simple") MarkovChain = NameGenerationType("markov_chain") )
Possible NameGenerationType values.
const (
Default = "Human"
)
Default holds the name of the default ancestry.
Variables ¶
var AllNameGenerationTypes = []NameGenerationType{ Simple, MarkovChain, }
AllNameGenerationTypes is the complete set of NameGenerationType values.
Functions ¶
func AvailableAncestries ¶
func AvailableAncestries(libraries library.Libraries) []*library.NamedFileSet
AvailableAncestries scans the libraries and returns the available ancestries.
func ChooseStringOption ¶
func ChooseStringOption(options []*StringOption, not string) string
ChooseStringOption selects a string option from the available set.
Types ¶
type Ancestry ¶
type Ancestry struct { Name string `json:"name,omitempty"` CommonOptions *Options `json:"common_options,omitempty"` GenderOptions []*WeightedAncestryOptions `json:"gender_options,omitempty"` }
Ancestry holds details necessary to generate ancestry-specific customizations.
func NewAncestryFromFile ¶
NewAncestryFromFile creates a new Ancestry from a file.
func (*Ancestry) GenderedOptions ¶
GenderedOptions returns the options for the specified gender, or nil.
func (*Ancestry) RandomEyes ¶
RandomEyes returns a randomized eyes.
func (*Ancestry) RandomGender ¶
RandomGender returns a randomized gender.
func (*Ancestry) RandomHair ¶
RandomHair returns a randomized hair.
func (*Ancestry) RandomHandedness ¶
RandomHandedness returns a randomized handedness.
func (*Ancestry) RandomHeight ¶
func (a *Ancestry) RandomHeight(resolver eval.VariableResolver, gender string, not measure.Length) measure.Length
RandomHeight returns a randomized height.
func (*Ancestry) RandomName ¶
func (a *Ancestry) RandomName(nameGeneratorRefs []*NameGeneratorRef, gender string) string
RandomName returns a randomized name.
func (*Ancestry) RandomSkin ¶
RandomSkin returns a randomized skin.
func (*Ancestry) RandomWeight ¶
func (a *Ancestry) RandomWeight(resolver eval.VariableResolver, gender string, not measure.Weight) measure.Weight
RandomWeight returns a randomized weight.
type NameGenerationType ¶
type NameGenerationType string
NameGenerationType holds the type of a name generation technique.
func (NameGenerationType) EnsureValid ¶
func (n NameGenerationType) EnsureValid() NameGenerationType
EnsureValid ensures this is of a known value.
func (NameGenerationType) String ¶
func (n NameGenerationType) String() string
String implements fmt.Stringer.
type NameGenerator ¶
type NameGenerator struct { Type NameGenerationType `json:"type"` TrainingData []string `json:"training_data"` // contains filtered or unexported fields }
NameGenerator holds the data for name generation.
func NewNameGeneratorFromFS ¶
func NewNameGeneratorFromFS(fileSystem fs.FS, filePath string) (*NameGenerator, error)
NewNameGeneratorFromFS creates a new NameGenerator from a file.
type NameGeneratorRef ¶
type NameGeneratorRef struct { FileRef *library.NamedFileRef // contains filtered or unexported fields }
NameGeneratorRef holds a reference to a NameGenerator.
func AvailableNameGenerators ¶
func AvailableNameGenerators(libraries library.Libraries) []*NameGeneratorRef
AvailableNameGenerators scans the libraries and returns the available name generators.
func (*NameGeneratorRef) Generator ¶
func (n *NameGeneratorRef) Generator() (*NameGenerator, error)
Generator returns the NameGenerator, loading it if needed.
type Options ¶
type Options struct { Name string `json:"name,omitempty"` HeightFormula string `json:"height_formula,omitempty"` WeightFormula string `json:"weight_formula,omitempty"` AgeFormula string `json:"age_formula,omitempty"` HairOptions []*StringOption `json:"hair_options,omitempty"` EyeOptions []*StringOption `json:"eye_options,omitempty"` SkinOptions []*StringOption `json:"skin_options,omitempty"` HandednessOptions []*StringOption `json:"handedness_options,omitempty"` NameGenerators []string `json:"name_generators,omitempty"` }
Options holds options that may be randomized for an Entity's ancestry.
func ChooseWeightedAncestryOptions ¶
func ChooseWeightedAncestryOptions(options []*WeightedAncestryOptions, omitter func(*Options) bool) *Options
ChooseWeightedAncestryOptions selects a string option from the available set.
func (*Options) RandomAge ¶
func (o *Options) RandomAge(resolver eval.VariableResolver, not int) int
RandomAge returns a randomized age.
func (*Options) RandomHair ¶
RandomHair returns a randomized hair.
func (*Options) RandomHandedness ¶
RandomHandedness returns a randomized handedness.
func (*Options) RandomHeight ¶
RandomHeight returns a randomized height.
func (*Options) RandomName ¶
func (o *Options) RandomName(nameGeneratorRefs []*NameGeneratorRef) string
RandomName returns a randomized name.
func (*Options) RandomSkin ¶
RandomSkin returns a randomized skin.
func (*Options) RandomWeight ¶
RandomWeight returns a randomized weight.
type StringOption ¶
StringOption is a string that has a weight associated with it.
func (*StringOption) Valid ¶
func (o *StringOption) Valid() bool
Valid returns true if this option has a valid weight.
type WeightedAncestryOptions ¶
WeightedAncestryOptions is a string that has a weight associated with it.
func (*WeightedAncestryOptions) Valid ¶
func (o *WeightedAncestryOptions) Valid() bool
Valid returns true if this option has a valid weight.