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
- func Blocks() cond.Word[Estimated]
- func Crossed() cond.Word[Built]
- func Crosses() cond.Word[Estimated]
- func Decked() cond.Word[Estimated]
- func Levelled() cond.Word[Built]
- func Levels() cond.Word[Estimated]
- func Longer(cells int) cond.Word[Estimated]
- func Moves(earth float32) cond.Word[Estimated]
- type Aim
- type Build
- type Built
- type Cancel
- type Config
- type Estimated
- type Levelling
- type Mark
- type Order
- type Piece
- type Plugin
- func (p *Plugin) DefaultBindings() []control.Binding
- func (p *Plugin) EventHandler() control.EventHandler
- func (p *Plugin) Install(ctx plugin.Installer) error
- func (p *Plugin) Name() string
- func (p *Plugin) Queues() []command.CommandQueue
- func (p *Plugin) Read(w int) *Read
- func (p *Plugin) Reason() *ui.Element
- func (p *Plugin) Restore()
- func (p *Plugin) RunPlan(ctx goke.RunCtx, d time.Duration)
- func (p *Plugin) Serializable() plugin.Serializable
- func (p *Plugin) Settings() []control.Setting
- func (p *Plugin) Window() *ui.Element
- func (p *Plugin) WithShaper(s ground.Shaper) *Plugin
- type Read
- type Receipt
- type Refuse
- type Resources
- type Settings
Constants ¶
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 ¶
Blocks is the word of a plan whose levelling waits for something standing on a cell to go.
Types ¶
type Built ¶
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.
type Cancel ¶
type Cancel struct{}
Cancel builds nothing of the road its player was asked about, its route still marked.
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 ¶
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.
type Levelling ¶
type Levelling struct{ On bool }
Levelling sets whether the tool levels the ground under the roads it lays (Settings.Levelling).
type Mark ¶
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.
type Order ¶
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 ¶
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.
type Plugin ¶
Plugin lays roads by one set of rules, package site's, with a road in a player's hand.
func (*Plugin) DefaultBindings ¶
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) 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 ¶
Read reads the plugin's state; w is the worker's index, 0 the game's own goroutine.
func (*Plugin) Reason ¶
Reason is a label saying why the road in a player's hand may not lie or be built as planned.
func (*Plugin) RunPlan ¶
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 ¶
Settings is the one setting, the ground levelled under the roads laid (plugin.Tunable).
type Read ¶
type Read struct {
// contains filtered or unexported fields
}
Read reads the roads in the players' hands and the roads built.
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.
Source Files
¶
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). |