Expand description
The .map text format of a grid map: a RON header, a --- line, then
one character per tile, top row first.
(
name: "Crossing",
legend: { '.': "plain", 'T': "forest", '~': "water" },
features: { (2, 0): Sign("Turn back") },
look: (tiles: "indoor", light: "dusk"),
)
---
..T
~~.The header has the map’s name, its legend (tile character →
terrain id), its features and its look; the last two may be left
out. A game says what a feature is (the MapFeature hook: its own
serde type, written after the tile’s (x, y)), what a terrain id
resolves to, and which tile looks there are (MapFormat). Every
problem is reported together, each with its line and column.
The look is kept beside the tiles, for a skin to paint them by; the
rules never need it. As a format (ADR-0007): MapText.
Structs§
- GridMap
- A map read from a
.mapfile: its tiles and features, the legend it was written with (for printing it back) and its look. - Legend
- A map’s legend: tile character → terrain id as written, and what each resolved to.
- MapFormat
- What a game’s maps may be: the tile looks there are, and how big a map
may be. Build it with
MapFormat::new(ADR-0039). - MapLook
- How a map looks, as far as its file says: which pictures a skin that has pictures paints its terrain with, and in which light. A skin without them ignores it. Look data only: the rules never see it.
- MapText
- The
.mapformat (map,.map) of a game’s maps, read asparsesays: the game’sMapFormat, what a legend’s terrain id resolves to, and its featuresF.
Enums§
- NoFeature
- The feature of a game whose maps have none.
Constants§
- DEFAULT_
LIGHT - The light of a map that names none.
- DEFAULT_
TILES - The tile look of a map that names none.
- SEPARATOR
- The line separating the RON header from the tile rows.
Traits§
- MapFeature
- A game’s tile feature, as written in a map header after the tile’s
(x, y)(a shop, a chest, a sign): the hook through which a game adds its own things to the format.
Functions§
- column_
number - 1-based column number of 0-based char index
i. - header_
lines - The header lines of map
source: every line before the separator (all of them if it has none). - header_
position - 1-based line and column of the first
needlein the header lines. - legend_
position - 1-based line and column of legend entry
cin the header lines: the quoted character if found, else the terrain id string, else the start. - line_
number - 1-based line number of 0-based line index
i. - parse
- Parses map
source(errors attributed tofile), resolving legend terrain ids withterrain. Reports every problem with its line and column. - Prints
mapin.mapformat: its look only if it isn’t the look of a map that names none.Noneif a tile’s terrain has no character in the legend. Parsing the text givesmapback.