procLevelKit.grid: the level as plain data. A level is a width x height grid of
one-character cells (the same characters its text form uses), plus its
start, exit, enemy and loot markers and its props. Pure data: no entities,
no engine state, so every peer computes the same thing from the same seed.
new(kind: string, seed: number, w: number, h: number, fill: string?) → Level
| arg | type | description |
|---|
| kind | string | |
| seed | number | |
| w | number | |
| h | number | |
| fill | string? | |
inBounds(L: Level, x: number, y: number) → boolean
| arg | type | description |
|---|
| L | Level | |
| x | number | |
| y | number | |
idx(L: Level, x: number, y: number) → number
| arg | type | description |
|---|
| L | Level | |
| x | number | |
| y | number | |
xy(L: Level, i: number) → void
| arg | type | description |
|---|
| L | Level | |
| i | number | |
get(L: Level, x: number, y: number) → string
| arg | type | description |
|---|
| L | Level | |
| x | number | |
| y | number | |
set(L: Level, x: number, y: number, ch: string) → void
| arg | type | description |
|---|
| L | Level | |
| x | number | |
| y | number | |
| ch | string | |
fillRect(L: Level, x0: number, y0: number, x1: number, y1: number, ch: string) → void
| arg | type | description |
|---|
| L | Level | |
| x0 | number | |
| y0 | number | |
| x1 | number | |
| y1 | number | |
| ch | string | |
walkableChar(ch: string?) → boolean
| arg | type | description |
|---|
| ch | string? | |
blockedByProp(L: Level) → void
Walkable terrain that no solid prop stands on.
passable(L: Level, x: number, y: number, blocked: { [number]: boolean }?) → boolean
| arg | type | description |
|---|
| L | Level | |
| x | number | |
| y | number | |
| blocked | { [number]: boolean }? | |
bfs(L: Level, sx: number, sy: number, blocked: { [number]: boolean }?) → void
Breadth-first distances (4-neighbour steps) from (sx, sy) over passable
cells. Returns a table index -> steps for every reachable cell.
| arg | type | description |
|---|
| L | Level | |
| sx | number | |
| sy | number | |
| blocked | { [number]: boolean }? | |
regions(L: Level) → void
Connected walkable regions, largest first (ties: lower first index first).
keepLargest(L: Level, fill: string?) → number
Keep only the largest walkable region; every other walkable cell becomes
`fill` (default: the level's `unreachable` char, else wall).
| arg | type | description |
|---|
| L | Level | |
| fill | string? | |
isSimplePoint(L: Level, x: number, y: number, blocked: { [number]: boolean }?) → boolean
| arg | type | description |
|---|
| L | Level | |
| x | number | |
| y | number | |
| blocked | { [number]: boolean }? | |
count(L: Level, ch: string) → number
| arg | type | description |
|---|
| L | Level | |
| ch | string | |
markersOf(L: Level, kind: string) → void
| arg | type | description |
|---|
| L | Level | |
| kind | string | |
rows(L: Level) → void
Rows of the terrain alone (no markers or props).
fnv(s: string) → string
FNV-1a 32-bit over a string, as 8 hex digits.
| arg | type | description |
|---|
| s | string | |
⌬ Types
Cell = { x: number, y: number }Marker = { x: number, y: number, type: string }Prop = { x: number, y: number, name: string, char: string, solid: boolean }Level = {