trait

package
v0.0.0-...-a30bc99 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package trait provides tools for dealing with descriptive traits of creatures or objects

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InSlice

func InSlice(trait Trait, traits []Trait) bool

InSlice checks to see if a given trait is in the slice

Types

type Template

type Template struct {
	Name                string   `json:"name" db:"name"`
	PossibleValues      []string `json:"possible_values" db:"possible_values"`
	PossibleDescriptors []string `json:"possible_descriptors" db:"possible_descriptors"`
	Tags                []string `json:"tags" db:"tags"`
}

Template is a template for building a trait

func RandomTemplate

func RandomTemplate(templates []Template) (Template, error)

RandomTemplate returns a random template from a slice

func (Template) ToTrait

func (t Template) ToTrait() (Trait, error)

ToTrait turns a template into a trait

type Trait

type Trait struct {
	Name       string   `json:"name"`       // The name of the trait
	Value      string   `json:"value"`      // The value of the trait
	Descriptor string   `json:"descriptor"` // The pattern by which a trait is described
	Tags       []string `json:"tags"`
}

Trait is a trait of something that can be used for description

func ByTag

func ByTag(tag string, traits []Trait) []Trait

ByTag returns all traits from the slice that match the tag

func (Trait) ToString

func (t Trait) ToString() (string, error)

ToString renders a trait to a string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL