Cell

Cell

A single cell on the board. Holds terrain, one optional agent, a list of items on the ground, and a list of active effects.

Cells do not fire DOM or network events — they notify the board, which fans out to any registered change listeners (e.g. the renderer).

Constructor

new Cell(board, x, y)

Source:
Parameters:
Name Type Description
board Board
x number

column (0-based)

y number

row (0-based)

Classes

Cell

Members

_animItemSymbol :Symbol|null

Description:
  • Per-cell animated item symbol set by onFrame. Same mechanism as _animTerrainSymbol but for the topmost item.

Source:

Per-cell animated item symbol set by onFrame. Same mechanism as _animTerrainSymbol but for the topmost item.

Type:

_animTerrainSymbol :Symbol|null

Description:
  • Per-cell animated terrain symbol set by onFrame. Equivalent to Java's fireRerender(cell, piece, symbol) — lets singleton terrain pieces render different symbols at different positions without lock-step.

Source:

Per-cell animated terrain symbol set by onFrame. Equivalent to Java's fireRerender(cell, piece, symbol) — lets singleton terrain pieces render different symbols at different positions without lock-step.

Type:

agent :Agent|null

Source:
Type:

effects :Array.<Effect>

Source:
Type:

hasNoEffects

Description:
  • True if there are no active effects in this cell.

Source:

True if there are no active effects in this cell.

isBagEmpty

Description:
  • True if there are no items on the ground in this cell.

Source:

True if there are no items on the ground in this cell.

items :Array.<Item>

Source:
Type:

terrain :Terrain|null

Source:
Type:

topEffect

Description:
  • The topmost effect, or null.

Source:

The topmost effect, or null.

topItem

Description:
  • The topmost item, or null.

Source:

The topmost item, or null.

visited

Description:
  • Breadcrumb counter: updated each time the player steps here. Used for pathfinding heuristics.

Source:

Breadcrumb counter: updated each time the player steps here. Used for pathfinding heuristics.

Methods

addEffect(effect)

Source:
Parameters:
Name Type Description
effect Effect

addItem(item)

Source:
Parameters:
Name Type Description
item Item

canEnter(agentLoc, agent, dir, targetPlayeropt) → {boolean}

Description:
  • Can an agent enter this cell from agentLoc in direction dir?

Source:
Parameters:
Name Type Attributes Default Description
agentLoc Cell

current cell of the moving agent

agent Agent
dir Direction
targetPlayer boolean <optional>
false

true if the agent intends to attack the player

Returns:
Type
boolean

containsPlayer()

Description:
  • True if the player is currently standing on this cell.

Source:

explosion(player)

Description:
  • Trigger a fire explosion at this cell, spreading to all adjacent cells whose terrain can be entered. Mirrors Java Cell.explosion().

Source:
Parameters:
Name Type Description
player Player

getAdjacentCell(direction) → {Cell|null}

Description:
  • The adjacent cell in the given direction, or null for vertical directions (UP/DOWN cross board boundaries, handled at a higher level).

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

getApparentTerrain() → {Terrain}

Description:
  • The terrain as it should appear to the player. Subclasses that implement a TerrainProxy decorator should override this to return the wrapped terrain.

Source:
Returns:
Type
Terrain

getDisplaySymbol(outside) → {Object}

Description:
  • Compute the display symbol for this cell by layering terrain → item → under-effects → agent → above-effects. Used by the board renderer.

    The layering order mirrors the original Java getCurrentSymbol() logic:

    1. terrain (or the piece being queried if it IS the terrain)
    2. top item (unless terrain has HIDES_ITEMS)
    3. under-effects (isAboveAgent === false)
    4. agent
    5. above-effects (isAboveAgent === true)
Source:
Parameters:
Name Type Description
outside boolean

whether the board is in outside (daylight) mode

Returns:
Type
Object

moveAgentTo(next, agent)

Description:
  • Move an agent from this cell to another cell in one operation (more efficient than remove + set, avoids creating an intermediate state).

Source:
Parameters:
Name Type Description
next Cell
agent Agent

onSteppedOn(event, agentLoc, agent)

Description:
  • Notify items on this cell that an agent has stepped onto it.

Source:
Parameters:
Name Type Description
event GameEvent
agentLoc Cell
agent Agent

openContainer(containerName, item, count, emptyTerrainKey, player)

Description:
  • Open a container (Chest, Crate, etc.): change the terrain to the empty state, add items to the player's bag, and fire a message.

Source:
Parameters:
Name Type Description
containerName string

e.g. "chest" or "crate"

item Item | null

item inside (null if empty)

count number

how many to give

emptyTerrainKey string

Registry key for the empty terrain

player Player

removeAgent(agent)

Description:
  • Remove the given agent from this cell (no-op if agent is null or differs).

Source:
Parameters:
Name Type Description
agent Agent

removeEffect(effect)

Source:
Parameters:
Name Type Description
effect Effect

removeItem(item)

Description:
  • Remove the last occurrence of the given item from this cell.

Source:
Parameters:
Name Type Description
item Item

setAgent(agent)

Description:
  • Place an agent on this cell. Any previously present agent is cleared first. Do NOT pass null — use removeAgent() to clear.

Source:
Parameters:
Name Type Description
agent Agent

setTerrain(terrain)

Description:
  • Replace the terrain on this cell. Fires a cell-change notification.

Source:
Parameters:
Name Type Description
terrain Terrain