roads

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 26 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package roads lays roads by one set of rules, package site's, with a road in a player's hand: planned, priced, asked about and then built.

NewPlugin takes the world, the board and the Config: what the game allows a road (site.Rules), the kind of road the tool lays and how wide, the Tariff pricing a plan, and whether the tool levels the ground and holds the game in the tactical pause. A road is a cell.Way laid cell after cell (board.BoardWrite.SetWay), a Graded kind lying as Transport Tycoon lays it, a track as the ground lies.

A road in a player's hand

Plugin.DefaultBindings have Shift+R take a road in hand (Tool); while the player holds it, the cursor aims the road (Aim), a left click marks a point of its route (Mark: the first where it begins, every next one it runs to by the cheapest way, a point no way reaches not marked, the last again taken back), a left drag with Shift lays one piece in a cell toward a neighbour (Piece, joining the roads ending at the cell), and a right click or Esc puts the road down. The plugin draws the road in hand over the ground as the levelling will leave it, green where it may lie and yellow where it may not (Plugin.Reason says why), the cells its levelling moves outlined and those something stands on marked in red. Plugin.Window asks "Build the road?" with what the road takes and what it costs: Build plans it anew (a plan the ground changed under is shown again and waits for a second Build, one levelling under a unit waits for the unit to go) and has it built at the next step of the simulation: every cell graded on the ground Plugin.WithShaper gives, then the ways laid, none on a bridge's span or a ford, which the road leads onto, a head's leading onto the span; a road along a road standing lays and costs nothing anew; Cancel builds nothing. Whether the tool levels the ground is the players' setting (Levelling, the settings screen's); Config.MaxStep is the topography's Shaping.MaxStep, how far the ground round a graded cell follows; Config.InPause has taking the road in hand hold the game in the tactical pause, the players letting it go.

Rules of the game

The price is the game's own work: Config.Tariff turns an site.Estimate into a number. The decision is its rules': every tick a plan stands in a hand the plugin's entity has the moment Estimated, at once, in the tactical pause too, and a rule of a role the entity plays may answer Refuse with why; every road built has the moment Built. A game's own pass reads what was built from Read.Built. The roads confirmed and waiting for a step (Resources.Orders) and the receipts not handed out yet (Resources.Receipts) are saved with the game beside the Settings: a road confirmed in the pause is built, and paid for, after a load; a road in hand is not saved.

Vocabulary

Moments, the plugin's entity's: Estimated (words Levels, Blocks, Crosses, Decked, Longer, Moves) and Built (words Levelled, Crossed). Commands, a player's with the road tool in hand: Aim, Mark, Piece, Build, Cancel; a rule's answer to Estimated: Refuse; the settings screen's: Levelling.

Index

Constants

View Source
const Tool control.Tool = "road"

Tool is a road in a player's hand, for control.Take.

Variables

This section is empty.

Functions

func Blocks

func Blocks() cond.Word[Estimated]

Blocks is the word of a plan whose levelling waits for something standing on a cell to go.

func Crossed

func Crossed() cond.Word[Built]

Crossed is the word of a road built that met a road standing.

func Crosses

func Crosses() cond.Word[Estimated]

Crosses is the word of a plan meeting a road standing.

func Decked

func Decked() cond.Word[Estimated]

Decked is the word of a plan running over a bridge's deck.

func Levelled

func Levelled() cond.Word[Built]

Levelled is the word of a road built that moved the ground's corners.

func Levels

func Levels() cond.Word[Estimated]

Levels is the word of a plan moving the ground's corners.

func Longer

func Longer(cells int) cond.Word[Estimated]

Longer is the word of a plan of more than cells cells.

func Moves

func Moves(earth float32) cond.Word[Estimated]

Moves is the word of a plan moving more earth than earth, cut and fill together.

Types

type Aim

type Aim struct{ At geom.Vec }

Aim is where the cursor of a player holding the road points: where its last leg runs to.

func (Aim) Command

func (Aim) Command()

type Build

type Build struct{}

Build builds the road its player was asked about.

func (Build) Command

func (Build) Command()

type Built

type Built struct {
	Self     uid.UID64
	Estimate site.Estimate
	Price    float32
}

Built is the moment of a road built, of the plugin's own entity, once as it is laid: what was laid and what it cost.

func (Built) Who

func (b Built) Who() uid.UID64

Who is the plugin's entity.

type Cancel

type Cancel struct{}

Cancel builds nothing of the road its player was asked about, its route still marked.

func (Cancel) Command

func (Cancel) Command()

type Config

type Config struct {
	Kind      string
	Width     float32
	Rules     site.Rules
	Tariff    func(e site.Estimate) float32
	Levelling bool
	// MaxStep is the topography's Shaping.MaxStep, so a plan levels the ground as the shaping
	// has it follow; 0 has nothing follow.
	MaxStep float32
	InPause bool
}

Config is what the game allows a road (Rules), the kind of road the Tool lays (Kind, a kind of cell defined on the board, Graded or a track) and how wide (a fifth of a cell for none), the Tariff pricing a plan (nil shows its quantities alone), whether the tool starts levelling the ground (Levelling) and whether taking it holds the game in the tactical pause (InPause).

type Estimated

type Estimated struct {
	Self     uid.UID64
	Estimate site.Estimate
	Price    float32
}

Estimated is the moment of a road planned in a player's hand, every tick the plan stands, of the plugin's own entity: Estimate what the road takes, Price what the Tariff makes of it (0 without one). A rule of it may Refuse the road.

