minifac

package module
v0.0.0-...-86a4e1d Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: MIT Imports: 8 Imported by: 0

README

minifac

Experimental factory game

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Log

func Log(pattern string, args ...any)

func Max

func Max[T constraints.Ordered](a, b T) T

func Min

func Min[T constraints.Ordered](a, b T) T

Types

type Assembler

type Assembler struct {
	// contains filtered or unexported fields
}

func NewAssembler

func NewAssembler(name string, receipt Receipt, inCapa int, outCapa int) *Assembler

func (*Assembler) CanConsumeAny

func (c *Assembler) CanConsumeAny() bool

func (*Assembler) CanConsumeFrom

func (c *Assembler) CanConsumeFrom(res Resource, dir grid.Direction) bool

func (*Assembler) CanProduce

func (c *Assembler) CanProduce() bool

func (*Assembler) ConsumeAtPositions

func (c *Assembler) ConsumeAtPositions(base grid.Position) []grid.Position

func (*Assembler) ConsumeFrom

func (c *Assembler) ConsumeFrom(res Resource, dir grid.Direction)

func (*Assembler) Info

func (c *Assembler) Info() []string

func (*Assembler) Name

func (c *Assembler) Name() string

func (*Assembler) Produce

func (c *Assembler) Produce() (Resource, bool)

func (*Assembler) ProduceAtPositions

func (c *Assembler) ProduceAtPositions(base grid.Position) []grid.Position

func (*Assembler) Resource

func (c *Assembler) Resource() Resource

func (*Assembler) Size

func (c *Assembler) Size() grid.Size

func (*Assembler) Tick

func (c *Assembler) Tick()

type Consumer

type Consumer interface {
	ConsumeFrom(Resource, grid.Direction)
	CanConsumeFrom(Resource, grid.Direction) bool
	CanConsumeAny() bool
	ConsumeAtPositions(base grid.Position) []grid.Position
	Name() string
}

type Conveyor

type Conveyor struct {
	// contains filtered or unexported fields
}

func NewConveyor

func NewConveyor(name string, dir grid.Direction, capa int) *Conveyor

func (*Conveyor) CanConsumeAny

func (c *Conveyor) CanConsumeAny() bool

func (*Conveyor) CanConsumeFrom

func (c *Conveyor) CanConsumeFrom(res Resource, dir grid.Direction) bool

func (*Conveyor) CanProduce

func (c *Conveyor) CanProduce() bool

func (*Conveyor) ConsumeAtPositions

func (c *Conveyor) ConsumeAtPositions(base grid.Position) []grid.Position

func (*Conveyor) ConsumeFrom

func (c *Conveyor) ConsumeFrom(res Resource, dir grid.Direction)

func (*Conveyor) Dir

func (c *Conveyor) Dir() grid.Direction

func (*Conveyor) Info

func (c *Conveyor) Info() []string

func (*Conveyor) Name

func (c *Conveyor) Name() string

func (*Conveyor) Produce

func (c *Conveyor) Produce() (Resource, bool)

func (*Conveyor) ProduceAtPositions

func (c *Conveyor) ProduceAtPositions(base grid.Position) []grid.Position

func (*Conveyor) Resource

func (c *Conveyor) Resource() Resource

func (*Conveyor) Size

func (c *Conveyor) Size() grid.Size

func (*Conveyor) Tick

func (c *Conveyor) Tick()

type Finalizer

type Finalizer struct {
	// contains filtered or unexported fields
}

func NewFinalizer

func NewFinalizer(name string, res Resource) *Finalizer

func (*Finalizer) CanConsumeAny

func (c *Finalizer) CanConsumeAny() bool

func (*Finalizer) CanConsumeFrom

func (c *Finalizer) CanConsumeFrom(res Resource, dir grid.Direction) bool

func (*Finalizer) ConsumeAtPositions

func (c *Finalizer) ConsumeAtPositions(base grid.Position) []grid.Position

func (*Finalizer) ConsumeFrom

func (c *Finalizer) ConsumeFrom(res Resource, dir grid.Direction)

func (*Finalizer) Info

func (c *Finalizer) Info() []string

func (*Finalizer) Name

func (c *Finalizer) Name() string

func (*Finalizer) Resource

func (c *Finalizer) Resource() Resource

func (*Finalizer) Size

func (c *Finalizer) Size() grid.Size

func (*Finalizer) Tick

func (c *Finalizer) Tick()

type IncarnationProducer

type IncarnationProducer struct {
	// contains filtered or unexported fields
}

func NewIncarnationProducer

func NewIncarnationProducer(name string, res Resource, rate Rate, stockCapa int) *IncarnationProducer

func (*IncarnationProducer) CanProduce

func (p *IncarnationProducer) CanProduce() bool

func (*IncarnationProducer) Info

func (p *IncarnationProducer) Info() []string

func (*IncarnationProducer) Name

func (p *IncarnationProducer) Name() string

func (*IncarnationProducer) Produce

func (p *IncarnationProducer) Produce() (Resource, bool)

func (*IncarnationProducer) ProduceAtPositions

func (p *IncarnationProducer) ProduceAtPositions(base grid.Position) []grid.Position

