Board

Board

The main model object in the game.

Holds a 40×25 grid of Cell objects (indexed cells[x][y], x-major), tracks the player's position, adjacent board references (for board-to-board navigation), and animation state.

Board is a plain data model — rendering is handled by the board-view module. Change notifications are delivered by calling registered listeners whenever a cell's state is mutated.

Constructor

new Board()

Source:

Classes

Board

Members

_adjacentBoards

Description:
  • direction name → board path stem (e.g. "north" → "desert.rimmos")

Source:

direction name → board path stem (e.g. "north" → "desert.rimmos")

_animated :Array.<AnimationProxy>

Description:
  • List of AnimationProxy objects — one per animated piece currently on the board. Maintained by Cell as agents/terrain are placed and removed.

Source:

List of AnimationProxy objects — one per animated piece currently on the board. Maintained by Cell as agents/terrain are placed and removed.

Type:

_changeListeners :Array.<function(Cell): void>

Source:
Type:
  • Array.<function(Cell): void>

boardID

Description:
  • Path stem identifying this board, e.g. "tutorial/start".

Source:

Path stem identifying this board, e.g. "tutorial/start".

folder :string|null

Description:
  • Scenario folder name (e.g. "malloc-wizard"). Used by the editor to resolve adjacent board paths without needing the full server path.

Source:

Scenario folder name (e.g. "malloc-wizard"). Used by the editor to resolve adjacent board paths without needing the full server path.

Type:
  • string | null

outside

Description:
  • True if the board is set outdoors (affects symbol color rendering).

Source:

True if the board is set outdoors (affects symbol color rendering).

playerX

Description:
  • Current player column (-1 if not placed).

Source:

Current player column (-1 if not placed).

playerY

Description:
  • Current player row (-1 if not placed).

Source:

Current player row (-1 if not placed).

startX

Description:
  • Default player entry column when entering without a transition.

Source:

Default player entry column when entering without a transition.

startY

Description:
  • Default player entry row when entering without a transition.

Source:

Default player entry row when entering without a transition.

visitCount

Description:
  • Monotonically increasing counter stamped onto each cell the player visits. Used for breadcrumb-style pathfinding.

Source:

Monotonically increasing counter stamped onto each cell the player visits. Used for breadcrumb-style pathfinding.

Methods

_notifyCellChange(cell)

Source:
Parameters:
Name Type Description
cell Cell

addAnimated(x, y, piece)

Description:
  • Register an animated piece at (x, y). Called by Cell when an agent or terrain with an onFrame method is placed.

Source:
Parameters:
Name Type Description
x number
y number
piece object

find(filter) → {Cell|null}

Description:
  • Find the first cell matching filter(cell, null), or null.

Source:
Parameters:
Name Type Description
filter function
Returns:
Type
Cell | null

findRandomCell() → {Cell}

Description:
  • Find a random traversable cell with no agent present.

Source:
Returns:
Type
Cell

fireColorEvent(event, color, _origin)

Description:
  • Broadcast a color event to all terrain and agents on the board. Each piece's onColorEvent() is called; pieces compare their own color to decide whether to react.

Source:
Parameters:
Name Type Description
event GameEvent
color string

CSS color hex string

_origin Cell

cell that originated the event (informational)

getAdjacentBoard(direction) → {string|null}

Source:
Parameters:
Name Type Description
direction Direction
Returns:
Type
string | null

getAdjacentCell(x, y, dir) → {Cell|null}

Description:
  • Return the cell adjacent to (x, y) in dir, or null.

Source:
Parameters:
Name Type Description
x number
y number
dir Direction
Returns:
Type
Cell | null

getCellAt(x, y) → {Cell|null}

Description:
  • Return the cell at (x, y), or null if out-of-bounds.

Source:
Parameters:
Name Type Description
x number
y number
Returns:
Type
Cell | null

getCurrentCell()

Description:
  • Return the cell currently occupied by the player.

Source:

hasNonTransientEffect() → {boolean}

Description:
  • True if any cell has a non-transient effect (used to delay saving).

Source:
Returns:
Type
boolean

moveAnimated(fromX, fromY, toX, toY, piece)

Description:
  • Update the (x, y) of the proxy for piece when it moves to an adjacent cell without being removed and re-added. Called by Cell.moveAgentTo.

Source:
Parameters:
Name Type Description
fromX number
fromY number
toX number
toY number
piece object

onCellChange(fn)

Description:
  • Register a callback invoked whenever a cell's state changes.

Source:
Parameters:
Name Type Description
fn function

removeAnimated(x, y, piece)

Description:
  • Deregister the proxy for piece at (x, y). Called by Cell when an agent or animated terrain is removed.

Source:
Parameters:
Name Type Description
x number
y number
piece object

setAdjacentBoard(directionName, boardPath)

Source:
Parameters:
Name Type Description
directionName string

e.g. "north"

boardPath string

path stem, e.g. "desert.rimmos"

visit(visitor)

Description:
  • Call visitor(cell) for every cell on the board.

Source:
Parameters:
Name Type Description
visitor function

visitRange(center, range, includeCenter, visitor)

Description:
  • Visit cells in expanding rings around center, closest first. visitor(cell, dist) should return false to stop early.

Source:
Parameters:
Name Type Description
center Cell
range number
includeCenter boolean
visitor function