pattern

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPossibleProfessions

func GetPossibleProfessions(resources []resource.Resource) ([]profession.Profession, error)

GetPossibleProfessions gets all possible professions for a given set of resources

Types

type Data

type Data struct {
	Patterns []Pattern `json:"patterns"`
}

Data is a collection of patterns

type Pattern

type Pattern struct {
	Name                 string   `json:"name" db:"name"`
	Description          string   `json:"description" db:"description"`
	Tags                 []string `json:"tags" db:"tags"`
	Commonality          int      `json:"commonality" db:"commonality"`
	ProfessionName       string   `json:"profession_name" db:"profession_name"`
	Slots                []Slot   `json:"slots" db:"slots"`
	NameTemplate         string   `json:"name_template" db:"name_template"`
	MainMaterial         string   `json:"main_material" db:"main_material"`
	MainMaterialOverride string   `json:"main_material_override" db:"main_material_override"`
	OriginOverride       string   `json:"origin_override" db:"origin_override"`
	Value                int      `json:"value" db:"value"`
}

Pattern is a pattern for a resource

func All

func All() ([]Pattern, error)

All returns all predefined patterns from JSON files on disk

func ForProfession

func ForProfession(prof profession.Profession, from []Pattern) []Pattern

ForProfession returns all patterns from the set that a profession can make

func LoadFromFile

func LoadFromFile(name string) ([]Pattern, error)

LoadFromFile loads patterns from the given JSON file

func (Pattern) CanMake

func (pattern Pattern) CanMake(resources []resource.Resource) bool

CanMake returns true if the pattern can be made with the resources given

func (Pattern) RenderDescription

func (pattern Pattern) RenderDescription() (string, error)

RenderDescription turns a completed pattern into a string description

func (Pattern) RenderName

func (pattern Pattern) RenderName() (string, error)

RenderName renders the name of a completed pattern

func (Pattern) ToResource

func (pattern Pattern) ToResource() (resource.Resource, error)

ToResource transforms a completed pattern into a resource

type Slot

type Slot struct {
	Name                string            `json:"name" db:"name"`
	RequiredTag         string            `json:"required_tag" db:"required_tag"`
	Resource            resource.Resource `json:"resource" db:"resource"`
	DescriptionTemplate string            `json:"description_template" db:"description_template"`
	PossibleQuirks      []string          `json:"possible_quirks" db:"possible_quirks"`
}

Slot is a slot for a resource requirement

Jump to

Keyboard shortcuts

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