module

package
v0.0.0-...-0cfb223 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const Collection = "modules"

Collection indicates the MongoDB module collection

Variables

This section is empty.

Functions

func Create

func Create(mod *Module) error

Create creates a new entity

func GetAll

func GetAll(opts *Options) (*model.Result, error)

GetAll returns a result based on filters

func GetByIDs

func GetByIDs(ids []string, opts *Options) (*model.Result, error)

GetByIDs returns a result by given IDs

func GetByMaterial

func GetByMaterial(id string, opts *Options) (*model.Result, error)

GetByMaterial returns a result based on stage materials

func GetByText

func GetByText(q string, opts *Options) (*model.Result, error)

GetByText returns a result based on given keyword

func Remove

func Remove(id string) error

Remove removes an entity

func Replace

func Replace(id string, mod *Module) error

Replace replaces the data of an existing entity

Types

type Bonus

type Bonus struct {
	Description string  `json:"description" bson:"description"`
	Value       float64 `json:"value,omitempty" bson:"value,omitempty"`
	SkillType   string  `json:"skillType,omitempty" bson:"skillType,omitempty"`
	Type        string  `json:"type" bson:"type"`
}

Bonus describes a bonus of a stage

func (Bonus) Validate

func (b Bonus) Validate() error

Validate validates the fields of a module bonus

type ItemRef

type ItemRef struct {
	ID        objectID  `json:"id" bson:"id"`
	Count     uint64    `json:"count,omitempty" bson:"count,omitempty"`
	Resources uint64    `json:"resources,omitempty" bson:"resources,omitempty"`
	Kind      item.Kind `json:"kind" bson:"kind"`
}

ItemRef refers to an item and specifies its quantity

func (ItemRef) Validate

func (i ItemRef) Validate() error

Validate validates the fields of an referred item

type Module

type Module struct {
	ID            objectID  `json:"_id" bson:"_id"`
	Name          string    `json:"name" bson:"name"`
	RequiresPower bool      `json:"requiresPower" bson:"requiresPower"`
	Stages        []Stage   `json:"stages" bson:"stages"`
	Modified      timestamp `json:"_modified" bson:"_modified"`
}

Module describes the entity of a module

func GetByID

func GetByID(id string) (*Module, error)

GetByID returns the entity of the given ID

func (Module) Validate

func (m Module) Validate() error

Validate validates the fields of a module

type Options

type Options struct {
	Sort   bson.D
	Limit  int64
	Offset int64
}

Options represents the options for a database operation

type Ref

type Ref struct {
	ID    objectID `json:"id" bson:"id"`
	Stage uint8    `json:"stage" bson:"stage"`
}

Ref refers to a module and its stage

func (Ref) Validate

func (m Ref) Validate() error

Validate validates the fields of a referred module

type Requirement

type Requirement struct {
	Name  string `json:"name" bson:"name"`
	Level uint8  `json:"level,omitempty" bson:"level,omitempty"`
	Type  string `json:"type" bson:"type"`
}

Requirement describes a requirement of different types of a stage

func (Requirement) Validate

func (r Requirement) Validate() error

Validate validates the fields of a module requirement

type Stage

type Stage struct {
	Description      string        `json:"description" bson:"description"`
	Bonuses          []Bonus       `json:"bonuses" bson:"bonuses"`
	Requirements     []Requirement `json:"requirements" bson:"requirements"`
	RequiredModules  []Ref         `json:"requiredMods" bson:"requiredMods"`
	Materials        []ItemRef     `json:"materials" bson:"materials"`
	ConstructionTime int64         `json:"constructionTime" bson:"constructionTime"`
}

Stage describes a stage of a module

func (Stage) Validate

func (s Stage) Validate() error

Validate validates the fields of a stage

Jump to

Keyboard shortcuts

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