Documentation
¶
Index ¶
- Constants
- Variables
- type Atom
- type AtomSlice
- type Attribute
- type AttributeGroup
- type Builder
- type Component
- type Item
- type MundaneBuilder
- func (mb *MundaneBuilder) Item() (*Item, error)
- func (mb *MundaneBuilder) LinkResources() error
- func (mb *MundaneBuilder) Reduce() Recipe
- func (mb *MundaneBuilder) SetAttributeGroups(r io.Reader) error
- func (mb *MundaneBuilder) SetAttributes(r io.Reader) error
- func (mb *MundaneBuilder) SetRecipes(r io.Reader) error
- type Property
- type Recipe
- type Variant
- type VariantBlock
Constants ¶
const ComponentSkipChance float64 = 0.5
const PropertySkipChance float64 = 0.5
Variables ¶
var ( ErrSetterEmpty = errors.New("setters require a slice with at least 1 element") ErrNameBlank = errors.New("setters require struct with valid 'Name' field") )
Functions ¶
This section is empty.
Types ¶
type Attribute ¶
type Attribute struct {
Name string `json:"name"`
Common VariantBlock `json:"common"`
Uncommon VariantBlock `json:"uncommon"`
Rare VariantBlock `json:"rare"`
WeightFactor float64 `json:"weight_factor"`
PrefixNames []string `json:"prefix_names"`
SuffixNames []string `json:"suffix_names"`
Prefixes []*Attribute
Suffixes []*Attribute
}
func (*Attribute) RandomPrefix ¶
func (*Attribute) RandomSuffix ¶
type AttributeGroup ¶
type Component ¶
type MundaneBuilder ¶
type MundaneBuilder struct {
Recipes map[string]Recipe
Attributes map[string]Attribute
Groups map[string]*AttributeGroup
}
MundaneBuilder implements the Builder interface. MundaneBuilder randomly generates mundane Items from the provided resources.
func NewMundaneBuilder ¶
func NewMundaneBuilder() MundaneBuilder
NewMundaneBuilder returns an initialized MundaneBuilder.
func (*MundaneBuilder) Item ¶
func (mb *MundaneBuilder) Item() (*Item, error)
Item generates a unique mundane Item using the set resources in MundaneBuilder.
func (*MundaneBuilder) LinkResources ¶
func (mb *MundaneBuilder) LinkResources() error
LinkResources iterates through all of the receiver's maps and links each object's list of AttributeNames and AttributeGroupNames to their respective Attributes and AttributeGroups.
func (*MundaneBuilder) Reduce ¶
func (mb *MundaneBuilder) Reduce() Recipe
Reduce returns a randomly selected Recipe.
func (*MundaneBuilder) SetAttributeGroups ¶
func (mb *MundaneBuilder) SetAttributeGroups(r io.Reader) error
SetAttributeGroups reads the JSON-encoded AttributeGroups from the provided Reader and adds them to the receiver's AttributeGroup map.
func (*MundaneBuilder) SetAttributes ¶
func (mb *MundaneBuilder) SetAttributes(r io.Reader) error
SetAttributes reads the JSON-encoded Attributes from the provided Reader and adds them to the receiver's Attribute map.
func (*MundaneBuilder) SetRecipes ¶
func (mb *MundaneBuilder) SetRecipes(r io.Reader) error
SetRecipes reads the JSON-encoded Recipes from the provided Reader and adds them to the receiver's Recipe map.
type Property ¶
type Recipe ¶
type VariantBlock ¶
type VariantBlock struct {
ValueFactor float64 `json:"value_factor"`
Variants []string `json:"variants"`
}
func (*VariantBlock) Reduce ¶
func (vb *VariantBlock) Reduce() Variant
Reduce returns a randomly selected Variant.