pet

package
v0.0.0-...-16605f2 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: Unlicense Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultPetStats = []*Stat{
		{Name: "Health", Value: 100},
		{Name: "Boredom", Value: 0, Delta: 5},
		{Name: "Thirst", Value: 0, Delta: 3},
		{Name: "Hunger", Value: 0, Delta: 2},
		{Name: "Fatigue", Value: 0, Delta: 2},
	}
	StatNames          []string
	StatUpdateInterval = time.Second * 5

	CurrentPet *Pet
)

Functions

This section is empty.

Types

type Pet

type Pet struct {
	Name   string
	IsDead bool

	StatLock           *sync.RWMutex
	Stats              []*Stat
	StatUpdateNotifier chan bool
}

func NewPet

func NewPet(name string) *Pet

NewPet creates a new Pet instance and returns a reference to it

func (*Pet) FixStats

func (p *Pet) FixStats()

FixStats ensures all stat values are within the range 0<=n<=100

func (*Pet) SetStat

func (p *Pet) SetStat(sname string, val int)

SetStat sets the statistic by name to a certain value

func (*Pet) SetStatDelta

func (p *Pet) SetStatDelta(sname string, delta int)

SetStatDelta applies a delta to a statistic by name

type Stat

type Stat struct {
	Name  string
	Value int
	Delta int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