func (Estimated) Who

func (e Estimated) Who() uid.UID64

Who is the plugin's entity.

type Levelling

type Levelling struct{ On bool }

Levelling sets whether the tool levels the ground under the roads it lays (Settings.Levelling).

func (Levelling) Command

func (Levelling) Command()

type Mark

type Mark struct{ At geom.Vec }

Mark lays a point of the road's route at the world point At: the first where the road begins, every next one it runs to, the last again lifts it; from the second on the road is planned whole and asked about.

func (Mark) Command

func (Mark) Command()

type Order

type Order struct {
	Issuer   command.Issuer
	Estimate site.Estimate
	Price    float32
}

Order is a road its player confirmed (Build), laid at the next step of the simulation: whose hand laid it out, what it takes and what it costs.

type Piece

type Piece struct{ At, Toward geom.Vec }

Piece lays one piece of road in the cell under At toward the cell under Toward, joining the roads ending at the cell; Toward in the same cell joins them alone.

func (Piece) Command

func (Piece) Command()

type Plugin

type Plugin struct {
	*world.Self
	Res Resources
	// contains filtered or unexported fields
}

Plugin lays roads by one set of rules, package site's, with a road in a player's hand.

func NewPlugin

func NewPlugin(w *world.Plugin, brd *board.Plugin, cfg Config) *Plugin

NewPlugin lays roads over w and brd as cfg says.

func (*Plugin) DefaultBindings

func (p *Plugin) DefaultBindings() []control.Binding

DefaultBindings are Shift+R taking the road in hand and, while it is held, the cursor aiming it, a left click marking a point of its route, a left drag with Shift laying a piece toward a neighbour, and a right click or Esc putting it down.

func (*Plugin) EventHandler

func (p *Plugin) EventHandler() control.EventHandler

EventHandler is nil: a player's bindings issue the plugin's commands.

func (*Plugin) Install

func (p *Plugin) Install(ctx plugin.Installer) error

Install registers what the plugin draws and the hosts of its moments.

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) Queues

func (p *Plugin) Queues() []command.CommandQueue

Queues are the plugin's command queues: Aim, Mark, Piece, Build, Cancel, Refuse and Levelling.

func (*Plugin) Read

func (p *Plugin) Read(w int) *Read

Read reads the plugin's state; w is the worker's index, 0 the game's own goroutine.

func (*Plugin) Reason

func (p *Plugin) Reason() *ui.Element

Reason is a label saying why the road in a player's hand may not lie or be built as planned.

func (*Plugin) Restore

func (p *Plugin) Restore()

Restore takes the Resources loaded.

func (*Plugin) RunPlan

func (p *Plugin) RunPlan(ctx goke.RunCtx, d time.Duration)

RunPlan carries out the players' commands at once, the rules of Estimated with them, and has the roads confirmed built in the next step of the simulation. Call it after the board's and the topography's RunPlan.

func (*Plugin) Serializable

func (p *Plugin) Serializable() plugin.Serializable

Serializable is the plugin's Resources, kept whole; the roads laid are the board's cells.

func (*Plugin) Settings

func (p *Plugin) Settings() []control.Setting

Settings is the one setting, the ground levelled under the roads laid (plugin.Tunable).

func (*Plugin) Window

func (p *Plugin) Window() *ui.Element

Window is the window asking a player whether to build the road it planned, with what it takes and what it costs, shown while it asks.

func (*Plugin) WithShaper

func (p *Plugin) WithShaper(s ground.Shaper) *Plugin

WithShaper gives the plugin the ground a road's levelling grades; without it a road lies only where the ground fits it already.

type Read

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

Read reads the roads in the players' hands and the roads built.

func (*Read) Built

func (r *Read) Built() []Receipt

Built is every road built since Built was last read, in the order built.

func (*Read) Estimate

func (r *Read) Estimate(issuer command.Issuer) (site.Estimate, float32, bool)

Estimate is the plan of the road in the hand of issuer and its price; false while the hand holds no plan.

func (*Read) Levelling

func (r *Read) Levelling() bool

Levelling reports whether the tool levels the ground under the roads it lays (Settings.Levelling).

type Receipt

type Receipt struct {
	Issuer   command.Issuer
	Estimate site.Estimate
	Price    float32
}

Receipt is a road built: whose hand laid it, what it took and what it cost.

type Refuse

type Refuse struct{ Why string }

Refuse is a rule's answer to Estimated: the road planned may not be built, Why shown to its player.

func (Refuse) Command

func (Refuse) Command()

type Resources

type Resources struct {
	Settings Settings
	Orders   []Order
	Receipts []Receipt
}

Resources is the state of roads, saved with the game whole: its Settings, the roads ordered and not yet built, and the receipts of those built that Read.Built has not handed out yet.

type Settings

type Settings struct{ Levelling bool }

Settings is what roads lets the players adjust, saved with the game: whether the tool levels the ground under the roads it lays.

Directories

Path Synopsis
Package site is where a road may run and what laying it takes: Route finds the cheapest way from cell to cell over a Ground under the Rules, Plan turns a way into an Estimate (the cells, their links, the corners levelled and what it all comes to) or says why not (Refusal).
Package site is where a road may run and what laying it takes: Route finds the cheapest way from cell to cell over a Ground under the Rules, Plan turns a way into an Estimate (the cells, their links, the corners levelled and what it all comes to) or says why not (Refusal).

Jump to

Keyboard shortcuts

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