func (*IncarnationProducer) Resource

func (p *IncarnationProducer) Resource() Resource

func (*IncarnationProducer) Size

func (p *IncarnationProducer) Size() grid.Size

func (*IncarnationProducer) Tick

func (p *IncarnationProducer) Tick()

type Object

type Object interface {
	Size() grid.Size
	Tick()
	Name() string
	Info() []string
}

type Obstacle

type Obstacle struct {
	// contains filtered or unexported fields
}

func NewObstacle

func NewObstacle(name string, typ ObstacleType) *Obstacle

func (*Obstacle) Info

func (c *Obstacle) Info() []string

func (*Obstacle) Name

func (c *Obstacle) Name() string

func (*Obstacle) Size

func (c *Obstacle) Size() grid.Size

func (*Obstacle) Tick

func (c *Obstacle) Tick()

func (*Obstacle) Type

func (c *Obstacle) Type() ObstacleType

type ObstacleType

type ObstacleType string
const (
	ObstacleWall ObstacleType = "wall"
)

type Producer

type Producer interface {
	Produce() (Resource, bool)
	Resource() Resource
	CanProduce() bool
	ProduceAtPositions(base grid.Position) []grid.Position
	Name() string
}

type ProducerConsumer

type ProducerConsumer interface {
	Producer
	Consumer
}

type Queue

type Queue[T any] struct {
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue[T any]() *Queue[T]

func (*Queue[T]) Dequeue

func (q *Queue[T]) Dequeue() (T, bool)

func (*Queue[T]) Enqueue

func (q *Queue[T]) Enqueue(t T)

func (*Queue[T]) Len

func (q *Queue[T]) Len() int

func (*Queue[T]) Peek

func (q *Queue[T]) Peek() (T, bool)

type Rate

type Rate struct {
	// contains filtered or unexported fields
}

func NewRate

func NewRate(count, perTicks int) Rate

func (Rate) Count

func (r Rate) Count(ticks int) int

type Receipt

type Receipt struct {
	Input          map[Resource]int
	Output         Resource
	ProductionTime int
}

func AllReceipts

func AllReceipts() []Receipt

func ReceiptFor

func ReceiptFor(res Resource) (Receipt, bool)

func ReceiptIron

func ReceiptIron() Receipt

func ReceiptSteel

func ReceiptSteel() Receipt

func (Receipt) String

func (r Receipt) String() string

type Resource

type Resource string
const (
	None    Resource = "none"
	Wood    Resource = "wood"
	Stone   Resource = "stone"
	Coal    Resource = "coal"
	IronOre Resource = "ironore"
	Iron    Resource = "iron"
	Steel   Resource = "steel"
)

func BaseResources

func BaseResources() []Resource

type Stock

type Stock struct {
	// contains filtered or unexported fields
}

func NewStock

func NewStock(capa int) *Stock

func (*Stock) Add

func (s *Stock) Add(res Resource, n int) (added int)

func (*Stock) Amount

func (s *Stock) Amount(res Resource) int

func (*Stock) CanAdd

func (s *Stock) CanAdd(res Resource, n int) bool

func (*Stock) Take

func (s *Stock) Take(res Resource, n int) (taken int)

func (*Stock) TotalAmount

func (s *Stock) TotalAmount() int

type Trashbin

type Trashbin struct {
	// contains filtered or unexported fields
}

func NewTrashbin

func NewTrashbin(name string) *Trashbin

func (*Trashbin) CanConsumeAny

func (c *Trashbin) CanConsumeAny() bool

func (*Trashbin) CanConsumeFrom

func (c *Trashbin) CanConsumeFrom(Resource, grid.Direction) bool

func (*Trashbin) ConsumeAtPositions

func (c *Trashbin) ConsumeAtPositions(base grid.Position) []grid.Position

func (*Trashbin) ConsumeFrom

func (c *Trashbin) ConsumeFrom(res Resource, dir grid.Direction)

func (*Trashbin) Info

func (c *Trashbin) Info() []string

func (*Trashbin) Name

func (c *Trashbin) Name() string

func (*Trashbin) Size

func (c *Trashbin) Size() grid.Size

func (*Trashbin) Tick

func (c *Trashbin) Tick()

type Universe

type Universe struct {
	// contains filtered or unexported fields
}

func NewUniverse

func NewUniverse(size grid.Size) *Universe

func (*Universe) AddObject

func (u *Universe) AddObject(o Object, at grid.Position) error

func (*Universe) AllObjects

func (u *Universe) AllObjects() []*grid.Object[Object]

func (*Universe) ContainsPosition

func (u *Universe) ContainsPosition(p grid.Position) bool

func (*Universe) DeleteAt

func (u *Universe) DeleteAt(p grid.Position)

func (*Universe) ObjectAt

func (u *Universe) ObjectAt(p grid.Position) (*grid.Object[Object], bool)

func (*Universe) Size

func (u *Universe) Size() grid.Size

func (*Universe) Tick

func (u *Universe) Tick()

Directories

Path Synopsis
cmd
ui

Jump to

Keyboard shortcuts

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