species

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: 9 Imported by: 0

Documentation

Overview

Package species implements the backbone of all living entities in a world

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	Species []Species `json:"species"`
}

Data is a struct containing a slice of Species

type Simplified

type Simplified struct {
	Name        string `json:"name"`
	PluralName  string `json:"plural_name"`
	Adjective   string `json:"adjective"`
	Description string `json:"description"`
}

Simplified is a simplified version of a species meant for JSON display

type Species

type Species struct {
	Name           string              `json:"name" db:"name"`
	PluralName     string              `json:"plural_name" db:"plural_name"`
	Adjective      string              `json:"adjective" db:"adjective"`
	Commonality    int                 `json:"commonality" db:"commonality"`
	PossibleTraits []trait.Template    `json:"possible_traits" db:"possible_traits"` // Traits that individuals of this species *might* have
	CommonTraits   []trait.Template    `json:"common_traits" db:"common_traits"`     // Traits that all members of this species share
	AgeCategories  []age.Category      `json:"age_categories" db:"age_categories"`
	MinHumidity    int                 `json:"min_humidity" db:"humidity_min"`
	MaxHumidity    int                 `json:"max_humidity" db:"humidity_max"`
	MinTemperature int                 `json:"min_temperature" db:"temperature_min"`
	MaxTemperature int                 `json:"max_temperature" db:"temperature_max"`
	Resources      []resource.Resource `json:"resources" db:"resources"` // These are resources that can be derived from this species
	Tags           []string            `json:"tags" db:"tags"`
}

Species is a species of living thing

func ByResource

func ByResource(resource string, from []Species) []Species

ByResource returns a slice of species that have the given resource

func ByTag

func ByTag(tag string, from []Species) []Species

ByTag returns a slice of species that have the given tag

func ByTagIn

func ByTagIn(tags []string, from []Species) []Species

ByTagIn returns a slice of species that have at least one of the given tags

func ExcludeTag

func ExcludeTag(tag string, from []Species) []Species

ExcludeTag returns a slice without a given tag

func FilterHumidity

func FilterHumidity(humidity int, from []Species) []Species

FilterHumidity filters a slice of Species by humidity

func FilterTemperature

func FilterTemperature(temperature int, from []Species) []Species

FilterTemperature filters a slice of Species by temperature

func Load

func Load(fileName string) ([]Species, error)

Load returns all predefined species of a given type from a JSON file on disk

func Random

func Random(amount int, from []Species) []Species

Random returns a set number of randomly chosen speciess from a slice

func RandomWithResourceTag

func RandomWithResourceTag(resourceTag string, from []Species) (Species, error)

RandomWithResourceTag returns a random species that has a resource with the given tag

func (Species) Describe

func (s Species) Describe() string

Describe returns a description of a species

func (Species) HasResource

func (s Species) HasResource(resource string) bool

HasResource returns true if the species has a given resource

func (Species) HasResourceWithTag

func (s Species) HasResourceWithTag(resourceTag string) bool

HasResourceWithTag returns true if the species has a resource with a given tag

func (Species) HasTag

func (s Species) HasTag(tag string) bool

HasTag returns true if the species has a given tag

func (Species) InSlice

func (s Species) InSlice(from []Species) bool

InSlice checks whether a given species is in a slice of speciess

func (Species) Simplify

func (s Species) Simplify() Simplified

Simplify returns a simplified version of a given species

Jump to

Keyboard shortcuts

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