Members
(constant) ADJ_DIRECTIONS
- Description:
Directions that lead to adjacent cells on the same board (8-directional).
- Source:
Directions that lead to adjacent cells on the same board (8-directional).
(constant) DIR_BY_DELTA
- Description:
Lookup table:
"${xDelta},${yDelta}"→ Direction constant
- Source:
Lookup table: "${xDelta},${yDelta}" → Direction constant
(constant) DIR_KEYS
- Description:
Direction keys used after throw/fire-mode
- Source:
Direction keys used after throw/fire-mode
(constant) EMPTY_HANDED
- Description:
Singleton representing the player wielding nothing. Always lives at index 0 in the PlayerBag.
- Source:
Singleton representing the player wielding nothing. Always lives at index 0 in the PlayerBag.
(constant) FIRE_DAMAGE
- Description:
Animated fire — 4-frame loop using ω glyph cycling through red/orange/yellow. Deals fire damage to non-fire-resistant agents and converts trees to stumps.
- Source:
Animated fire — 4-frame loop using ω glyph cycling through red/orange/yellow. Deals fire damage to non-fire-resistant agents and converts trees to stumps.
(constant) KEY_MAP
- Description:
Key → { action, dir? } mapping — matches original Java InputManager key bindings.
Movement: arrow keys / vi keys (hjkl + yubn) / numpad Pickup: g (or p) Drop: d Use: Enter Throw: t followed by a direction key (two-step) Fire (ranged): f followed by a direction key (two-step), OR shift+direction (one-step) Shift+arrow, shift+vi (HJKLYUBN), or ctrl+numpad Vertical: z (game detects UP vs DOWN from terrain) Bag select-up: a Bag select-down: s First weapon: w Empty-handed: e Reorder up: c (or <) Reorder down: v (or >)
- Source:
Key → { action, dir? } mapping — matches original Java InputManager key bindings.
Movement: arrow keys / vi keys (hjkl + yubn) / numpad Pickup: g (or p) Drop: d Use: Enter Throw: t followed by a direction key (two-step) Fire (ranged): f followed by a direction key (two-step), OR shift+direction (one-step) Shift+arrow, shift+vi (HJKLYUBN), or ctrl+numpad Vertical: z (game detects UP vs DOWN from terrain) Bag select-up: a Bag select-down: s First weapon: w Empty-handed: e Reorder up: c (or <) Reorder down: v (or >)
(constant) MAP_DIRECTIONS
- Description:
Directions that can lead to adjacent boards (cardinal + vertical).
- Source:
Directions that can lead to adjacent boards (cardinal + vertical).
(constant) NOT_EDITABLE
- Description:
This piece should not be available in the map editor.
- Source:
This piece should not be available in the map editor.
(constant) PENETRABLE
- Description:
Thrown items can fly over this terrain.
- Source:
Thrown items can fly over this terrain.
(constant) PLAYER
- Description:
Bitmask flag constants for pieces, terrain, items, and agents. Mirrors Flags.java exactly.
- Source:
Bitmask flag constants for pieces, terrain, items, and agents. Mirrors Flags.java exactly.
(constant) TerrainUtils
- Description:
Utility helpers for terrain manipulation. Mirrors TerrainUtils.java.
- Source:
Utility helpers for terrain manipulation. Mirrors TerrainUtils.java.
(constant) _FIREBALL_SYMBOLS
- Description:
Fireball — fired by Thermadon. Deals heavy fire damage.
- Source:
Fireball — fired by Thermadon. Deals heavy fire damage.
(constant) _serializers
- Description:
Registry — singleton cache for all piece instances.
Pieces are immutable singletons identified by their serialization key (pipe-delimited: "TypeName|arg1|arg2"). Nested piece references within an arg use ^ as a sub-delimiter (e.g. "Altar^none" deserializes as the piece from key "Altar|none").
Usage: Registry.register("Floor", Floor.SERIALIZER); const floor = Registry.get("Floor"); Registry.serialize(floor); // → "Floor"
- Source:
Registry — singleton cache for all piece instances.
Pieces are immutable singletons identified by their serialization key (pipe-delimited: "TypeName|arg1|arg2"). Nested piece references within an arg use ^ as a sub-delimiter (e.g. "Altar^none" deserializes as the piece from key "Altar|none").
Usage: Registry.register("Floor", Floor.SERIALIZER); const floor = Registry.get("Floor"); Registry.serialize(floor); // → "Floor"
(constant) events
- Description:
Global event bus singleton.
- Source:
Global event bus singleton.
(constant) store
- Description:
IndexedDB-backed wrapper for game saves. All methods are async. Quota is effectively unlimited (50% of available disk).
- Source:
IndexedDB-backed wrapper for game saves. All methods are async. Quota is effectively unlimited (50% of available disk).
Methods
_buildCellHoverText(cell) → {string|null}
- Description:
Build the HTML legend for a hovered cell: terrain, then agent (if any), then the topmost item (unless the terrain has HIDES_ITEMS). Mirrors Java's CellInfoPanel.renderCellInfo().
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
cell |
Cell |
Returns:
- Type
- string | null
_buildItemListText(cell) → {string|null}
- Description:
Build the HTML text for the item-list popup, mirroring Java's MessageManager.displayItemsAtCurrentCell(). Returns null if the cell has no items.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
cell |
Cell |
Returns:
- Type
- string | null
_itemAtDisplayIndex(cell, index) → {Item|null}
- Description:
Return the item at visual display index
indexin the grouped item list for the given cell. Groups items by name (matching popup display order). Index 0 = first item shown in the popup (pressing '1' or 'p').
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
cell |
Cell | |
index |
number |
Returns:
- Type
- Item | null
_openDB()
- Description:
Open (or reuse) the IndexedDB database.
- Source:
_renderPieceLabel(piece, outside) → {string}
- Description:
Render a colored symbol + name label for one piece.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
piece |
Piece | |
outside |
boolean |
Returns:
- Type
- string
_resolveTerrain()
- Description:
Resolve a terrain arg that may be either a plain string key or an already-resolved Piece.
- Source:
_ri()
- Description:
Resolve an item arg: if it's a plain string key, look it up in the Registry.
- Source:
_rt()
- Description:
Resolve a terrain arg that may be a plain string key or an already-resolved Piece.
- Source:
_rt()
- Description:
Resolve a terrain arg that may be a plain string key or an already-resolved Piece.
- Source:
_showFadePopup(boardEl, popupLayer, text, cellX, cellY, optionsopt) → {HTMLElement|null}
- Description:
Show a fade-out popup anchored to the right of a cell. Returns the popup element so callers can remove it early if needed.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
boardEl |
HTMLElement | ||
popupLayer |
HTMLElement | ||
text |
string | ||
cellX |
number | ||
cellY |
number | ||
options |
Object |
<optional> |
Returns:
- Type
- HTMLElement | null
_showModalPopup()
- Description:
Show a modal (blocking) positional popup. Freezes the game until ESC/Enter.
- Source:
_tryGetPiece()
- Description:
Try to get a piece from the registry; returns null if not found.
- Source:
_wrapFactory(typeId, factory)
- Description:
Wrap a legacy bare factory function in a minimal Serializer-shaped object. Provides create() only; tag/example/template/store throw (Uncategorised).
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
typeId |
string | |
factory |
function |
allColors()
- Description:
All registered color names → Color instances.
- Source:
assessAmmo(event, weapon, ammoItem) → {Item|null}
- Description:
Check whether the player has loaded ammo for
weapon. If so, decrement the ammo count and returnammoItemto be fired. Otherwise fire an "Out of ammo" message and return null.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
event |
GameEvent | |
weapon |
Item | — the weapon item (used to locate the bag entry) |
ammoItem |
Item | — the projectile to return when ammo is available |
Returns:
- Type
- Item | null
buildBoard(data, boardPath) → {Object}
- Description:
Build a Board from a deserialized scenario data object. Also used to restore boards from player.unsavedMaps.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
data |
object | raw JSON or deserialized save data |
boardPath |
string |
Returns:
- Type
- Object
burntColor(color) → {string}
- Description:
Return a darker, browned version of the given color (the "burnt" effect).
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
color |
Color |
Returns:
- Type
- string
checkPlayerHas()
- Description:
Check if a player has a given flag (by label) or item (by name).
- Source:
colorByName(name) → {Color|null}
- Description:
Look up a Color instance by its name (case-insensitive). Returns null if not found.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string |
Returns:
- Type
- Color | null
description()
- Description:
Return a comma-separated string of visible flag labels for a given flags value. Returns an empty string if no visible flags are set.
- Source:
deserializeBoard(data, board)
- Description:
Restore a Board's state from a serialized data object.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
data |
object | |
board |
Board |
deserializePlayer(data, player)
- Description:
Restore the player's mutable state from a serialized object. The player instance must already exist; this mutates it.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
data |
object | |
player |
Player |
directionByName()
- Description:
Look up a Direction by name (case-insensitive). Returns null if not found.
- Source:
findPathToTarget()
- Description:
Determine the direction an agent should move given its targeting spec. Returns a Direction or null if no move is possible.
- Source:
frozenColor(color) → {string}
- Description:
Return an rgb() string lightened toward white (the "frozen" effect).
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
color |
Color |
Returns:
- Type
- string
getFlag()
- Description:
Look up a flag constant by its display label. Returns -1 if not found.
- Source:
getFlagByLabel()
- Description:
Look up a flag bitmask by its display label, returning 0 if unknown.
- Source:
initCellHoverPopup()
- Description:
Show a brief legend popup when the player hovers over a cell. Mirrors the Java CellInfoPanel behaviour: 600 ms delay to show, auto-hides after 2100 ms or on mouseout/mousedown.
- Source:
initDialogs(onWinCloseopt)
- Description:
Connect the events bus to the modal-message dialog. Call once during app init.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
onWinClose |
function |
<optional> |
called when win dialog is closed |
initInput(target)
- Description:
Wire keyboard input to the game controller.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
target |
HTMLElement | element to listen on (typically document or #board) |
initInventoryPanel()
- Description:
Inventory panel — renders the player's bag as a list of clickable items. The selected item is highlighted. Clicking an item selects it.
- Source:
initMessageLog()
- Description:
Message log — appends game messages to the #message-list element and auto-scrolls to the bottom.
- Source:
initMouseInput(boardEl)
- Description:
Wire mouse clicks on the board and inventory to game actions. Board click rules:
- Click on a different cell: move one step toward it (or fire with Shift).
- Click on the player's own cell: pick up the topmost item. Inventory click: select that item in the bag.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
boardEl |
HTMLElement |
initPopupMessages()
- Description:
Cell popup messages — mirrors the Java "popup menu" feature.
When a non-modal message fires, a small label appears above the relevant cell on the board and fades out after 4 seconds.
- Source:
initStatsPanel()
- Description:
Stats panel — keeps the HP bar, HP text, XP, gold, and flags display in sync with the player model via the events bus.
- Source:
is()
- Description:
True if
flagis set inflags.
- Source:
loadBoard(boardPath, baseURLopt) → {Promise.<{board: Board, startX: number, startY: number, startInv: Array.<string>}>}
- Description:
Load a board from a scenario JSON file.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
boardPath |
string | path stem, e.g. "tutorial/start" |
|
baseURL |
string |
<optional> |
base URL, default "/scenarios/" |
Returns:
- Type
- Promise.<{board: Board, startX: number, startY: number, startInv: Array.<string>}>
nameByColor(hex) → {string|null}
- Description:
Look up a color's display name by its hex string. Returns null if not found.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
hex |
string |
Returns:
- Type
- string | null
not()
- Description:
True if
flagis NOT set inflags.
- Source:
randomColor()
- Description:
Return a random color hex string (used by win-game animation).
- Source:
serializeBoard(board) → {object}
- Description:
Serialize a Board's cell state to a plain object (safe to JSON.stringify). Player position is NOT saved here (managed by game.js).
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
board |
Board |
Returns:
- Type
- object
serializePlayer(player) → {object}
- Description:
Serialize the player to a plain object.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
player |
Player |
Returns:
- Type
- object
showConfirm(message, onConfirm, optsopt)
- Description:
Show a yes/no confirmation dialog.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
message |
string | ||
onConfirm |
function | ||
opts |
Object |
<optional> |
showLoadDialog(onLoad)
- Description:
Show load dialog with a list of saves to choose from. The
onLoadcallback receives the chosen slot name.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
onLoad |
function |
showMenu() → {Promise.<(string|null)>}
- Description:
Show the main menu. Returns a Promise that resolves with the chosen action. Possible resolved values: "new-game" | "load-game" | "help" | null (dismissed)
- Source:
Returns:
- Type
- Promise.<(string|null)>
showModalMessage(message, onCloseopt)
- Description:
Show a short modal message (used for win conditions, key events, etc.). If the message looks like a URL (.html extension), shows the win dialog. Otherwise shows a confirm dialog with "OK" only.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
message |
string | ||
onClose |
function |
<optional> |
showSaveDialog(onSave)
- Description:
Show save dialog. The
onSavecallback receives the chosen slot name.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
onSave |
function |
showScenarioDialog(scenarios) → {Promise.<({id:string, start:string}|null)>}
- Description:
Show scenario selection list.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
scenarios |
Array.<{id:string, start:string, name:string, description:string, creator:string}> |
Returns:
- Type
- Promise.<({id:string, start:string}|null)>
showWinDialog(url, onCloseopt)
- Description:
Show the win screen with an iframe pointing to the win URL.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
url |
string | relative or absolute URL for the win HTML page |
|
onClose |
function |
<optional> |
stateFromString()
- Description:
Parse a state string (case-insensitive) to a State constant.
- Source:
Type Definitions
CellFn()
- Source:
FlagsFn()
- Source:
InventoryFn()
- Source:
MessageFn()
- Source:
ModalFn()
- Source:
PlayerFn()
- Source:
VoidFn()
- Source: