objects

package
v0.0.0-...-2d400ac Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Building

type Building struct {
	Location  Point
	Kind      int
	Neighbors []Neighbor
}

Building instances are like Renderables with additional information.

func (*Building) Char

func (b *Building) Char() rune

Char returns the symbol to use when rendering the building.

func (*Building) Cost

func (b *Building) Cost() int

Cost calculates the cost of the building.

func (*Building) HasPower

func (b *Building) HasPower() bool

HasPower will return true if any neighbor has power.

func (*Building) Revenue

func (b *Building) Revenue() int

Revenue calculates the revenue of the building (assuming power)

func (*Building) String

func (b *Building) String() string

String returns the humanized name of the building.

type Cursor

type Cursor struct {
	Location  Point
	Mode      int
	Inventory []Building
}

Cursor represents the location of the player as well as what mode and building they are currently acting as.

func (*Cursor) Char

func (c *Cursor) Char() rune

Char returns the rune to use when rendering the cursor.

func (*Cursor) String

func (c *Cursor) String() string

String returns a human redable version of the cursor.

type Dimensions

type Dimensions struct {
	Width  int
	Height int
}

Dimensions wraps a width and height.

func (*Dimensions) Area

func (d *Dimensions) Area() int

Area returns the product of the width and height.

func (*Dimensions) Dup

func (d *Dimensions) Dup() Dimensions

Dup returns a fresh copy of the dimensions.

func (*Dimensions) Midway

func (d *Dimensions) Midway() (int, int)

Midway returns the x and y values of the width and height divided by two.

func (*Dimensions) MidwayPoint

func (d *Dimensions) MidwayPoint() Point

MidwayPoint returns a point from the midway values.

func (*Dimensions) String

func (d *Dimensions) String() string

String returns a human readble interpretation of the dimensions.

func (*Dimensions) Values

func (d *Dimensions) Values() (int, int)

Values returns a tupe of the width and height values.

type Flash

type Flash struct {
	Text    string
	Expires time.Time
}

Flash objects are used to render out banners to the user.

type Game

type Game struct {
	Cursor           Cursor
	Dimensions       Dimensions
	World            Dimensions
	Buildings        []Building
	Turn             Turn
	Funds            int
	Revenue          int
	Population       int
	PopulationGrowth int
	Flashes          []Flash
	Frame            int
	Debug            bool
}

Game represents the state of the game.

func (*Game) String

func (state *Game) String() string

String returns a user readable version of the game.

type Neighbor

type Neighbor struct {
	Building  Building
	Direction string
}

Neighbor is used to create an array of buildings that are adjacent to a given building.

type Point

type Point struct {
	X int
	Y int
}

Point wraps an x and y position.

func (*Point) Dup

func (p *Point) Dup() Point

Dup copies the point.

func (*Point) Equals

func (p *Point) Equals(other Point) bool

Equals returns true if the coordinates match

func (*Point) String

func (p *Point) String() string

String returns a human readable string representation of the point.

func (*Point) Translate

func (p *Point) Translate(x, y int) Point

Translate returns a new point having the x and y coordinates moved by the provided amounts.

func (*Point) Values

func (p *Point) Values() (int, int)

Values returns the x and y coordinates as a tuple

type Renderable

type Renderable struct {
	Location Point
	Symbol   rune
	Color    color.Color
}

Renderable represents a location and a symbol to be rendered.

func (*Renderable) String

func (r *Renderable) String() string

String returns a human readable version of the renderable.

type Turn

type Turn struct {
	Actions TurnActions
	Start   time.Time
}

Turn holds the information about the current turn.

func (*Turn) Done

func (t *Turn) Done() bool

Done is true when the player has used all of the actions available to them.

func (*Turn) Inc

func (t *Turn) Inc() Turn

Inc consumes an available action.

func (*Turn) Progress

func (t *Turn) Progress() (float64, float64)

Progress returns two 0-1 floating point numbers representing the completeness of the turn.

func (*Turn) TimeElapsed

func (t *Turn) TimeElapsed() time.Duration

TimeElapsed calculates how long this turn has been going on.

type TurnActions

type TurnActions struct {
	Used      int
	Available int
}

TurnActions store how many actions a user has taken this turn and how many they are allowed to.

Jump to

Keyboard shortcuts

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